Skip to content

Commit

Permalink
[Server] Fix WMS GetContext accesscontrol and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rldhont committed May 24, 2017
1 parent ac97341 commit eb7c98f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/server/qgswmsprojectparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1607,6 +1607,12 @@ void QgsWMSProjectParser::addOWSLayers( QDomDocument &doc,
{
continue;
}
#ifdef HAVE_SERVER_PYTHON_PLUGINS
if ( !mAccessControl->layerReadPermission( currentLayer ) )
{
continue;
}
#endif
if ( nonIdentifiableLayers.contains( currentLayer->id() ) )
{
layerElem.setAttribute( "queryable", "false" );
Expand Down
29 changes: 29 additions & 0 deletions tests/src/python/test_qgsserver_accesscontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import tempfile
import urllib
import base64
import re


XML_NS = \
Expand Down Expand Up @@ -237,6 +238,34 @@ def test_wms_getprojectsettings(self):
str(response).find("<LayerDrawingOrder>Country_Labels,dem,Hello_Filter_SubsetString,Hello_Project_SubsetString,Hello_SubsetString,Hello,db_point</LayerDrawingOrder>") != -1,
"LayerDrawingOrder in GetProjectSettings\n%s" % response)

def test_wms_getcontext(self):
query_string = "&".join(["%s=%s" % i for i in {
"MAP": urllib.quote(self.projectPath),
"SERVICE": "WMS",
"VERSION": "1.1.1",
"REQUEST": "GetContext"
}.items()])

response, headers = self._get_fullaccess(query_string)
self.assertTrue(
str(response).find("<Layer opacity=\"1\" queryable=\"true\" hidden=\"false\" id=\"Hello\" name=\"Hello\">") != -1,
"No Hello layer in GetContext\n%s" % response)
self.assertTrue(
str(response).find("<Layer opacity=\"1\" queryable=\"true\" hidden=\"false\" id=\"Country\" name=\"Country\">") != -1,
"No Country layer in GetContext\n%s" % response)
self.assertTrue(
str(response).find("<Layer opacity=\"1\" queryable=\"true\" hidden=\"false\" id=\"Country\" name=\"Country\">")
< str(response).find("<Layer opacity=\"1\" queryable=\"true\" hidden=\"false\" id=\"Hello\" name=\"Hello\">"),
"Hello layer not after Country layer\n%s" % response)

response, headers = self._get_restricted(query_string)
self.assertTrue(
str(response).find("<Layer opacity=\"1\" queryable=\"true\" hidden=\"false\" id=\"Hello\" name=\"Hello\">") != -1,
"No Hello layer in GetContext\n%s" % response)
self.assertFalse(
str(response).find("<Layer opacity=\"1\" queryable=\"true\" hidden=\"false\" id=\"Country\" name=\"Country\">") != -1,
"Country layer in GetContext\n%s" % response)

def test_wms_describelayer_hello(self):
query_string = "&".join(["%s=%s" % i for i in {
"MAP": urllib.quote(self.projectPath),
Expand Down

0 comments on commit eb7c98f

Please sign in to comment.