summaryrefslogtreecommitdiff
path: root/src/test/modules/dummy_seclabel/sql
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-07-17 18:42:31 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2016-07-17 18:42:43 -0400
commit18555b1323bd225c7882e80723c52f25ce60afed (patch)
tree6913712a47c4bd2de14b86b2366c6eb728a109c0 /src/test/modules/dummy_seclabel/sql
parent7482fc4600ee97f8b2570e87b8c216a83b918065 (diff)
Establish conventions about global object names used in regression tests.
To ensure that "make installcheck" can be used safely against an existing installation, we need to be careful about what global object names (database, role, and tablespace names) we use; otherwise we might accidentally clobber important objects. There's been a weak consensus that test databases should have names including "regression", and that test role names should start with "regress_", but we didn't have any particular rule about tablespace names; and neither of the other rules was followed with any consistency either. This commit moves us a long way towards having a hard-and-fast rule that regression test databases must have names including "regression", and that test role and tablespace names must start with "regress_". It's not completely there because I did not touch some test cases in rolenames.sql that test creation of special role names like "session_user". That will require some rethinking of exactly what we want to test, whereas the intent of this patch is just to hit all the cases in which the needed renamings are cosmetic. There is no enforcement mechanism in this patch either, but if we don't add one we can expect that the tests will soon be violating the convention again. Again, that's not such a cosmetic change and it will require discussion. (But I did use a quick-hack enforcement patch to find these cases.) Discussion: <16638.1468620817@sss.pgh.pa.us>
Diffstat (limited to 'src/test/modules/dummy_seclabel/sql')
-rw-r--r--src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql47
1 files changed, 25 insertions, 22 deletions
diff --git a/src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql b/src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql
index f1135b6da5f..854906f3ed9 100644
--- a/src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql
+++ b/src/test/modules/dummy_seclabel/sql/dummy_seclabel.sql
@@ -6,15 +6,13 @@ CREATE EXTENSION dummy_seclabel;
-- initial setups
SET client_min_messages TO 'warning';
-DROP ROLE IF EXISTS dummy_seclabel_user1;
-DROP ROLE IF EXISTS dummy_seclabel_user2;
+DROP ROLE IF EXISTS regress_dummy_seclabel_user1;
+DROP ROLE IF EXISTS regress_dummy_seclabel_user2;
-DROP TABLE IF EXISTS dummy_seclabel_tbl1;
-DROP TABLE IF EXISTS dummy_seclabel_tbl2;
-DROP TABLE IF EXISTS dummy_seclabel_tbl3;
+RESET client_min_messages;
-CREATE USER dummy_seclabel_user1 WITH CREATEROLE;
-CREATE USER dummy_seclabel_user2;
+CREATE USER regress_dummy_seclabel_user1 WITH CREATEROLE;
+CREATE USER regress_dummy_seclabel_user2;
CREATE TABLE dummy_seclabel_tbl1 (a int, b text);
CREATE TABLE dummy_seclabel_tbl2 (x int, y text);
@@ -22,15 +20,13 @@ CREATE VIEW dummy_seclabel_view1 AS SELECT * FROM dummy_seclabel_tbl2;
CREATE FUNCTION dummy_seclabel_four() RETURNS integer AS $$SELECT 4$$ language sql;
CREATE DOMAIN dummy_seclabel_domain AS text;
-ALTER TABLE dummy_seclabel_tbl1 OWNER TO dummy_seclabel_user1;
-ALTER TABLE dummy_seclabel_tbl2 OWNER TO dummy_seclabel_user2;
-
-RESET client_min_messages;
+ALTER TABLE dummy_seclabel_tbl1 OWNER TO regress_dummy_seclabel_user1;
+ALTER TABLE dummy_seclabel_tbl2 OWNER TO regress_dummy_seclabel_user2;
--
-- Test of SECURITY LABEL statement with a plugin
--
-SET SESSION AUTHORIZATION dummy_seclabel_user1;
+SET SESSION AUTHORIZATION regress_dummy_seclabel_user1;
SECURITY LABEL ON TABLE dummy_seclabel_tbl1 IS 'classified'; -- OK
SECURITY LABEL ON COLUMN dummy_seclabel_tbl1.a IS 'unclassified'; -- OK
@@ -42,24 +38,24 @@ SECURITY LABEL ON TABLE dummy_seclabel_tbl2 IS 'unclassified'; -- fail (not owne
SECURITY LABEL ON TABLE dummy_seclabel_tbl1 IS 'secret'; -- fail (not superuser)
SECURITY LABEL ON TABLE dummy_seclabel_tbl3 IS 'unclassified'; -- fail (not found)
-SET SESSION AUTHORIZATION dummy_seclabel_user2;
+SET SESSION AUTHORIZATION regress_dummy_seclabel_user2;
SECURITY LABEL ON TABLE dummy_seclabel_tbl1 IS 'unclassified'; -- fail
SECURITY LABEL ON TABLE dummy_seclabel_tbl2 IS 'classified'; -- OK
--
-- Test for shared database object
--
-SET SESSION AUTHORIZATION dummy_seclabel_user1;
+SET SESSION AUTHORIZATION regress_dummy_seclabel_user1;
-SECURITY LABEL ON ROLE dummy_seclabel_user1 IS 'classified'; -- OK
-SECURITY LABEL ON ROLE dummy_seclabel_user1 IS '...invalid label...'; -- fail
-SECURITY LABEL FOR 'dummy' ON ROLE dummy_seclabel_user2 IS 'unclassified'; -- OK
-SECURITY LABEL FOR 'unknown_seclabel' ON ROLE dummy_seclabel_user1 IS 'unclassified'; -- fail
-SECURITY LABEL ON ROLE dummy_seclabel_user1 IS 'secret'; -- fail (not superuser)
-SECURITY LABEL ON ROLE dummy_seclabel_user3 IS 'unclassified'; -- fail (not found)
+SECURITY LABEL ON ROLE regress_dummy_seclabel_user1 IS 'classified'; -- OK
+SECURITY LABEL ON ROLE regress_dummy_seclabel_user1 IS '...invalid label...'; -- fail
+SECURITY LABEL FOR 'dummy' ON ROLE regress_dummy_seclabel_user2 IS 'unclassified'; -- OK
+SECURITY LABEL FOR 'unknown_seclabel' ON ROLE regress_dummy_seclabel_user1 IS 'unclassified'; -- fail
+SECURITY LABEL ON ROLE regress_dummy_seclabel_user1 IS 'secret'; -- fail (not superuser)
+SECURITY LABEL ON ROLE regress_dummy_seclabel_user3 IS 'unclassified'; -- fail (not found)
-SET SESSION AUTHORIZATION dummy_seclabel_user2;
-SECURITY LABEL ON ROLE dummy_seclabel_user2 IS 'unclassified'; -- fail (not privileged)
+SET SESSION AUTHORIZATION regress_dummy_seclabel_user2;
+SECURITY LABEL ON ROLE regress_dummy_seclabel_user2 IS 'unclassified'; -- fail (not privileged)
RESET SESSION AUTHORIZATION;
@@ -99,4 +95,11 @@ EXECUTE PROCEDURE event_trigger_test();
-- should trigger ddl_command_{start,end}
SECURITY LABEL ON TABLE dummy_seclabel_tbl1 IS 'classified';
+-- clean up
DROP EVENT TRIGGER always_start, always_end, always_drop, always_rewrite;
+
+DROP VIEW dummy_seclabel_view1;
+DROP TABLE dummy_seclabel_tbl1, dummy_seclabel_tbl2;
+
+DROP ROLE regress_dummy_seclabel_user1;
+DROP ROLE regress_dummy_seclabel_user2;