Skip to content

Commit 949241d

Browse files
authoredSep 29, 2016
Merge pull request #3540 from elpaso/auth-integration-test
Auth integration test + more reliable server tests
2 parents 67d5e19 + 49ae020 commit 949241d

12 files changed

+488
-199
lines changed
 

‎tests/src/python/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,5 @@ IF (WITH_SERVER)
150150
ADD_PYTHON_TEST(PyQgsServerAccessControl test_qgsserver_accesscontrol.py)
151151
ADD_PYTHON_TEST(PyQgsServerWFST test_qgsserver_wfst.py)
152152
ADD_PYTHON_TEST(PyQgsOfflineEditingWFS test_offline_editing_wfs.py)
153+
ADD_PYTHON_TEST(PyQgsAuthManagerEnpointTest test_authmanager_endpoint.py)
153154
ENDIF (WITH_SERVER)

‎tests/src/python/qgis_wrapped_server.py

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
This script launches a QGIS Server listening on port 8081 or on the port
66
specified on the environment variable QGIS_SERVER_DEFAULT_PORT
77
8+
For testing purposes, HTTP Basic can be enabled by setting the following
9+
environment variables:
10+
11+
* QGIS_SERVER_HTTP_BASIC_AUTH (default not set, set to anything to enable)
12+
* QGIS_SERVER_USERNAME (default ="username")
13+
* QGIS_SERVER_PASSWORD (default ="password")
14+
815
.. note:: This program is free software; you can redistribute it and/or modify
916
it under the terms of the GNU General Public License as published by
1017
the Free Software Foundation; either version 2 of the License, or
@@ -22,6 +29,8 @@
2229

2330

2431
import os
32+
import sys
33+
import signal
2534
import urllib.parse
2635
from http.server import BaseHTTPRequestHandler, HTTPServer
2736
from qgis.core import QgsApplication
@@ -36,11 +45,35 @@
3645
qgs_server = QgsServer()
3746

3847

48+
if os.environ.get('QGIS_SERVER_HTTP_BASIC_AUTH') is not None:
49+
from qgis.server import QgsServerFilter
50+
import base64
51+
52+
class HTTPBasicFilter(QgsServerFilter):
53+
54+
def responseComplete(self):
55+
request = self.serverInterface().requestHandler()
56+
if self.serverInterface().getEnv('HTTP_AUTHORIZATION'):
57+
username, password = base64.b64decode(self.serverInterface().getEnv('HTTP_AUTHORIZATION')[6:]).split(b':')
58+
if (username.decode('utf-8') == os.environ.get('QGIS_SERVER_USERNAME', 'username')
59+
and password.decode('utf-8') == os.environ.get('QGIS_SERVER_PASSWORD', 'password')):
60+
return
61+
# No auth ...
62+
request.clearHeaders()
63+
request.setHeader('Status', '401 Authorization required')
64+
request.setHeader('WWW-Authenticate', 'Basic realm="QGIS Server"')
65+
request.clearBody()
66+
request.appendBody(b'<h1>Authorization required</h1>')
67+
68+
filter = HTTPBasicFilter(qgs_server.serverInterface())
69+
qgs_server.serverInterface().registerFilter(filter)
70+
71+
3972
class Handler(BaseHTTPRequestHandler):
4073

