Skip to content

Commit 6ed8014

Browse files
committed
f
1 parent 68c4648 commit 6ed8014

File tree

3 files changed

+100
-60
lines changed

3 files changed

+100
-60
lines changed

tests/src/python/test_qgsserver_accesscontrol_wms.py

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -190,66 +190,6 @@ def test_wms_describelayer_country_grp(self):
190190
str(response).find("<se:FeatureTypeName>Country_grp</se:FeatureTypeName>") != -1,
191191
"Country_grp layer in DescribeLayer\n%s" % response)
192192

193-
def test_wms_getlegendgraphic_hello(self):
194-
query_string = "&".join(["%s=%s" % i for i in list({
195-
"MAP": urllib.parse.quote(self.projectPath),
196-
"SERVICE": "WMS",
197-
"VERSION": "1.1.1",
198-
"REQUEST": "GetLegendGraphic",
199-
"LAYERS": "Hello",
200-
"FORMAT": "image/png"
201-
}.items())])
202-
203-
response, headers = self._get_fullaccess(query_string)
204-
self._img_diff_error(response, headers, "WMS_GetLegendGraphic_Hello", 250, QSize(10, 10))
205-
206-
response, headers = self._get_restricted(query_string)
207-
self._img_diff_error(response, headers, "WMS_GetLegendGraphic_Hello", 250, QSize(10, 10))
208-
209-
def test_wms_getlegendgraphic_country(self):
210-
query_string = "&".join(["%s=%s" % i for i in list({
211-
"MAP": urllib.parse.quote(self.projectPath),
212-
"SERVICE": "WMS",
213-
"VERSION": "1.1.1",
214-
"REQUEST": "GetLegendGraphic",
215-
"LAYERS": "Country",
216-
"FORMAT": "image/png"
217-
}.items())])
218-
219-
response, headers = self._get_fullaccess(query_string)
220-
self._img_diff_error(response, headers, "WMS_GetLegendGraphic_Country", 250, QSize(10, 10))
221-
222-
response, headers = self._get_restricted(query_string)
223-
self.assertEqual(
224-
headers.get("Content-Type"), "text/xml; charset=utf-8",
225-
"Content type for GetMap is wrong: %s" % headers.get("Content-Type"))
226-
self.assertTrue(
227-
str(response).find('<ServiceException code="Security">') != -1,
228-
"Not allowed GetLegendGraphic"
229-
)
230-
231-
def test_wms_getlegendgraphic_country_grp(self):
232-
query_string = "&".join(["%s=%s" % i for i in list({
233-
"MAP": urllib.parse.quote(self.projectPath),
234-
"SERVICE": "WMS",
235-
"VERSION": "1.1.1",
236-
"REQUEST": "GetLegendGraphic",
237-
"LAYERS": "Country_grp",
238-
"FORMAT": "image/png"
239-
}.items())])
240-
241-
response, headers = self._get_fullaccess(query_string)
242-
self._img_diff_error(response, headers, "WMS_GetLegendGraphic_Country", 250, QSize(10, 10))
243-
244-
response, headers = self._get_restricted(query_string)
245-
self.assertEqual(
246-
headers.get("Content-Type"), "text/xml; charset=utf-8",
247-
"Content type for GetMap is wrong: %s" % headers.get("Content-Type"))
248-
self.assertTrue(
249-
str(response).find('<ServiceException code="Security">') != -1,
250-
"Not allowed GetLegendGraphic"
251-
)
252-
253193
def test_wms_getmap(self):
254194
query_string = "&".join(["%s=%s" % i for i in list({
255195
"MAP": urllib.parse.quote(self.projectPath),
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# -*- coding: utf-8 -*-
2+
"""QGIS Unit tests for QgsServer.
3+
4+
.. note:: This program is free software; you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License as published by
6+
the Free Software Foundation; either version 2 of the License, or
7+
(at your option) any later version.
8+
"""
9+
__author__ = 'Stephane Brunner'
10+
__date__ = '28/08/2015'
11+
__copyright__ = 'Copyright 2015, The QGIS Project'
12+
# This will get replaced with a git SHA1 when you do a git archive
13+
__revision__ = '$Format:%H$'
14+
15+
print('CTEST_FULL_OUTPUT')
16+
17+
import qgis # NOQA
18+
19+
import os
20+
from shutil import copyfile
21+
from math import sqrt
22+
from qgis.testing import unittest
23+
from utilities import unitTestDataPath
24+
from osgeo import gdal
25+
from osgeo.gdalconst import GA_ReadOnly
26+
from qgis.server import QgsServer, QgsAccessControlFilter, QgsServerRequest, QgsBufferServerRequest, QgsBufferServerResponse
27+
from qgis.core import QgsRenderChecker, QgsApplication
28+
from qgis.PyQt.QtCore import QSize
29+
import tempfile
30+
import urllib.request
31+
import urllib.parse
32+
import urllib.error
33+
import base64
34+
from test_qgsserver_accesscontrol import TestQgsServerAccessControl
35+
36+
37+
class TestQgsServerAccessControlWMSGetlegendgraphic(TestQgsServerAccessControl):
38+
39+
def test_wms_getlegendgraphic_hello(self):
40+
query_string = "&".join(["%s=%s" % i for i in list({
41+
"MAP": urllib.parse.quote(self.projectPath),
42+
"SERVICE": "WMS",
43+
"VERSION": "1.1.1",
44+
"REQUEST": "GetLegendGraphic",
45+
"LAYERS": "Hello",
46+
"FORMAT": "image/png"
47+
}.items())])
48+
49+
response, headers = self._get_fullaccess(query_string)
50+
self._img_diff_error(response, headers, "WMS_GetLegendGraphic_Hello", 250, QSize(10, 10))
51+
52+
response, headers = self._get_restricted(query_string)
53+
self._img_diff_error(response, headers, "WMS_GetLegendGraphic_Hello", 250, QSize(10, 10))
54+
55+
def test_wms_getlegendgraphic_country(self):
56+
query_string = "&".join(["%s=%s" % i for i in list({
57+
"MAP": urllib.parse.quote(self.projectPath),
58+
"SERVICE": "WMS",
59+
"VERSION": "1.1.1",
60+
"REQUEST": "GetLegendGraphic",
61+
"LAYERS": "Country",
62+
"FORMAT": "image/png"
63+
}.items())])
64+
65+
response, headers = self._get_fullaccess(query_string)
66+
self._img_diff_error(response, headers, "WMS_GetLegendGraphic_Country", 250, QSize(10, 10))
67+
68+
response, headers = self._get_restricted(query_string)
69+
self.assertEqual(
70+
headers.get("Content-Type"), "text/xml; charset=utf-8",
71+
"Content type for GetMap is wrong: %s" % headers.get("Content-Type"))
72+
self.assertTrue(
73+
str(response).find('<ServiceException code="Security">') != -1,
74+
"Not allowed GetLegendGraphic"
75+
)
76+
77+
def test_wms_getlegendgraphic_country_grp(self):
78+
query_string = "&".join(["%s=%s" % i for i in list({
79+
"MAP": urllib.parse.quote(self.projectPath),
80+
"SERVICE": "WMS",
81+
"VERSION": "1.1.1",
82+
"REQUEST": "GetLegendGraphic",
83+
"LAYERS": "Country_grp",
84+
"FORMAT": "image/png"
85+
}.items())])
86+
87+
response, headers = self._get_fullaccess(query_string)
88+
self._img_diff_error(response, headers, "WMS_GetLegendGraphic_Country", 250, QSize(10, 10))
89+
90+
response, headers = self._get_restricted(query_string)
91+
self.assertEqual(
92+
headers.get("Content-Type"), "text/xml; charset=utf-8",
93+
"Content type for GetMap is wrong: %s" % headers.get("Content-Type"))
94+
self.assertTrue(
95+
str(response).find('<ServiceException code="Security">') != -1,
96+
"Not allowed GetLegendGraphic"
97+
)
98+
99+
if __name__ == "__main__":
100+
unittest.main()

0 commit comments

Comments
 (0)