Skip to content
Permalink
Browse files

Merge pull request #5157 from pblottiere/server_bugfix_ogc_invalid_qu…

…erylayers

[server][bugfix] Fix OGC test getfeatureinfo:invalid-query_layers
  • Loading branch information
pblottiere committed Oct 2, 2017
2 parents d1018cb + c5ed92c commit 60fd7636211f5fc0414b5cf7057e25a8e97e54f2
@@ -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 )
{
@@ -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 )
@@ -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&' +
@@ -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.
You can’t perform that action at this time.