Skip to content
Permalink
Browse files

[ogr][auth] Add geojson username/password test

  • Loading branch information
elpaso committed Nov 14, 2017
1 parent dc6101a commit d163c01673d5f72075876676dd883095cf889089
Showing with 17 additions and 0 deletions.
  1. +17 −0 tests/src/python/test_authmanager_password_ows.py
@@ -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
@@ -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):
"""
@@ -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):
"""

0 comments on commit d163c01

Please sign in to comment.
You can’t perform that action at this time.