4174
def do_GET(self):
4275
# CGI vars:
43-
for k, v in list(self.headers.items()):
76+
for k, v in self.headers.items():
4477
qgs_server.putenv('HTTP_%s' % k.replace(' ', '-').replace('-', '_').replace(' ', '-').upper(), v)
4578
qgs_server.putenv('SERVER_PORT', str(self.server.server_port))
4679
qgs_server.putenv('SERVER_NAME', self.server.server_name)
@@ -52,7 +85,7 @@ def do_GET(self):
5285
self.send_response(int(headers_dict['Status'].split(' ')[0]))
5386
except:
5487
self.send_response(200)
55-
for k, v in list(headers_dict.items()):
88+
for k, v in headers_dict.items():
5689
self.send_header(k, v)
5790
self.end_headers()
5891
self.wfile.write(body)
@@ -71,5 +104,12 @@ def do_POST(self):
71104
server = HTTPServer(('localhost', QGIS_SERVER_DEFAULT_PORT), Handler)
72105
print('Starting server on localhost:%s, use <Ctrl-C> to stop' %
73106
QGIS_SERVER_DEFAULT_PORT)
107+
108+
def signal_handler(signal, frame):
109+
global qgs_app
110+
print("\nExiting QGIS...")
111+
qgs_app.exitQgis()
112+
sys.exit(0)
113+
114+
signal.signal(signal.SIGINT, signal_handler)
74115
server.serve_forever()
75-
qgs_app.exitQgis()
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Tests for auth manager WMS/WFS using QGIS Server through HTTP Basic
4+
enabled qgis_wrapped_server.py.
5+
6+
This is an integration test for QGIS Desktop Auth Manager WFS and WMS provider
7+
and QGIS Server WFS/WMS that check if QGIS can use a stored auth manager auth
8+
configuration to access an HTTP Basic protected endpoint.
9+
10+
11+
From build dir, run: ctest -R PyQgsAuthManagerEnpointTest -V
12+
13+
.. note:: This program is free software; you can redistribute it and/or modify
14+
it under the terms of the GNU General Public License as published by
15+
the Free Software Foundation; either version 2 of the License, or
16+
(at your option) any later version.
17+
"""
18+
import os
19+
import sys
20+
import subprocess
21+
import tempfile
22+
import random
23+
import string
24+
import urllib
25+
26+
__author__ = 'Alessandro Pasotti'
27+
__date__ = '18/09/2016'
28+
__copyright__ = 'Copyright 2016, The QGIS Project'
29+
# This will get replaced with a git SHA1 when you do a git archive
30+
__revision__ = '$Format:%H$'
31+
32+
from time import sleep
33+
from urllib.parse import quote
34+
from shutil import rmtree
35+
36+
from utilities import unitTestDataPath
37+
from qgis.core import (
38+
QgsAuthManager,
39+
QgsAuthMethodConfig,
40+
QgsVectorLayer,
41+
QgsRasterLayer,
42+
)
43+
from qgis.testing import (
44+
start_app,
45+
unittest,
46+
)
47+
48+
try:
49+
QGIS_SERVER_AUTHMANAGER_DEFAULT_PORT = os.environ['QGIS_SERVER_AUTHMANAGER_DEFAULT_PORT']
50+
except:
51+
import socket
52+
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
53+
s.bind(("", 0))
54+
QGIS_SERVER_AUTHMANAGER_DEFAULT_PORT = s.getsockname()[1]
55+
s.close()
56+
57+
QGIS_AUTH_DB_DIR_PATH = tempfile.mkdtemp()
58+
59+
os.environ['QGIS_AUTH_DB_DIR_PATH'] = QGIS_AUTH_DB_DIR_PATH
60+
61+
qgis_app = start_app()
62+
63+
64+
class TestAuthManager(unittest.TestCase):
65+
66+
@classmethod
67+
def setUpClass(cls):
68+
"""Run before all tests:
69+
Creates an auth configuration"""
70+
cls.port = QGIS_SERVER_AUTHMANAGER_DEFAULT_PORT
71+
# Clean env just to be sure
72+
env_vars = ['QUERY_STRING', 'QGIS_PROJECT_FILE']
73+
for ev in env_vars:
74+
try:
75+
del os.environ[ev]
76+
except KeyError:
77+
pass
78+
cls.testdata_path = unitTestDataPath('qgis_server') + '/'
79+
cls.project_path = quote(cls.testdata_path + "test_project.qgs")
80+
# Enable auth
81+
#os.environ['QGIS_AUTH_PASSWORD_FILE'] = QGIS_AUTH_PASSWORD_FILE
82+
authm = QgsAuthManager.instance()
83+
assert (authm.setMasterPassword('masterpassword', True))
84+
cls.auth_config = QgsAuthMethodConfig('Basic')
85+
cls.auth_config.setName('test_auth_config')
86+
cls.username = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(6))
87+
cls.password = cls.username[::-1] # reversed
88+
cls.auth_config.setConfig('username', cls.username)
89+
cls.auth_config.setConfig('password', cls.password)
90+
assert (authm.storeAuthenticationConfig(cls.auth_config)[0])
91+
92+
os.environ['QGIS_SERVER_HTTP_BASIC_AUTH'] = '1'
93+
os.environ['QGIS_SERVER_USERNAME'] = cls.username
94+
os.environ['QGIS_SERVER_PASSWORD'] = cls.password
95+
os.environ['QGIS_SERVER_DEFAULT_PORT'] = str(cls.port)
96+
server_path = os.path.dirname(os.path.realpath(__file__)) + \
97+
'/qgis_wrapped_server.py'
98+
cls.server = subprocess.Popen([sys.executable, server_path],
99+
env=os.environ)
100+
sleep(2)
101+
102+
@classmethod
103+
def tearDownClass(cls):
104+
"""Run after all tests"""
105+
cls.server.terminate()
106+
rmtree(QGIS_AUTH_DB_DIR_PATH)
107+
del cls.server
108+
109+
def setUp(self):
110+
"""Run before each test."""
111+
pass
112+
113+
def tearDown(self):
114+
"""Run after each test."""
115+
pass
116+
117+
@classmethod
118+
def _getWFSLayer(cls, type_name, layer_name=None, authcfg=None):
119+
"""
120+
WFS layer factory
121+
"""
122+
if layer_name is None:
123+
layer_name = 'wfs_' + type_name
124+
parms = {
125+
'srsname': 'EPSG:4326',
126+
'typename': type_name,
127+
'url': 'http://127.0.0.1:%s/?map=%s' % (cls.port, cls.project_path),
128+
'version': 'auto',
129+
'table': '',
130+
}
131+
if authcfg is not None:
132+
parms.update({'authcfg': authcfg})
133+
uri = ' '.join([("%s='%s'" % (k, v)) for k, v in list(parms.items())])
134+
wfs_layer = QgsVectorLayer(uri, layer_name, 'WFS')
135+
return wfs_layer
136+
137+
@classmethod
138+
def _getWMSLayer(cls, layers, layer_name=None, authcfg=None):
139+
"""
140+
WMS layer factory
141+
"""
142+
if layer_name is None:
143+
layer_name = 'wms_' + layers.replace(',', '')
144+
parms = {
145+
'crs': 'EPSG:4326',
146+
'url': 'http://127.0.0.1:%s/?map=%s' % (cls.port, cls.project_path),
147+
'format': 'image/png',
148+
# This is needed because of a really wierd implementation in QGIS Server, that
149+
# replaces _ in the the real layer name with spaces
150+
'layers': urllib.parse.quote(layers).replace('_', ' '),
151+
'styles': '',
152+
#'sql': '',
153+
}
154+
if authcfg is not None:
155+
parms.update({'authcfg': authcfg})
156+
uri = '&'.join([("%s=%s" % (k, v.replace('=', '%3D'))) for k, v in list(parms.items())])
157+
wms_layer = QgsRasterLayer(uri, layer_name, 'wms')
158+
return wms_layer
159+
160+
def testValidAuthAccess(self):
161+
"""
162+
Access the HTTP Basic protected layer with valid credentials
163+
"""
164+
wfs_layer = self._getWFSLayer('testlayer_èé', authcfg=self.auth_config.id())
165+
self.assertTrue(wfs_layer.isValid())
166+
wms_layer = self._getWMSLayer('testlayer_èé', authcfg=self.auth_config.id())
167+
self.assertTrue(wms_layer.isValid())
168+
169+
def testInvalidAuthAccess(self):
170+
"""
171+
Access the HTTP Basic protected layer with no credentials
172+
"""
173+
wfs_layer = self._getWFSLayer('testlayer_èé')
174+
self.assertFalse(wfs_layer.isValid())
175+
wms_layer = self._getWMSLayer('testlayer_èé')
176+
self.assertFalse(wms_layer.isValid())
177+
178+
179+
if __name__ == '__main__':
180+
unittest.main()

‎tests/src/python/test_offline_editing_wfs.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,15 @@
4545

4646
from offlineditingtestbase import OfflineTestBase
4747

48+
4849
try:
4950
QGIS_SERVER_WFST_DEFAULT_PORT = os.environ['QGIS_SERVER_WFST_DEFAULT_PORT']
5051
except:
51-
QGIS_SERVER_WFST_DEFAULT_PORT = 8081
52+
import socket
53+
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
54+
s.bind(("", 0))
55+
QGIS_SERVER_WFST_DEFAULT_PORT = s.getsockname()[1]
56+
s.close()
5257

5358
qgis_app = start_app()
5459

‎tests/src/python/test_qgsserver.py

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,37 @@
3030
# Also strip all multi-attribute tags (Qt5 attr order is random)
3131
# FIXME: this is a temporary workaround to make the test pass, a more
3232
# robust implementation must check for attributes too
33-
RE_STRIP_UNCHECKABLE = b'<LatLongBoundingBox [^>]*>|<sld:UserDefinedSymbolization [^>]*>|<Attribute [^>]*>|<Layer [^>]*>|MAP=[^"]+|Content-Length: \d+|<OnlineResource[^>]*>|<BoundingBox[^>]*>|<WMS_Capabilities[^>]*>|<WFS_Capabilities[^>]*>|<element[^>]*>|<schema [^>]*>|<import [^>]*>|<gml:coordinates [^>]*>'
33+
#RE_STRIP_UNCHECKABLE = b'<LatLongBoundingBox [^>]*>|<sld:UserDefinedSymbolization [^>]*>|<Attribute [^>]*>|<Layer [^>]*>|MAP=[^"]+|Content-Length: \d+|<OnlineResource[^>]*>|<BoundingBox[^>]*>|<WMS_Capabilities[^>]*>|<WFS_Capabilities[^>]*>|<element[^>]*>|<schema [^>]*>|<import [^>]*>|<gml:coordinates [^>]*>'
34+
RE_STRIP_UNCHECKABLE = b'MAP=[^"]+|Content-Length: \d+'
35+
RE_ATTRIBUTES = b'[^>\s]+=[^>\s]+'
3436

3537

3638
class TestQgsServer(unittest.TestCase):
3739

40+
def assertXMLEqual(self, response, expected, msg=''):
41+
"""Compare XML line by line and sorted attributes"""
42+
response_lines = response.splitlines()
43+
expected_lines = expected.splitlines()
44+
line_no = 1
45+
for expected_line in expected_lines:
46+
expected_line = expected_line.strip()
47+
response_line = response_lines[line_no - 1].strip()
48+
# Compare tag
49+
try:
50+
self.assertEqual(re.findall(b'<([^>\s]+)[ >]', expected_line)[0],
51+
re.findall(b'<([^>\s]+)[ >]', response_line)[0], msg=msg + "\nTag mismatch on line %s: %s != %s" % (line_no, expected_line, response_line))
52+
except IndexError:
53+
self.assertEqual(expected_line, response_line, msg=msg + "\nTag line mismatch %s: %s != %s" % (line_no, expected_line, response_line))
54+
#print("---->%s\t%s == %s" % (line_no, expected_line, response_line))
55+
# Compare attributes
56+
if re.match(RE_ATTRIBUTES, expected_line): # has attrs
57+
expected_attrs = re.findall(RE_ATTRIBUTES, expected_line)
58+
expected_attrs.sort()
59+
response_attrs = re.findall(RE_ATTRIBUTES, response_line)
60+
response_attrs.sort()
61+
self.assertEqual(expected_attrs, response_attrs, msg=msg + "\nXML attributes differ at line {0}: {1} != {2}".format(line_no, expected_attrs, response_attrs))
62+
line_no += 1
63+
3864
@classmethod
3965
def setUpClass(cls):
4066
cls.app = QgsApplication([], False)
@@ -170,7 +196,7 @@ def responseComplete(self):
170196

171197
# WMS tests
172198
def wms_request_compare(self, request, extra=None, reference_file=None):
173-
project = self.testdata_path + "test+project.qgs"
199+
project = self.testdata_path + "test_project.qgs"
174200
assert os.path.exists(project), "Project file not found: " + project
175201

176202
query_string = 'MAP=%s&SERVICE=WMS&VERSION=1.3&REQUEST=%s' % (urllib.parse.quote(project), request)
@@ -202,7 +228,7 @@ def wms_request_compare(self, request, extra=None, reference_file=None):
202228
if int(osgeo.gdal.VersionInfo()[:1]) < 2:
203229
expected = expected.replace(b'typeName="Integer64" precision="0" length="10" editType="TextEdit" type="qlonglong"', b'typeName="Integer" precision="0" length="10" editType="TextEdit" type="int"')
204230

205-
self.assertEqual(response, expected, msg="request %s failed.\n Query: %s\n Expected:\n%s\n\n Response:\n%s" % (query_string, request, expected.decode('utf-8'), response.decode('utf-8')))
231+
self.assertXMLEqual(response, expected, msg="request %s failed.\n Query: %s\n Expected:\n%s\n\n Response:\n%s" % (query_string, request, expected.decode('utf-8'), response.decode('utf-8')))
206232

207233
def test_project_wms(self):
208234
"""Test some WMS request"""
@@ -239,7 +265,7 @@ def test_project_wms(self):
239265

240266
def wms_inspire_request_compare(self, request):
241267
"""WMS INSPIRE tests"""
242-
project = self.testdata_path + "test+project_inspire.qgs"
268+
project = self.testdata_path + "test_project_inspire.qgs"
243269
assert os.path.exists(project), "Project file not found: " + project
244270

245271
query_string = 'MAP=%s&SERVICE=WMS&VERSION=1.3.0&REQUEST=%s' % (urllib.parse.quote(project), request)
@@ -259,7 +285,7 @@ def wms_inspire_request_compare(self, request):
259285
"""
260286
response = re.sub(RE_STRIP_UNCHECKABLE, b'', response)
261287
expected = re.sub(RE_STRIP_UNCHECKABLE, b'', expected)
262-
self.assertEqual(response, expected, msg="request %s failed.\n Query: %s\n Expected:\n%s\n\n Response:\n%s" % (query_string, request, expected.decode('utf-8'), response.decode('utf-8')))
288+
self.assertXMLEqual(response, expected, msg="request %s failed.\n Query: %s\n Expected:\n%s\n\n Response:\n%s" % (query_string, request, expected.decode('utf-8'), response.decode('utf-8')))
263289

