Skip to content
Permalink
Browse files

Revert "Revert "Add test for pointcloud layers fetching and related p…

…ermissions""

This reverts commit 72e012a.
  • Loading branch information
strk authored and nyalldawson committed Feb 19, 2020
1 parent c932794 commit ee931d8c711c95c88ae81525b36bdd919f79f15a
@@ -98,23 +98,31 @@ def test_postgis_connections(self):
self.assertEqual(srids_and_types,
[[0, 1], [0, 2], [0, 3], [0, 7], [3857, 1], [4326, 1]])

# Check TopoGeometry layers are found in vector table names

# Check TopoGeometry and Pointcloud layers are found in vector table names
tables = conn.tables('qgis_test', QgsAbstractDatabaseProviderConnection.Vector)
table_names = self._table_names(tables)
self.assertTrue('TopoLayer1' in table_names)
self.assertTrue('PointCloudPointLayer' in table_names)
self.assertTrue('PointCloudPatchLayer' in table_names)

self.assertTrue('geometries_table' in table_names)

# Revoke select permissions on topology.topology from qgis_test_user
conn.executeSql('REVOKE SELECT ON topology.topology FROM qgis_test_user')

# Revoke select permissions on pointcloud_format from qgis_test_user
conn.executeSql('REVOKE SELECT ON pointcloud_formats FROM qgis_test_user')

# Re-connect as the qgis_test_role role
newuri = self.uri + ' user=qgis_test_user password=qgis_test_user_password'
conn = md.createConnection(newuri, {})
newconn = md.createConnection(newuri, {})

tables = conn.tables('qgis_test', QgsAbstractDatabaseProviderConnection.Vector)
# Check TopoGeometry and Pointcloud layers are not found in vector table names
tables = newconn.tables('qgis_test', QgsAbstractDatabaseProviderConnection.Vector)
table_names = self._table_names(tables)
self.assertFalse('TopoLayer1' in table_names)
self.assertFalse('PointCloudPointLayer' in table_names)
self.assertFalse('PointCloudPatchLayer' in table_names)
self.assertTrue('geometries_table' in table_names)

# TODO: only revoke select permission on topology.layer, grant
@@ -126,6 +134,13 @@ def test_postgis_connections(self):
# TODO: only revoke select permission the actual topology
# schema associated with TopoLayer1

# TODO: only revoke select permission the pointcloud_columns
# table

# Grant select permissions back on topology.topology to qgis_test_user
conn.executeSql('GRANT SELECT ON topology.topology TO qgis_test_user')
conn.executeSql('GRANT SELECT ON pointcloud_formats TO qgis_test_user')

# error: ERROR: relation "qgis_test.raster1" does not exist
@unittest.skipIf(gdal.VersionInfo() < '2040000', 'This test requires GDAL >= 2.4.0')
def test_postgis_raster_rename(self):
@@ -5,3 +5,14 @@ ADD auth_system/certs_keys/postgres.key /etc/ssl/private/postgres_key.key
ADD auth_system/certs_keys/issuer_ca_cert.pem /etc/ssl/certs/issuer_ca_cert.pem

RUN chmod 400 /etc/ssl/private/postgres_key.key

# Compile and install PointCloud.
# NOTE: release 1.2.0 would not build against PostgreSQL-11:
# https://github.com/pgpointcloud/pointcloud/issues/248
RUN apt-get -y update; apt-get -y install build-essential autoconf postgresql-server-dev-11 libxml2-dev zlib1g-dev
RUN wget -O- \
https://github.com/pgpointcloud/pointcloud/archive/master.tar.gz \
| tar xz && \
cd pointcloud-master && \
./autogen.sh && ./configure && make && make install && \
cd .. && rm -Rf pointcloud-master
@@ -15,6 +15,7 @@ SCRIPTS="
tests/testdata/provider/testdata_pg_topology.sql
tests/testdata/provider/testdata_pg_domain.sql
tests/testdata/provider/testdata_pg_json.sql
tests/testdata/provider/testdata_pg_pointcloud.sql
"

dropdb --if-exists $DB
@@ -0,0 +1,69 @@
DO $$
DECLARE
layerid INTEGER;

BEGIN
IF EXISTS ( SELECT *
FROM pg_catalog.pg_available_extensions e1,
pg_catalog.pg_available_extensions e2
WHERE e1.name = 'pointcloud'
AND e2.name = 'pointcloud_postgis' )
THEN
RAISE NOTICE 'Loading pointcloud';
CREATE EXTENSION IF NOT EXISTS pointcloud;
CREATE EXTENSION IF NOT EXISTS pointcloud_postgis;

TRUNCATE pointcloud_formats;
INSERT INTO pointcloud_formats (pcid, srid, schema) VALUES (1, 4326, $S$
<?xml version="1.0" encoding="UTF-8"?>
<pc:PointCloudSchema xmlns:pc="http://pointcloud.org/schemas/PC/1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<pc:dimension>
<pc:position>1</pc:position>
<pc:size>4</pc:size>
<pc:name>X</pc:name>
<pc:interpretation>int32_t</pc:interpretation>
<pc:scale>0.01</pc:scale>
</pc:dimension>
<pc:dimension>
<pc:position>2</pc:position>
<pc:size>4</pc:size>
<pc:name>Y</pc:name>
<pc:interpretation>int32_t</pc:interpretation>
<pc:scale>0.01</pc:scale>
</pc:dimension>
<pc:dimension>
<pc:position>3</pc:position>
<pc:size>4</pc:size>
<pc:name>Z</pc:name>
<pc:interpretation>int32_t</pc:interpretation>
<pc:scale>0.01</pc:scale>
</pc:dimension>
<pc:metadata>
<Metadata name="compression">dimensional</Metadata>
<Metadata name="spatialreference" type="id">4326</Metadata>
</pc:metadata>
</pc:PointCloudSchema>
$S$);

-- Pointcloud layer: qgis_test.PointCloudPointLayer
CREATE TABLE IF NOT EXISTS qgis_test."PointCloudPointLayer" (
id serial primary key,
pt PCPOINT(1)
);
INSERT INTO qgis_test."PointCloudPointLayer" (pt)
SELECT PC_MakePoint(1, ARRAY[-127, 45, 124.0]);
INSERT INTO qgis_test."PointCloudPointLayer" (pt)
SELECT PC_MakePoint(1, ARRAY[127, -45, 224.0]);

-- Pointcloud layer: qgis_test.PointCloudPatchLayer
CREATE TABLE IF NOT EXISTS qgis_test."PointCloudPatchLayer" (
id serial primary key,
pc PCPATCH(1)
);
INSERT INTO qgis_test."PointCloudPatchLayer" (pc)
SELECT PC_Patch(pt) FROM qgis_test."PointCloudPointLayer";

END IF;
END;
$$;

0 comments on commit ee931d8

Please sign in to comment.
You can’t perform that action at this time.