Skip to content
Permalink
Browse files

Merge pull request #8950 from elpaso/bugfix-opengis-zug-wmsroot

Fix server WMS short name (unreported)
  • Loading branch information
elpaso committed Jan 23, 2019
2 parents e3516ab + 4e8898d commit de2976735164621544691b0931ed84ce1b153dc4
@@ -2548,8 +2548,9 @@ namespace QgsWms
}

// init groups
const QString rootName { QgsServerProjectUtils::wmsRootName( *mProject ) };
const QgsLayerTreeGroup *root = mProject->layerTreeRoot();
initLayerGroupsRecursive( root, mProject->title() );
initLayerGroupsRecursive( root, rootName.isEmpty() ? mProject->title() : rootName );
}

void QgsRenderer::initLayerGroupsRecursive( const QgsLayerTreeGroup *group, const QString &groupName )
@@ -514,6 +514,47 @@ def test_wms_GetLegendGraphic_EmptyLegend(self):
self.assertEqual(-1, h.find(b'Content-Type: text/xml; charset=utf-8'), "Header: %s\nResponse:\n%s" % (h, r))
self.assertNotEqual(-1, h.find(b'Content-Type: image/png'), "Header: %s\nResponse:\n%s" % (h, r))

def test_wms_GetLegendGraphic_wmsRootName(self):
"""Test an unreported issue when a wmsRootName short name is set in the service capabilities"""

# First test with the project title itself:
qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": self.testdata_path + 'test_project_wms_grouped_layers.qgs',
"SERVICE": "WMS",
"VERSION": "1.1.1",
"REQUEST": "GetLegendGraphic",
"LAYER": "QGIS%20Server%20-%20Grouped%20Layer",
"FORMAT": "image/png",
"HEIGHT": "840",
"WIDTH": "1226",
"BBOX": "609152,5808188,625492,5814318",
"SRS": "EPSG:25832",
"SCALE": "38976"
}.items())])

h, r = self._execute_request(qs)
self.assertEqual(-1, h.find(b'Content-Type: text/xml; charset=utf-8'), "Header: %s\nResponse:\n%s" % (h, r))
self.assertNotEqual(-1, h.find(b'Content-Type: image/png'), "Header: %s\nResponse:\n%s" % (h, r))

# Then test with the wmsRootName short name:
qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": self.testdata_path + 'test_project_wms_grouped_layers_wmsroot.qgs',
"SERVICE": "WMS",
"VERSION": "1.1.1",
"REQUEST": "GetLegendGraphic",
"LAYER": "All_grouped_layers",
"FORMAT": "image/png",
"HEIGHT": "840",
"WIDTH": "1226",
"BBOX": "609152,5808188,625492,5814318",
"SRS": "EPSG:25832",
"SCALE": "38976"
}.items())])

h, r = self._execute_request(qs)
self.assertEqual(-1, h.find(b'Content-Type: text/xml; charset=utf-8'), "Header: %s\nResponse:\n%s" % (h, r))
self.assertNotEqual(-1, h.find(b'Content-Type: image/png'), "Header: %s\nResponse:\n%s" % (h, r))


if __name__ == '__main__':
unittest.main()

0 comments on commit de29767

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