264290
def test_project_wms_inspire(self):
265291
"""Test some WMS request"""
@@ -268,7 +294,7 @@ def test_project_wms_inspire(self):
268294

269295
# WFS tests
270296
def wfs_request_compare(self, request):
271-
project = self.testdata_path + "test+project_wfs.qgs"
297+
project = self.testdata_path + "test_project_wfs.qgs"
272298
assert os.path.exists(project), "Project file not found: " + project
273299

274300
query_string = 'MAP=%s&SERVICE=WFS&VERSION=1.0.0&REQUEST=%s' % (urllib.parse.quote(project), request)
@@ -294,15 +320,15 @@ def wfs_request_compare(self, request):
294320
if int(osgeo.gdal.VersionInfo()[:1]) < 2:
295321
expected = expected.replace(b'<element type="long" name="id"/>', b'<element type="integer" name="id"/>')
296322

297-
self.assertEqual(response, expected, msg="request %s failed.\n Query: %s\n Expected:\n%s\n\n Response:\n%s" % (query_string, request, expected.decode('utf-8'), response.decode('utf-8')))
323+
self.assertXMLEqual(response, expected, msg="request %s failed.\n Query: %s\n Expected:\n%s\n\n Response:\n%s" % (query_string, request, expected.decode('utf-8'), response.decode('utf-8')))
298324

