diff schema/auth_tests.sql @ 3024:5470aa3ffb9a

Fix privileges for GeoServer views
author Tom Gottfried <tom@intevation.de>
date Fri, 12 Apr 2019 11:41:24 +0200
parents 4374d942b23d
children ec6163c6687d
line wrap: on
line diff
--- a/schema/auth_tests.sql	Fri Apr 12 11:34:47 2019 +0200
+++ b/schema/auth_tests.sql	Fri Apr 12 11:41:24 2019 +0200
@@ -15,6 +15,28 @@
 -- pgTAP test script for privileges and RLS policies
 --
 
+CREATE FUNCTION test_privs() RETURNS SETOF TEXT AS
+$$
+DECLARE the_schema CONSTANT varchar = 'waterway';
+DECLARE the_table varchar;
+BEGIN
+    FOR the_table IN
+        SELECT table_name
+            FROM information_schema.tables
+            WHERE table_schema = the_schema
+    LOOP
+        RETURN NEXT table_privs_are(
+            the_schema,
+            the_table,
+            'waterway_user',
+            ARRAY['SELECT'],
+            format('waterway_user can SELECT from %I.%I',
+                the_schema, the_table));
+    END LOOP;
+END;
+$$ LANGUAGE plpgsql;
+SELECT * FROM test_privs();
+
 --
 -- Run tests as unprivileged user
 --