Changeset: 6133dd94dfea for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/6133dd94dfea Added Files: sql/test/Tests/comment-auth-1.test sql/test/Tests/comment-auth-2.reqtests sql/test/Tests/comment-auth-2.test sql/test/Tests/comment-dump.test sql/test/Tests/comment-on.test Removed Files: sql/test/Tests/comment-auth.SQL.py sql/test/Tests/comment-dump-cleanup.sql sql/test/Tests/comment-dump-cleanup.test sql/test/Tests/comment-dump.SQL.py sql/test/Tests/comment-dump.sql sql/test/Tests/comment-on.SQL.py sql/test/Tests/comment-on.sql Modified Files: sql/test/Tests/All Branch: Jan2022 Log Message:
Converted tests. diffs (truncated from 1190 to 300 lines): diff --git a/sql/test/Tests/All b/sql/test/Tests/All --- a/sql/test/Tests/All +++ b/sql/test/Tests/All @@ -2,7 +2,8 @@ # leftovers from other tests comment-dump comment-on -comment-auth +comment-auth-1 +USER=user_a&PASSWD=user_a?comment-auth-2 bincopycollist-prepare bincopycollist diff --git a/sql/test/Tests/comment-auth-1.test b/sql/test/Tests/comment-auth-1.test new file mode 100644 --- /dev/null +++ b/sql/test/Tests/comment-auth-1.test @@ -0,0 +1,30 @@ +statement ok +CREATE USER user_a WITH PASSWORD 'user_a' NAME 'User A' SCHEMA sys + +statement ok +CREATE USER user_b WITH PASSWORD 'user_b' NAME 'User B' SCHEMA sys + +statement ok +CREATE ROLE role_b + +statement ok +GRANT role_b to user_b + +statement ok +CREATE SCHEMA schema_a AUTHORIZATION user_a + +statement ok +CREATE SCHEMA schema_b AUTHORIZATION role_b + +statement ok +CREATE TABLE schema_a.tab_a(i INTEGER) + +statement ok +CREATE TABLE schema_b.tab_b(i INTEGER) + +statement ok +COMMENT ON SCHEMA schema_a IS 'set by super user' + +statement ok +COMMENT ON SCHEMA schema_b IS 'set by super user' + diff --git a/sql/test/Tests/comment-auth-2.reqtests b/sql/test/Tests/comment-auth-2.reqtests new file mode 100644 --- /dev/null +++ b/sql/test/Tests/comment-auth-2.reqtests @@ -0,0 +1,1 @@ +comment-auth-1 diff --git a/sql/test/Tests/comment-auth-2.test b/sql/test/Tests/comment-auth-2.test new file mode 100644 --- /dev/null +++ b/sql/test/Tests/comment-auth-2.test @@ -0,0 +1,22 @@ +query TT nosort +select s.name, c.remark from sys.schemas s left outer join sys.comments c on s.id = c.id where not s.system order by name +---- +schema_a +set by super user +schema_b +set by super user + +statement error +COMMENT ON SCHEMA schema_b IS 'set by user_a' + +statement ok +COMMENT ON SCHEMA schema_a IS 'set by user_a' + +query TT nosort +select s.name, c.remark from sys.schemas s left outer join sys.comments c on s.id = c.id where not s.system order by name +---- +schema_a +set by user_a +schema_b +set by super user + diff --git a/sql/test/Tests/comment-auth.SQL.py b/sql/test/Tests/comment-auth.SQL.py deleted file mode 100644 --- a/sql/test/Tests/comment-auth.SQL.py +++ /dev/null @@ -1,78 +0,0 @@ -import os, sys, re -try: - from MonetDBtesting import process -except ImportError: - import process - -# As super user, create users and schemas owned by these users. - -SUPERUSER_SCRIPT = """ -CREATE USER user_a WITH PASSWORD 'user_a' NAME 'User A' SCHEMA sys; -CREATE USER user_b WITH PASSWORD 'user_b' NAME 'User B' SCHEMA sys; -CREATE ROLE role_b; -GRANT role_b to user_b; - -CREATE SCHEMA schema_a AUTHORIZATION user_a; -CREATE SCHEMA schema_b AUTHORIZATION role_b; - -CREATE TABLE schema_a.tab_a(i INTEGER); -CREATE TABLE schema_b.tab_b(i INTEGER); - -COMMENT ON SCHEMA schema_a IS 'set by super user'; -COMMENT ON SCHEMA schema_b IS 'set by super user'; -""" - -with process.client('sql', - stdin = process.PIPE, - stdout = process.PIPE, stderr = process.PIPE) as c: - out, err = c.communicate(SUPERUSER_SCRIPT) - if re.search(r'^[^#\n]', out, re.M): - sys.stdout.write(out) - sys.exit(1) - if re.search(r'^[^#\n]', err, re.M): - sys.stderr.write(err) - sys.exit(1) - - -USER_A_SCRIPT = r""" --- can we see the comments set by the super user? -\dn - --- we cannot change comments on objects we don't own -COMMENT ON SCHEMA schema_b IS 'set by user_a'; - --- but we can comment on our own stuff -COMMENT ON SCHEMA schema_a IS 'set by user_a'; -\dn -""" - -# As one of the users, check that we can only comment on our own objects. - -USER_A_STDOUT = '''\ -SCHEMA schema_a 'set by super user' -SCHEMA schema_b 'set by super user' -SCHEMA schema_a 'set by user_a' -SCHEMA schema_b 'set by super user' -''' - -USER_A_STDERR = r'''\ -MAPI = (user_a) /var/tmp/mtest-285315/.s.monetdb.\d+ -QUERY = COMMENT ON SCHEMA schema_b IS 'set by user_a'; -ERROR = !COMMENT ON: insufficient privileges for user 'user_a' in schema 'schema_b' -CODE = 42000 -''' - -with process.client('sql', - user='user_a', passwd='user_a', - stdin=process.PIPE, - echo=False, - stdout=process.PIPE, stderr=process.PIPE) as c: - out, err = c.communicate(USER_A_SCRIPT) - out = ' '.join(re.split('[ \t]+', out)) - if out != USER_A_STDOUT: - sys.stdout.write(out) - sys.exit(1) - err = ' '.join(re.split('[ \t]+', err)) - if re.match(USER_A_STDERR, err) is not None: - sys.stderr.write(err) - sys.exit(1) diff --git a/sql/test/Tests/comment-dump-cleanup.sql b/sql/test/Tests/comment-dump-cleanup.sql deleted file mode 100644 --- a/sql/test/Tests/comment-dump-cleanup.sql +++ /dev/null @@ -1,14 +0,0 @@ -DROP FUNCTION foo.f(); -DROP PROCEDURE foo.g(); -DROP FUNCTION foo.f(INT); -DROP FUNCTION foo.f(INT, INT); -DROP FUNCTION foo.f(INT, INT, INT); -DROP FUNCTION foo.f(INT, INT, INT, INT); - -DROP SEQUENCE foo.counter; - -DROP VIEW foo.vivi; - -DROP TABLE foo.tab; - -DROP SCHEMA foo; diff --git a/sql/test/Tests/comment-dump-cleanup.test b/sql/test/Tests/comment-dump-cleanup.test deleted file mode 100644 --- a/sql/test/Tests/comment-dump-cleanup.test +++ /dev/null @@ -1,30 +0,0 @@ -statement error -DROP FUNCTION foo.f() - -statement error -DROP PROCEDURE foo.g() - -statement error -DROP FUNCTION foo.f(INT) - -statement error -DROP FUNCTION foo.f(INT, INT) - -statement error -DROP FUNCTION foo.f(INT, INT, INT) - -statement error -DROP FUNCTION foo.f(INT, INT, INT, INT) - -statement error -DROP SEQUENCE foo.counter - -statement error -DROP VIEW foo.vivi - -statement error -DROP TABLE foo.tab - -statement error -DROP SCHEMA foo - diff --git a/sql/test/Tests/comment-dump.SQL.py b/sql/test/Tests/comment-dump.SQL.py deleted file mode 100644 --- a/sql/test/Tests/comment-dump.SQL.py +++ /dev/null @@ -1,92 +0,0 @@ -import os, sys, re -try: - from MonetDBtesting import process -except ImportError: - import process - -with process.client('sql', - stdin=open(os.path.join(os.getenv('TSTSRCDIR'), - 'comment-dump.sql')), - stdout=process.PIPE, stderr=process.PIPE) as c: - out, err = c.communicate() - if re.search(r'^[^#\n]', out, re.M): - sys.stdout.write(out) - if re.search(r'^[^#\n]', err, re.M): - sys.stderr.write(err) - -dump1 = '''\ -START TRANSACTION; -CREATE SCHEMA "foo" AUTHORIZATION "monetdb"; -COMMENT ON SCHEMA "foo" IS 'foo foo'; -CREATE SEQUENCE "foo"."counter" AS INTEGER; -COMMENT ON SEQUENCE "foo"."counter" IS 'counting'; -SET SCHEMA "foo"; -CREATE TABLE "foo"."tab" ( - "i" INTEGER, - "j" DECIMAL(4,2) -); -COMMENT ON TABLE "foo"."tab" IS 'table'; -CREATE INDEX "idx" ON "foo"."tab" ("j", "i"); -COMMENT ON INDEX "foo"."idx" IS 'index on j'; -COMMENT ON COLUMN "foo"."tab"."i" IS 'ii'; -COMMENT ON COLUMN "foo"."tab"."j" IS 'jj'; -create view vivi as select * from tab; -COMMENT ON VIEW "foo"."vivi" IS 'phew'; -create function f() returns int begin return 42; end; -COMMENT ON FUNCTION "foo"."f"() IS '0 parms'; -create function f(i int) returns int begin return 43; end; -COMMENT ON FUNCTION "foo"."f"(INTEGER) IS '1 parm'; -create function f(i int, j int) returns int begin return 44; end; -COMMENT ON FUNCTION "foo"."f"(INTEGER, INTEGER) IS '2 parms'; -create function f(i int, j int, k int) returns int begin return 45; end; -create function f(i int, j int, k int, l int) returns int begin return 45; end; -create procedure g() begin delete from tab where false; end; -COMMENT ON PROCEDURE "foo"."g"() IS 'proc'; -ALTER SEQUENCE "foo"."counter" RESTART WITH 1 NO CYCLE; -SET SCHEMA "sys"; -COMMIT; -''' - -dump2 = '''\ -START TRANSACTION; -SET SCHEMA "foo"; -create function f() returns int begin return 42; end; -COMMENT ON FUNCTION "foo"."f"() IS '0 parms'; -create function f(i int) returns int begin return 43; end; -COMMENT ON FUNCTION "foo"."f"(INTEGER) IS '1 parm'; -create function f(i int, j int) returns int begin return 44; end; -COMMENT ON FUNCTION "foo"."f"(INTEGER, INTEGER) IS '2 parms'; -create function f(i int, j int, k int) returns int begin return 45; end; -create function f(i int, j int, k int, l int) returns int begin return 45; end; -create procedure g() begin delete from tab where false; end; -COMMENT ON PROCEDURE "foo"."g"() IS 'proc'; -COMMIT; -''' - -with process.client('sqldump', - stdout=process.PIPE, stderr=process.PIPE) as d: - out, err = d.communicate() - out = ' '.join(re.split('[ \t]+', out)) - if out != dump1: - sys.stdout.write(out) - if re.search(r'^[^#\n]', err, re.M): - sys.stderr.write(err) - -with process.client('sqldump', args=['-f'], - stdout=process.PIPE, stderr=process.PIPE) as d2: - out, err = d2.communicate() _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list