299325
def test_project_wfs(self):
300326
"""Test some WFS request"""
301327
for request in ('GetCapabilities', 'DescribeFeatureType'):
302328
self.wfs_request_compare(request)
303329

304330
def wfs_getfeature_compare(self, requestid, request):
305-
project = self.testdata_path + "test+project_wfs.qgs"
331+
project = self.testdata_path + "test_project_wfs.qgs"
306332
assert os.path.exists(project), "Project file not found: " + project
307333

308334
query_string = 'MAP=%s&SERVICE=WFS&VERSION=1.0.0&REQUEST=%s' % (urllib.parse.quote(project), request)
@@ -333,8 +359,8 @@ def result_compare(self, file_name, error_msg_header, header, body):
333359
"""
334360
response = re.sub(RE_STRIP_UNCHECKABLE, b'', response)
335361
expected = re.sub(RE_STRIP_UNCHECKABLE, b'', expected)
336-
self.assertEqual(response, expected, msg="%s\n Expected:\n%s\n\n Response:\n%s"
337-
% (error_msg_header,
362+
self.assertXMLEqual(response, expected, msg="%s\n Expected:\n%s\n\n Response:\n%s"
363+
% (error_msg_header,
338364
str(expected, errors='replace'),
339365
str(response, errors='replace')))
340366

@@ -349,7 +375,7 @@ def test_getfeature(self):
349375
self.wfs_getfeature_compare(id, req)
350376

351377
def wfs_getfeature_post_compare(self, requestid, request):
352-
project = self.testdata_path + "test+project_wfs.qgs"
378+
project = self.testdata_path + "test_project_wfs.qgs"
353379
assert os.path.exists(project), "Project file not found: " + project
354380

355381
query_string = 'MAP={}'.format(urllib.parse.quote(project))
@@ -365,7 +391,6 @@ def wfs_getfeature_post_compare(self, requestid, request):
365391
header, body,
366392
)
367393

368-
@unittest.skip
369394
def test_getfeature_post(self):
370395
template = """<?xml version="1.0" encoding="UTF-8"?>
371396
<wfs:GetFeature service="WFS" version="1.0.0" {} xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
@@ -392,20 +417,20 @@ def test_getfeature_post(self):
392417
for id, req in tests:
393418
self.wfs_getfeature_post_compare(id, req)
394419

