mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-26 00:02:08 -05:00
Use shapefiles for WFST data format
Spatialite is just asking for unwanted issues. (In this case it's magically decided that the layers should all be readonly.)
This commit is contained in:
parent
4aa01a06d5
commit
7ccfbe3fe9
@ -11,6 +11,7 @@ __date__ = '28/08/2015'
|
||||
__copyright__ = 'Copyright 2015, The QGIS Project'
|
||||
|
||||
import qgis # NOQA
|
||||
import shutil
|
||||
|
||||
import os
|
||||
from shutil import copyfile
|
||||
@ -146,23 +147,26 @@ class TestQgsServerAccessControl(QgsServerTestBase):
|
||||
cls._accesscontrol = RestrictedAccessControl(cls._server_iface)
|
||||
cls._server_iface.registerAccessControl(cls._accesscontrol, 100)
|
||||
|
||||
@classmethod
|
||||
def project_file(cls):
|
||||
return 'project_grp.qgs'
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.testdata_path = unitTestDataPath("qgis_server_accesscontrol")
|
||||
|
||||
data_file = os.path.join(self.testdata_path, "helloworld.db")
|
||||
self.assertTrue(os.path.isfile(data_file), 'Could not find data file "{}"'.format(data_file))
|
||||
copyfile(data_file, os.path.join(self.testdata_path, "_helloworld.db"))
|
||||
self.tmp_path = tempfile.mkdtemp()
|
||||
shutil.copytree(self.testdata_path, self.tmp_path, dirs_exist_ok=True)
|
||||
|
||||
for k in ["QUERY_STRING", "QGIS_PROJECT_FILE"]:
|
||||
if k in os.environ:
|
||||
del os.environ[k]
|
||||
|
||||
self.projectPath = os.path.join(self.testdata_path, "project_grp.qgs")
|
||||
self.projectPath = os.path.join(self.tmp_path, self.project_file())
|
||||
self.assertTrue(os.path.isfile(self.projectPath), 'Could not find project file "{}"'.format(self.projectPath))
|
||||
|
||||
def tearDown(self):
|
||||
copyfile(os.path.join(self.testdata_path, "_helloworld.db"), os.path.join(self.testdata_path, "helloworld.db"))
|
||||
shutil.rmtree(self.tmp_path, True)
|
||||
|
||||
def _handle_request(self, restricted, query_string, **kwargs):
|
||||
self._accesscontrol._active = restricted
|
||||
|
@ -25,11 +25,12 @@ WFS_TRANSACTION_INSERT = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gml:coordinates decimal="." cs="," ts=" ">{x},{y}</gml:coordinates>
|
||||
</gml:Point>
|
||||
</qgs:geometry>
|
||||
<qgs:gid>{gid}</qgs:gid>
|
||||
<qgs:name>{name}</qgs:name>
|
||||
<qgs:color>{color}</qgs:color>
|
||||
</qgs:db_point>
|
||||
</wfs:Insert>
|
||||
</wfs:Transaction>""".format(x=1000, y=2000, name="test", color="{color}", xml_ns=XML_NS)
|
||||
</wfs:Transaction>"""
|
||||
|
||||
WFS_TRANSACTION_UPDATE = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<wfs:Transaction {xml_ns}>
|
||||
@ -56,20 +57,25 @@ WFS_TRANSACTION_DELETE = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
class TestQgsServerAccessControlWFSTransactional(TestQgsServerAccessControl):
|
||||
|
||||
@classmethod
|
||||
def project_file(cls):
|
||||
return 'project_shp.qgs'
|
||||
|
||||
def test_wfstransaction_insert(self):
|
||||
data = WFS_TRANSACTION_INSERT.format(x=1000, y=2000, name="test", color="{color}", xml_ns=XML_NS)
|
||||
data = WFS_TRANSACTION_INSERT.format(x=1, y=2, name="test", color="{color}", gid="{gid}", xml_ns=XML_NS)
|
||||
self._test_colors({1: "blue"})
|
||||
|
||||
response, headers = self._post_fullaccess(data.format(color="red"))
|
||||
response, headers = self._post_fullaccess(data.format(color="red", gid=2))
|
||||
self.assertEqual(
|
||||
headers.get("Content-Type"), "text/xml; charset=utf-8",
|
||||
"Content type for Insert is wrong: %s" % headers.get("Content-Type"))
|
||||
|
||||
self.assertTrue(
|
||||
str(response).find("<SUCCESS/>") != -1,
|
||||
"WFS/Transactions Insert don't succeed\n%s" % response)
|
||||
self._test_colors({2: "red"})
|
||||
|
||||
response, headers = self._post_restricted(data.format(color="blue"))
|
||||
response, headers = self._post_restricted(data.format(color="blue", gid=3))
|
||||
self.assertEqual(
|
||||
headers.get("Content-Type"), "text/xml; charset=utf-8",
|
||||
"Content type for Insert is wrong: %s" % headers.get("Content-Type"))
|
||||
@ -77,7 +83,7 @@ class TestQgsServerAccessControlWFSTransactional(TestQgsServerAccessControl):
|
||||
str(response).find("<SUCCESS/>") == -1,
|
||||
"WFS/Transactions Insert succeed\n%s" % response)
|
||||
|
||||
response, headers = self._post_restricted(data.format(color="red"), "LAYER_PERM=no")
|
||||
response, headers = self._post_restricted(data.format(color="red", gid=4), "LAYER_PERM=no")
|
||||
self.assertEqual(
|
||||
headers.get("Content-Type"), "text/xml; charset=utf-8",
|
||||
"Content type for Insert is wrong: %s" % headers.get("Content-Type"))
|
||||
@ -86,17 +92,17 @@ class TestQgsServerAccessControlWFSTransactional(TestQgsServerAccessControl):
|
||||
'<ServiceException code="Security">No permissions to do WFS changes on layer \\\'db_point\\\'</ServiceException>') != -1,
|
||||
"WFS/Transactions Insert succeed\n%s" % response)
|
||||
|
||||
response, headers = self._post_restricted(data.format(color="yellow"), "LAYER_PERM=yes")
|
||||
response, headers = self._post_restricted(data.format(color="yellow", gid=5), "LAYER_PERM=yes")
|
||||
self.assertEqual(
|
||||
headers.get("Content-Type"), "text/xml; charset=utf-8",
|
||||
"Content type for Insert is wrong: %s" % headers.get("Content-Type"))
|
||||
self.assertTrue(
|
||||
str(response).find("<SUCCESS/>") != -1,
|
||||
"WFS/Transactions Insert don't succeed\n%s" % response)
|
||||
self._test_colors({3: "yellow"})
|
||||
self._test_colors({5: "yellow"})
|
||||
|
||||
def test_wfstransaction_update(self):
|
||||
data = WFS_TRANSACTION_UPDATE.format(id="1", color="{color}", xml_ns=XML_NS)
|
||||
data = WFS_TRANSACTION_UPDATE.format(id="0", color="{color}", xml_ns=XML_NS)
|
||||
self._test_colors({1: "blue"})
|
||||
|
||||
response, headers = self._post_restricted(data.format(color="yellow"))
|
||||
@ -146,7 +152,7 @@ class TestQgsServerAccessControlWFSTransactional(TestQgsServerAccessControl):
|
||||
self._test_colors({1: "yellow"})
|
||||
|
||||
def test_wfstransaction_delete_fullaccess(self):
|
||||
data = WFS_TRANSACTION_DELETE.format(id="1", xml_ns=XML_NS)
|
||||
data = WFS_TRANSACTION_DELETE.format(id="0", xml_ns=XML_NS)
|
||||
self._test_colors({1: "blue"})
|
||||
|
||||
response, headers = self._post_fullaccess(data)
|
||||
@ -155,10 +161,10 @@ class TestQgsServerAccessControlWFSTransactional(TestQgsServerAccessControl):
|
||||
"Content type for GetMap is wrong: %s" % headers.get("Content-Type"))
|
||||
self.assertTrue(
|
||||
str(response).find("<SUCCESS/>") != -1,
|
||||
"WFS/Transactions Delete don't succeed\n%s" % response)
|
||||
"WFS/Transactions Delete didn't succeed\n%s" % response)
|
||||
|
||||
def test_wfstransaction_delete_restricted(self):
|
||||
data = WFS_TRANSACTION_DELETE.format(id="1", xml_ns=XML_NS)
|
||||
data = WFS_TRANSACTION_DELETE.format(id="0", xml_ns=XML_NS)
|
||||
self._test_colors({1: "blue"})
|
||||
|
||||
response, headers = self._post_restricted(data)
|
||||
@ -169,7 +175,7 @@ class TestQgsServerAccessControlWFSTransactional(TestQgsServerAccessControl):
|
||||
str(response).find("<SUCCESS/>") == -1,
|
||||
"WFS/Transactions Delete succeed\n%s" % response)
|
||||
|
||||
data_update = WFS_TRANSACTION_UPDATE.format(id="1", color="red", xml_ns=XML_NS)
|
||||
data_update = WFS_TRANSACTION_UPDATE.format(id="0", color="red", xml_ns=XML_NS)
|
||||
response, headers = self._post_fullaccess(data_update)
|
||||
self._test_colors({1: "red"})
|
||||
|
||||
|
1
tests/testdata/qgis_server_accesscontrol/helloworld_country.cpg
vendored
Normal file
1
tests/testdata/qgis_server_accesscontrol/helloworld_country.cpg
vendored
Normal file
@ -0,0 +1 @@
|
||||
UTF-8
|
BIN
tests/testdata/qgis_server_accesscontrol/helloworld_country.dbf
vendored
Normal file
BIN
tests/testdata/qgis_server_accesscontrol/helloworld_country.dbf
vendored
Normal file
Binary file not shown.
1
tests/testdata/qgis_server_accesscontrol/helloworld_country.prj
vendored
Normal file
1
tests/testdata/qgis_server_accesscontrol/helloworld_country.prj
vendored
Normal file
@ -0,0 +1 @@
|
||||
PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]]
|
26
tests/testdata/qgis_server_accesscontrol/helloworld_country.qmd
vendored
Normal file
26
tests/testdata/qgis_server_accesscontrol/helloworld_country.qmd
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
|
||||
<qgis version="3.27.0-Master">
|
||||
<identifier></identifier>
|
||||
<parentidentifier></parentidentifier>
|
||||
<language></language>
|
||||
<type>dataset</type>
|
||||
<title></title>
|
||||
<abstract></abstract>
|
||||
<links/>
|
||||
<fees></fees>
|
||||
<encoding></encoding>
|
||||
<crs>
|
||||
<spatialrefsys nativeFormat="Wkt">
|
||||
<wkt></wkt>
|
||||
<proj4></proj4>
|
||||
<srsid>0</srsid>
|
||||
<srid>0</srid>
|
||||
<authid></authid>
|
||||
<description></description>
|
||||
<projectionacronym></projectionacronym>
|
||||
<ellipsoidacronym></ellipsoidacronym>
|
||||
<geographicflag>false</geographicflag>
|
||||
</spatialrefsys>
|
||||
</crs>
|
||||
<extent/>
|
||||
</qgis>
|
BIN
tests/testdata/qgis_server_accesscontrol/helloworld_country.shp
vendored
Normal file
BIN
tests/testdata/qgis_server_accesscontrol/helloworld_country.shp
vendored
Normal file
Binary file not shown.
BIN
tests/testdata/qgis_server_accesscontrol/helloworld_country.shx
vendored
Normal file
BIN
tests/testdata/qgis_server_accesscontrol/helloworld_country.shx
vendored
Normal file
Binary file not shown.
1
tests/testdata/qgis_server_accesscontrol/helloworld_hello.cpg
vendored
Normal file
1
tests/testdata/qgis_server_accesscontrol/helloworld_hello.cpg
vendored
Normal file
@ -0,0 +1 @@
|
||||
UTF-8
|
BIN
tests/testdata/qgis_server_accesscontrol/helloworld_hello.dbf
vendored
Normal file
BIN
tests/testdata/qgis_server_accesscontrol/helloworld_hello.dbf
vendored
Normal file
Binary file not shown.
1
tests/testdata/qgis_server_accesscontrol/helloworld_hello.prj
vendored
Normal file
1
tests/testdata/qgis_server_accesscontrol/helloworld_hello.prj
vendored
Normal file
@ -0,0 +1 @@
|
||||
PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]]
|
26
tests/testdata/qgis_server_accesscontrol/helloworld_hello.qmd
vendored
Normal file
26
tests/testdata/qgis_server_accesscontrol/helloworld_hello.qmd
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
|
||||
<qgis version="3.27.0-Master">
|
||||
<identifier></identifier>
|
||||
<parentidentifier></parentidentifier>
|
||||
<language></language>
|
||||
<type>dataset</type>
|
||||
<title></title>
|
||||
<abstract></abstract>
|
||||
<links/>
|
||||
<fees></fees>
|
||||
<encoding></encoding>
|
||||
<crs>
|
||||
<spatialrefsys nativeFormat="Wkt">
|
||||
<wkt></wkt>
|
||||
<proj4></proj4>
|
||||
<srsid>0</srsid>
|
||||
<srid>0</srid>
|
||||
<authid></authid>
|
||||
<description></description>
|
||||
<projectionacronym></projectionacronym>
|
||||
<ellipsoidacronym></ellipsoidacronym>
|
||||
<geographicflag>false</geographicflag>
|
||||
</spatialrefsys>
|
||||
</crs>
|
||||
<extent/>
|
||||
</qgis>
|
BIN
tests/testdata/qgis_server_accesscontrol/helloworld_hello.shp
vendored
Normal file
BIN
tests/testdata/qgis_server_accesscontrol/helloworld_hello.shp
vendored
Normal file
Binary file not shown.
BIN
tests/testdata/qgis_server_accesscontrol/helloworld_hello.shx
vendored
Normal file
BIN
tests/testdata/qgis_server_accesscontrol/helloworld_hello.shx
vendored
Normal file
Binary file not shown.
1
tests/testdata/qgis_server_accesscontrol/helloworld_points.cpg
vendored
Normal file
1
tests/testdata/qgis_server_accesscontrol/helloworld_points.cpg
vendored
Normal file
@ -0,0 +1 @@
|
||||
UTF-8
|
BIN
tests/testdata/qgis_server_accesscontrol/helloworld_points.dbf
vendored
Normal file
BIN
tests/testdata/qgis_server_accesscontrol/helloworld_points.dbf
vendored
Normal file
Binary file not shown.
1
tests/testdata/qgis_server_accesscontrol/helloworld_points.prj
vendored
Normal file
1
tests/testdata/qgis_server_accesscontrol/helloworld_points.prj
vendored
Normal file
@ -0,0 +1 @@
|
||||
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
|
26
tests/testdata/qgis_server_accesscontrol/helloworld_points.qmd
vendored
Normal file
26
tests/testdata/qgis_server_accesscontrol/helloworld_points.qmd
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
|
||||
<qgis version="3.27.0-Master">
|
||||
<identifier></identifier>
|
||||
<parentidentifier></parentidentifier>
|
||||
<language></language>
|
||||
<type>dataset</type>
|
||||
<title></title>
|
||||
<abstract></abstract>
|
||||
<links/>
|
||||
<fees></fees>
|
||||
<encoding></encoding>
|
||||
<crs>
|
||||
<spatialrefsys nativeFormat="Wkt">
|
||||
<wkt></wkt>
|
||||
<proj4></proj4>
|
||||
<srsid>0</srsid>
|
||||
<srid>0</srid>
|
||||
<authid></authid>
|
||||
<description></description>
|
||||
<projectionacronym></projectionacronym>
|
||||
<ellipsoidacronym></ellipsoidacronym>
|
||||
<geographicflag>false</geographicflag>
|
||||
</spatialrefsys>
|
||||
</crs>
|
||||
<extent/>
|
||||
</qgis>
|
BIN
tests/testdata/qgis_server_accesscontrol/helloworld_points.shp
vendored
Normal file
BIN
tests/testdata/qgis_server_accesscontrol/helloworld_points.shp
vendored
Normal file
Binary file not shown.
BIN
tests/testdata/qgis_server_accesscontrol/helloworld_points.shx
vendored
Normal file
BIN
tests/testdata/qgis_server_accesscontrol/helloworld_points.shx
vendored
Normal file
Binary file not shown.
4372
tests/testdata/qgis_server_accesscontrol/project_shp.qgs
vendored
Normal file
4372
tests/testdata/qgis_server_accesscontrol/project_shp.qgs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user