Skip to content

Commit

Permalink
[ogr][auth] Add geojson username/password test
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Nov 14, 2017
1 parent dc6101a commit d163c01
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/src/python/test_authmanager_password_ows.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,19 @@ def _getWMSLayer(cls, layers, layer_name=None, authcfg=None):
wms_layer = QgsRasterLayer(uri, layer_name, 'wms')
return wms_layer

@classmethod
def _getGeoJsonLayer(cls, type_name, layer_name=None, authcfg=None):
"""
OGR layer factory
"""
if layer_name is None:
layer_name = 'geojson_' + type_name
uri = '%s://%s:%s/?MAP=%s&SERVICE=WFS&REQUEST=GetFeature&TYPENAME=%s&VERSION=2.0.0&OUTPUTFORMAT=geojson' % (cls.protocol, cls.hostname, cls.port, cls.project_path, urllib.parse.quote(type_name))
if authcfg is not None:
uri += " authcfg='%s'" % authcfg
geojson_layer = QgsVectorLayer(uri, layer_name, 'ogr')
return geojson_layer

def testValidAuthAccess(self):
"""
Access the HTTP Basic protected layer with valid credentials
Expand All @@ -178,6 +191,8 @@ def testValidAuthAccess(self):
self.assertTrue(wfs_layer.isValid())
wms_layer = self._getWMSLayer('testlayer_èé', authcfg=self.auth_config.id())
self.assertTrue(wms_layer.isValid())
geojson_layer = self._getGeoJsonLayer('testlayer_èé', authcfg=self.auth_config.id())
self.assertTrue(geojson_layer.isValid())

def testInvalidAuthAccess(self):
"""
Expand All @@ -187,6 +202,8 @@ def testInvalidAuthAccess(self):
self.assertFalse(wfs_layer.isValid())
wms_layer = self._getWMSLayer('testlayer_èé')
self.assertFalse(wms_layer.isValid())
geojson_layer = self._getGeoJsonLayer('testlayer_èé')
self.assertFalse(geojson_layer.isValid())

def testInvalidAuthFileDownload(self):
"""
Expand Down

0 comments on commit d163c01

Please sign in to comment.