|
1 | 1 | import unittest |
2 | 2 | from qgis.core import * |
3 | 3 | import sys |
| 4 | +import os |
| 5 | +import urllib |
4 | 6 |
|
| 7 | +keyfile = os.path.join(os.path.dirname(__file__), "resources", "rod.key.pem") |
| 8 | +certfile = os.path.join(os.path.dirname(__file__), "resources", "rod.crt.pem") |
| 9 | +cafile = os.path.join(os.path.dirname(__file__), "resources", "ca.pem") |
5 | 10 |
|
6 | 11 | class PKITests(unittest.TestCase): |
7 | 12 | ''' |
8 | | - Tests for the OGCatalog class that provides additional capabilities to a gsconfig catalog |
9 | | - Requires a Geoserver catalog with pki auth on localhost:8443 with a catalog named test_catalog |
10 | | - and a vector layer called test_layer |
| 13 | + Tests for PKI support in QGIS |
| 14 | + Requires a Geoserver catalog with pki auth on localhost:8443 with the default sample data |
11 | 15 | ''' |
12 | 16 |
|
13 | 17 | def testOpenWFSLayer(self): |
14 | | - uri = "http://localhost:8443/geoserver/wfs?srsname=EPSG:4326&typename=\ |
15 | | - polygons&version=1.0.0&request=GetFeature&service=WFS" |
16 | | - vlayer = QgsVectorLayer(uri, "my_wfs_layer", "WFS") |
| 18 | + params = { |
| 19 | + 'service': 'WFS', |
| 20 | + 'version': '1.0.0', |
| 21 | + 'request': 'GetFeature', |
| 22 | + 'typename': 'poly_landmarks', |
| 23 | + 'srsname': 'EPSG:4326', |
| 24 | + 'certid': certfile, |
| 25 | + 'keyid': keyfile, |
| 26 | + 'issuerid': cafile |
| 27 | + } |
| 28 | + uri = 'http://localhost:8443/geoserver/wfs?' + urllib.unquote(urllib.urlencode(params)) |
| 29 | + |
| 30 | + vlayer = QgsVectorLayer(uri, "poly_landmarks", "WFS") |
17 | 31 | self.assertTrue(vlayer.isValid()) |
18 | 32 |
|
19 | 33 | def testOpenWMSLayer(self): |
20 | | - uri = 'http://localhost:8443/geoserver/wms?layers=polygons&format=image/jpeg&crs=EPSG:4326' |
21 | | - rlayer = QgsRasterLayer(uri, 'my_wms_layer', 'wms') |
| 34 | + params = { |
| 35 | + 'service': 'wms', |
| 36 | + 'typename': 'Arc_Sample', |
| 37 | + 'crs': 'EPSG:4326', |
| 38 | + 'format': 'image/jpeg', |
| 39 | + 'certid': certfile, |
| 40 | + 'keyid': keyfile, |
| 41 | + 'issuerid': cafile |
| 42 | + } |
| 43 | + uri = 'http://localhost:8443/geoserver/wms?' + urllib.unquote(urllib.urlencode(params)) |
| 44 | + rlayer = QgsRasterLayer(uri, 'Arc_Sample', 'wms') |
22 | 45 | self.assertTrue(rlayer.isValid()) |
23 | 46 |
|
24 | 47 | def suite(): |
|
0 commit comments