395-
@unittest.skip
396420
def test_getLegendGraphics(self):
397421
"""Test that does not return an exception but an image"""
398422
parms = {
399-
'MAP': self.testdata_path + "test%2Bproject.qgs",
423+
'MAP': self.testdata_path + "test_project.qgs",
400424
'SERVICE': 'WMS',
401-
'VERSION': '1.0.0',
425+
'VERSION': '1.3.0',
402426
'REQUEST': 'GetLegendGraphic',
403427
'FORMAT': 'image/png',
404428
#'WIDTH': '20', # optional
405429
#'HEIGHT': '20', # optional
406-
'LAYER': 'testlayer+èé',
430+
'LAYER': 'testlayer%20èé',
407431
}
408432
qs = '&'.join(["%s=%s" % (k, v) for k, v in parms.items()])
433+
print(qs)
409434
h, r = self.server.handleRequest(qs)
410435
self.assertEqual(-1, h.find(b'Content-Type: text/xml; charset=utf-8'), "Header: %s\nResponse:\n%s" % (h, r))
411436
self.assertNotEqual(-1, h.find(b'Content-Type: image/png'), "Header: %s\nResponse:\n%s" % (h, r))

‎tests/src/python/test_qgsserver_wfst.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
# -*- coding: utf-8 -*-
23
"""
34
Tests for WFS-T provider using QGIS Server through qgis_wrapped_server.py.
@@ -58,7 +59,11 @@
5859
try:
5960
QGIS_SERVER_WFST_DEFAULT_PORT = os.environ['QGIS_SERVER_WFST_DEFAULT_PORT']
6061
except:
61-
QGIS_SERVER_WFST_DEFAULT_PORT = 8081
62+
import socket
63+
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
64+
s.bind(("", 0))
65+
QGIS_SERVER_WFST_DEFAULT_PORT = s.getsockname()[1]
66+
s.close()
6267

6368

6469
qgis_app = start_app()

‎tests/testdata/qgis_server/getcapabilities.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Content-Length: 5590
22
Content-Type: text/xml; charset=utf-8
33

44
<?xml version="1.0" encoding="utf-8"?>
5-
<WMS_Capabilities xmlns:sld="http://www.opengis.net/sld" version="1.3" xmlns="http://www.opengis.net/wms" xmlns:qgs="http://www.qgis.org/wms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wms http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd http://www.qgis.org/wms http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test%2Bproject.qgsSERVICE=WMS&amp;REQUEST=GetSchemaExtension">
5+
<WMS_Capabilities xmlns:sld="http://www.opengis.net/sld" version="1.3" xmlns="http://www.opengis.net/wms" xmlns:qgs="http://www.qgis.org/wms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wms http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd http://www.qgis.org/wms http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test-project.qgsSERVICE=WMS&amp;REQUEST=GetSchemaExtension">
66
<Service>
77
<Name>WMS</Name>
88
<Title>QGIS TestProject</Title>
@@ -30,7 +30,7 @@ Content-Type: text/xml; charset=utf-8
3030
<DCPType>
3131
<HTTP>
3232
<Get>
33-
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test%2Bproject.qgs"/>
33+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test-project.qgs"/>
3434
</Get>
3535
</HTTP>
3636
</DCPType>
@@ -45,7 +45,7 @@ Content-Type: text/xml; charset=utf-8
4545
<DCPType>
4646
<HTTP>
4747
<Get>
48-
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test%2Bproject.qgs"/>
48+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test-project.qgs"/>
4949
</Get>
5050
</HTTP>
5151
</DCPType>
@@ -59,7 +59,7 @@ Content-Type: text/xml; charset=utf-8
5959
<DCPType>
6060
<HTTP>
6161
<Get>
62-
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test%2Bproject.qgs"/>
62+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test-project.qgs"/>
6363
</Get>
6464
</HTTP>
6565
</DCPType>
@@ -70,7 +70,7 @@ Content-Type: text/xml; charset=utf-8
7070
<DCPType>
7171
<HTTP>
7272
<Get>
73-
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test%2Bproject.qgs"/>
73+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test-project.qgs"/>
7474
</Get>
7575
</HTTP>
7676
</DCPType>
@@ -80,7 +80,7 @@ Content-Type: text/xml; charset=utf-8
8080
<DCPType>
8181
<HTTP>
8282
<Get>
83-
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test%2Bproject.qgs"/>
83+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test-project.qgs"/>
8484
</Get>
8585
</HTTP>
8686
</DCPType>
@@ -90,7 +90,7 @@ Content-Type: text/xml; charset=utf-8
9090
<DCPType>
9191
<HTTP>
9292
<Get>
93-
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test%2Bproject.qgs"/>
93+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test-project.qgs"/>
9494
</Get>
9595
</HTTP>
9696
</DCPType>
@@ -131,7 +131,7 @@ Content-Type: text/xml; charset=utf-8
131131
<Title>default</Title>
132132
<LegendURL>
133133
<Format>image/png</Format>
134-
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test%2Bproject.qgs&amp;SERVICE=WMS&amp;VERSION=1.3&amp;REQUEST=GetLegendGraphic&amp;LAYER=testlayer èé&amp;FORMAT=image/png&amp;STYLE=default"/>
134+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test-project.qgs&amp;SERVICE=WMS&amp;VERSION=1.3&amp;REQUEST=GetLegendGraphic&amp;LAYER=testlayer èé&amp;FORMAT=image/png&amp;STYLE=default"/>
135135
</LegendURL>
136136
</Style>
137137
</Layer>

‎tests/testdata/qgis_server/getcapabilities_inspire.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Content-Length: 7368
22
Content-Type: text/xml; charset=utf-8
33

44
<?xml version="1.0" encoding="utf-8"?>
5-
<WMS_Capabilities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:inspire_vs="http://inspire.ec.europa.eu/schemas/inspire_vs/1.0" xmlns:inspire_common="http://inspire.ec.europa.eu/schemas/common/1.0" version="1.3.0" xmlns="http://www.opengis.net/wms" xsi:schemaLocation="http://www.opengis.net/wms http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd http://www.qgis.org/wms http://inspire.ec.europa.eu/schemas/inspire_vs/1.0 http://inspire.ec.europa.eu/schemas/inspire_vs/1.0/inspire_vs.xsd http:?MAP=/home/dhont/3liz_dev/QGIS/qgis_rldhont/tests/testdata/qgis_server/test%2Bproject_inspire.qgs&amp;SERVICE=WMS&amp;REQUEST=GetSchemaExtension" xmlns:sld="http://www.opengis.net/sld" xmlns:qgs="http://www.qgis.org/wms">
5+
<WMS_Capabilities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:inspire_vs="http://inspire.ec.europa.eu/schemas/inspire_vs/1.0" xmlns:inspire_common="http://inspire.ec.europa.eu/schemas/common/1.0" version="1.3.0" xmlns="http://www.opengis.net/wms" xsi:schemaLocation="http://www.opengis.net/wms http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd http://www.qgis.org/wms http://inspire.ec.europa.eu/schemas/inspire_vs/1.0 http://inspire.ec.europa.eu/schemas/inspire_vs/1.0/inspire_vs.xsd http:?MAP=/home/dhont/3liz_dev/QGIS/qgis_rldhont/tests/testdata/qgis_server/test-project_inspire.qgs&amp;SERVICE=WMS&amp;REQUEST=GetSchemaExtension" xmlns:sld="http://www.opengis.net/sld" xmlns:qgs="http://www.qgis.org/wms">
66
<Service>
77
<Name>WMS</Name>
88
<Title>QGIS TestProject</Title>
@@ -30,7 +30,7 @@ Content-Type: text/xml; charset=utf-8
3030
<DCPType>
3131
<HTTP>
3232
<Get>
33-
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/dhont/3liz_dev/QGIS/qgis_rldhont/tests/testdata/qgis_server/test%2Bproject_inspire.qgs&amp;"/>
33+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/dhont/3liz_dev/QGIS/qgis_rldhont/tests/testdata/qgis_server/test-project_inspire.qgs&amp;"/>
3434
</Get>
3535
</HTTP>
3636
</DCPType>
@@ -45,7 +45,7 @@ Content-Type: text/xml; charset=utf-8
4545
<DCPType>
4646
<HTTP>
4747
<Get>
48-
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/dhont/3liz_dev/QGIS/qgis_rldhont/tests/testdata/qgis_server/test%2Bproject_inspire.qgs&amp;"/>
48+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/dhont/3liz_dev/QGIS/qgis_rldhont/tests/testdata/qgis_server/test-project_inspire.qgs&amp;"/>
4949
</Get>
5050
</HTTP>
5151
</DCPType>
@@ -59,7 +59,7 @@ Content-Type: text/xml; charset=utf-8
5959
<DCPType>
6060
<HTTP>
6161
<Get>
62-
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/dhont/3liz_dev/QGIS/qgis_rldhont/tests/testdata/qgis_server/test%2Bproject_inspire.qgs&amp;"/>
62+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/dhont/3liz_dev/QGIS/qgis_rldhont/tests/testdata/qgis_server/test-project_inspire.qgs&amp;"/>
6363
</Get>
6464
</HTTP>
6565
</DCPType>
@@ -70,7 +70,7 @@ Content-Type: text/xml; charset=utf-8
7070
<DCPType>
7171
<HTTP>
7272
<Get>
73-
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/dhont/3liz_dev/QGIS/qgis_rldhont/tests/testdata/qgis_server/test%2Bproject_inspire.qgs&amp;"/>
73+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/dhont/3liz_dev/QGIS/qgis_rldhont/tests/testdata/qgis_server/test-project_inspire.qgs&amp;"/>
7474
</Get>
7575
</HTTP>
7676
</DCPType>
@@ -80,7 +80,7 @@ Content-Type: text/xml; charset=utf-8
8080
<DCPType>
8181
<HTTP>
8282
<Get>
83-
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/dhont/3liz_dev/QGIS/qgis_rldhont/tests/testdata/qgis_server/test%2Bproject_inspire.qgs&amp;"/>
83+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/dhont/3liz_dev/QGIS/qgis_rldhont/tests/testdata/qgis_server/test-project_inspire.qgs&amp;"/>
8484
</Get>
8585
</HTTP>
8686
</DCPType>
@@ -90,7 +90,7 @@ Content-Type: text/xml; charset=utf-8
9090
<DCPType>
9191
<HTTP>
9292
<Get>
93-
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/dhont/3liz_dev/QGIS/qgis_rldhont/tests/testdata/qgis_server/test%2Bproject_inspire.qgs&amp;"/>
93+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/dhont/3liz_dev/QGIS/qgis_rldhont/tests/testdata/qgis_server/test-project_inspire.qgs&amp;"/>
9494
</Get>
9595
</HTTP>
9696
</DCPType>
@@ -152,7 +152,7 @@ Content-Type: text/xml; charset=utf-8
152152
<Title>default</Title>
153153
<LegendURL>
154154
<Format>image/png</Format>
155-
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/dhont/3liz_dev/QGIS/qgis_rldhont/tests/testdata/qgis_server/test%2Bproject_inspire.qgs&amp;&amp;SERVICE=WMS&amp;VERSION=1.3.0&amp;REQUEST=GetLegendGraphic&amp;LAYER=testlayer èé&amp;FORMAT=image/png&amp;STYLE=default&amp;SLD_VERSION=1.1.0"/>
155+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/dhont/3liz_dev/QGIS/qgis_rldhont/tests/testdata/qgis_server/test-project_inspire.qgs&amp;&amp;SERVICE=WMS&amp;VERSION=1.3.0&amp;REQUEST=GetLegendGraphic&amp;LAYER=testlayer èé&amp;FORMAT=image/png&amp;STYLE=default&amp;SLD_VERSION=1.1.0"/>
156156
</LegendURL>
157157
</Style>
158158
</Layer>

‎tests/testdata/qgis_server/getprojectsettings.txt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Content-Length: 6685
22
Content-Type: text/xml; charset=utf-8
33

44
<?xml version="1.0" encoding="utf-8"?>
5-
<WMS_Capabilities xmlns:sld="http://www.opengis.net/sld" version="1.3.0" xmlns="http://www.opengis.net/wms" xmlns:qgs="http://www.qgis.org/wms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wms http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd http://www.qgis.org/wms http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test%2Bproject.qgsSERVICE=WMS&amp;REQUEST=GetSchemaExtension">
5+
<WMS_Capabilities xmlns:sld="http://www.opengis.net/sld" version="1.3.0" xmlns="http://www.opengis.net/wms" xmlns:qgs="http://www.qgis.org/wms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wms http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/sld_capabilities.xsd http://www.qgis.org/wms http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test-project.qgsSERVICE=WMS&amp;REQUEST=GetSchemaExtension">
66
<Service>
77
<Name>WMS</Name>
88
<Title>QGIS TestProject</Title>
@@ -30,7 +30,7 @@ Content-Type: text/xml; charset=utf-8
3030
<DCPType>
3131
<HTTP>
3232
<Get>
33-
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test%2Bproject.qgs"/>
33+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test-project.qgs"/>
3434
</Get>
3535
</HTTP>
3636
</DCPType>
@@ -45,7 +45,7 @@ Content-Type: text/xml; charset=utf-8
4545
<DCPType>
4646
<HTTP>
4747
<Get>
48-
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test%2Bproject.qgs"/>
48+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test-project.qgs"/>
4949
</Get>
5050
</HTTP>
5151
</DCPType>
@@ -59,7 +59,7 @@ Content-Type: text/xml; charset=utf-8
5959
<DCPType>
6060
<HTTP>
6161
<Get>
62-
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test%2Bproject.qgs"/>
62+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test-project.qgs"/>
6363
</Get>
6464
</HTTP>
6565
</DCPType>
@@ -70,7 +70,7 @@ Content-Type: text/xml; charset=utf-8
7070
<DCPType>
7171
<HTTP>
7272
<Get>
73-
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test%2Bproject.qgs"/>
73+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test-project.qgs"/>
7474
</Get>
7575
</HTTP>
7676
</DCPType>
@@ -80,7 +80,7 @@ Content-Type: text/xml; charset=utf-8
8080
<DCPType>
8181
<HTTP>
8282
<Get>
83-
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test%2Bproject.qgs"/>
83+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test-project.qgs"/>
8484
</Get>
8585
</HTTP>
8686
</DCPType>
@@ -90,7 +90,7 @@ Content-Type: text/xml; charset=utf-8
9090
<DCPType>
9191
<HTTP>
9292
<Get>
93-
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test%2Bproject.qgs"/>
93+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test-project.qgs"/>
9494
</Get>
9595
</HTTP>
9696
</DCPType>
@@ -102,7 +102,7 @@ Content-Type: text/xml; charset=utf-8
102102
<DCPType>
103103
<HTTP>
104104
<Get>
105-
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test%2Bproject.qgs"/>
105+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test-project.qgs"/>
106106
</Get>
107107
</HTTP>
108108
</DCPType>
@@ -112,6 +112,9 @@ Content-Type: text/xml; charset=utf-8
112112
<Format>text/xml</Format>
113113
</Exception>
114114
<sld:UserDefinedSymbolization UserStyle="1" RemoteWFS="0" SupportSLD="1" UserLayer="0" RemoteWCS="0" InlineFeature="0"/>
115+
<WFSLayers>
116+
<WFSLayer name="testlayer èé"/>
117+
</WFSLayers>
115118
<Layer queryable="1">
116119
<Name>QGIS Test Project</Name>
117120
<Title>QGIS Test Project</Title>
@@ -145,7 +148,7 @@ Content-Type: text/xml; charset=utf-8
145148
<Title>default</Title>
146149
<LegendURL>
147150
<Format>image/png</Format>
148-
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test%2Bproject.qgs&amp;SERVICE=WMS&amp;VERSION=1.3.0&amp;REQUEST=GetLegendGraphic&amp;LAYER=testlayer èé&amp;FORMAT=image/png&amp;STYLE=default&amp;SLD_VERSION=1.1.0"/>
151+
<OnlineResource xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http:?MAP=/home/ale/dev/QGIS/tests/testdata/qgis_server/test-project.qgs&amp;SERVICE=WMS&amp;VERSION=1.3.0&amp;REQUEST=GetLegendGraphic&amp;LAYER=testlayer èé&amp;FORMAT=image/png&amp;STYLE=default&amp;SLD_VERSION=1.1.0"/>
149152
</LegendURL>
150153
</Style>
151154
<TreeName>testlayer èé</TreeName>

‎tests/testdata/qgis_server/test+project.qgs renamed to ‎tests/testdata/qgis_server/test_project.qgs

Lines changed: 183 additions & 153 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.