Skip to content

Commit

Permalink
Server: Do not display Empty group in Capabilities and project settings
Browse files Browse the repository at this point in the history
The `test_wms_getprojectsettings` in `test_qgsserver_accesscontrol_wms.py` was marked as `Expectedfailure`, after checking duplicated test methods.
This test checks that an empty group because fo acces control could not be in GetCapabilities document with settings activated.
The same test did not exist for simple getCapabilities.

This commit fix it

Funded by 3Liz https://3liz.com
  • Loading branch information
rldhont committed Feb 3, 2023
1 parent fb5ca4c commit 1c2f1e3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/server/services/wms/qgswmsgetcapabilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,12 @@ namespace QgsWms
}

handleLayersFromTreeGroup( doc, layerElem, serverIface, project, request, treeGroupChild, wmsLayerInfos, projectSettings );

// CHeck if child layer elements have been added
if ( layerElem.elementsByTagName( QStringLiteral( "Layer" ) ).length() == 0 )
{
continue;
}
}
else
{
Expand Down
12 changes: 9 additions & 3 deletions tests/src/python/test_qgsserver_accesscontrol_wms.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ def test_wms_getcapabilities(self):
self.assertTrue(
str(response).find("<Name>Hello</Name>") != -1,
f"No Hello layer in GetCapabilities\n{response}")
self.assertTrue(
str(response).find("<Name>Country_grp</Name>") != -1,
f"Unexpected Country_grp layer in GetCapabilities\n{response}")
self.assertTrue(
str(response).find("<Name>Country</Name>") != -1,
f"No Country layer in GetCapabilities\n{response}")
Expand All @@ -52,12 +55,15 @@ def test_wms_getcapabilities(self):
self.assertTrue(
str(response).find("<Name>Hello</Name>") != -1,
f"No Hello layer in GetCapabilities\n{response}")
self.assertFalse(
str(response).find("<Name>Country_grp</Name>") != -1,
f"Unexpected Country_grp layer in GetCapabilities\n{response}")
self.assertFalse(
str(response).find("<Name>Country</Name>") != -1,
f"Unexpected Country layer in GetCapabilities\n{response}")

# This test hasn't run yet
@unittest.expectedFailure
# @unittest.expectedFailure
def test_wms_getprojectsettings(self):
query_string = "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(self.projectPath),
Expand All @@ -78,7 +84,7 @@ def test_wms_getprojectsettings(self):
f"No Country_grp layer in GetProjectSettings\n{response}")
self.assertTrue(
str(response).find(
"<LayerDrawingOrder>Country_Diagrams,Country_Labels,Country,dem,Hello_Filter_SubsetString,Hello_Project_SubsetString,Hello_SubsetString,Hello,db_point</LayerDrawingOrder>") != -1,
"<LayerDrawingOrder>Country_Diagrams,Country_Labels,Country,dem,Hello_Filter_SubsetString,Hello_Project_SubsetString,Hello_SubsetString,Hello_Filter,Hello_OnOff,Hello,db_point</LayerDrawingOrder>") != -1,
f"LayerDrawingOrder in GetProjectSettings\n{response}")

response, headers = self._get_restricted(query_string)
Expand All @@ -93,7 +99,7 @@ def test_wms_getprojectsettings(self):
f"Unexpected Country_grp layer in GetProjectSettings\n{response}")
self.assertTrue(
str(response).find(
"<LayerDrawingOrder>Country_Diagrams,Country_Labels,dem,Hello_Filter_SubsetString,Hello_Project_SubsetString,Hello_SubsetString,Hello,db_point</LayerDrawingOrder>") != -1,
"<LayerDrawingOrder>Country_Diagrams,Country_Labels,dem,Hello_Filter_SubsetString,Hello_Project_SubsetString,Hello_SubsetString,Hello_Filter,Hello,db_point</LayerDrawingOrder>") != -1,
f"Wrong LayerDrawingOrder in GetProjectSettings\n{response}")

def test_wms_getcontext(self):
Expand Down

0 comments on commit 1c2f1e3

Please sign in to comment.