Skip to content

Commit

Permalink
Merge pull request qgis#51724 from rldhont/fix-server-wms-capabilitie…
Browse files Browse the repository at this point in the history
…s-empty-group

Server: Do not display Empty group in Capabilities and project settings
  • Loading branch information
rldhont authored Feb 6, 2023
2 parents 04851d5 + ff0ca50 commit d0a9f12
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 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: 8 additions & 4 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,13 @@ 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
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 +82,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 +97,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 d0a9f12

Please sign in to comment.