Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #5157 from pblottiere/server_bugfix_ogc_invalid_qu…
Browse files Browse the repository at this point in the history
…erylayers

[server][bugfix] Fix OGC test getfeatureinfo:invalid-query_layers
  • Loading branch information
pblottiere committed Oct 2, 2017
2 parents d1018cb + c5ed92c commit 60fd763
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -1255,10 +1255,13 @@ namespace QgsWms

Q_FOREACH ( QString queryLayer, queryLayers )
{
bool validLayer = false;
Q_FOREACH ( QgsMapLayer *layer, layers )
{
if ( queryLayer == layerNickname( *layer ) )
{
validLayer = true;

QDomElement layerElement;
if ( infoFormat == QgsWmsParameters::Format::GML )
{
Expand Down Expand Up @@ -1316,6 +1319,12 @@ namespace QgsWms
break;
}
}

if ( !validLayer )
{
QString msg = QObject::tr( "Layer '%1' not found" ).arg( queryLayer );
throw QgsBadRequestException( QStringLiteral( "LayerNotDefined" ), msg );
}
}

if ( featuresRect )
Expand Down
9 changes: 9 additions & 0 deletions tests/src/python/test_qgsserver_wms.py
Expand Up @@ -145,6 +145,15 @@ def test_project_wms(self):
'FEATURE_COUNT=10&FILTER_GEOM=POLYGON((8.2035381 44.901459,8.2035562 44.901459,8.2035562 44.901418,8.2035381 44.901418,8.2035381 44.901459))',
'wms_getfeatureinfo_geometry_filter')

# Test feature info request with invalid query_layer
self.wms_request_compare('GetFeatureInfo',
'&layers=testlayer%20%C3%A8%C3%A9&' +
'INFO_FORMAT=text%2Fxml&' +
'width=600&height=400&srs=EPSG%3A3857&' +
'query_layers=InvalidLayer&' +
'FEATURE_COUNT=10&FILTER_GEOM=POLYGON((8.2035381 44.901459,8.2035562 44.901459,8.2035562 44.901418,8.2035381 44.901418,8.2035381 44.901459))',
'wms_getfeatureinfo_invalid_query_layers')

# Test DescribeLayer
self.wms_request_compare('DescribeLayer',
'&layers=testlayer%20%C3%A8%C3%A9&' +
Expand Down
@@ -0,0 +1,6 @@
*****
Content-Type: text/xml; charset=utf-8

<ServiceExceptionReport xmlns="http://www.opengis.net/ogc" version="1.3.0">
<ServiceException code="LayerNotDefined">Layer 'InvalidLayer' not found</ServiceException>
</ServiceExceptionReport>

0 comments on commit 60fd763

Please sign in to comment.