diff options
author | Michael Paquier <michael@paquier.xyz> | 2022-07-13 12:21:20 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2022-07-13 12:21:20 +0900 |
commit | 08951a7c93cf0dd791ee6ac8a8cf5e4b152528e5 (patch) | |
tree | 8df0cc6cc141afde94f98d3ac9ac32421e428d76 /src/bin/scripts/t/040_createuser.pl | |
parent | c23e3e6beb273ae8c0f8e616edb7ed1acb0271c4 (diff) | |
download | postgresql-08951a7c93cf0dd791ee6ac8a8cf5e4b152528e5.tar.gz postgresql-08951a7c93cf0dd791ee6ac8a8cf5e4b152528e5.zip |
createuser: Add support for more clause types through new options
The following options are added to createuser:
* --valid-until to generate a VALID UNTIL clause for the role created.
* --bypassrls/--no-bypassrls for BYPASSRLS/NOBYPASSRLS.
* -m/--member to make the new role a member of an existing role, with an
extra ROLE clause generated. The clause generated overlaps with
-g/--role, but per discussion this was the most popular choice as option
name.
* -a/--admin for the addition of an ADMIN clause.
These option names are chosen to be completely new, so as they do not
impact anybody relying on the existing option set. Tests are added for
the new options and extended a bit, while on it, to cover more patterns
where quotes are added to various elements of the query generated.
Author: Shinya Kato
Reviewed-by: Nathan Bossart, Daniel Gustafsson, Robert Haas, Kyotaro
Horiguchi, David G. Johnston, Przemysław Sztoch
Discussion: https://postgr.es/m/69a9851035cf0f0477bcc5d742b031a3@oss.nttdata.com
Diffstat (limited to 'src/bin/scripts/t/040_createuser.pl')
-rw-r--r-- | src/bin/scripts/t/040_createuser.pl | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/bin/scripts/t/040_createuser.pl b/src/bin/scripts/t/040_createuser.pl index 2a34be81cf6..834d258bf87 100644 --- a/src/bin/scripts/t/040_createuser.pl +++ b/src/bin/scripts/t/040_createuser.pl @@ -25,13 +25,41 @@ $node->issues_sql_like( qr/statement: CREATE ROLE regress_role1 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT NOLOGIN;/, 'create a non-login role'); $node->issues_sql_like( - [ 'createuser', '-r', 'regress_user2' ], - qr/statement: CREATE ROLE regress_user2 NOSUPERUSER NOCREATEDB CREATEROLE INHERIT LOGIN;/, + [ 'createuser', '-r', 'regress user2' ], + qr/statement: CREATE ROLE "regress user2" NOSUPERUSER NOCREATEDB CREATEROLE INHERIT LOGIN;/, 'create a CREATEROLE user'); $node->issues_sql_like( [ 'createuser', '-s', 'regress_user3' ], qr/statement: CREATE ROLE regress_user3 SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN;/, 'create a superuser'); +$node->issues_sql_like( + [ + 'createuser', '-a', + 'regress_user1', '-a', + 'regress user2', 'regress user #4' + ], + qr/statement: CREATE ROLE "regress user #4" NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN ADMIN regress_user1,"regress user2";/, + 'add a role as a member with admin option of the newly created role'); +$node->issues_sql_like( + [ + 'createuser', '-m', + 'regress_user3', '-m', + 'regress user #4', 'REGRESS_USER5' + ], + qr/statement: CREATE ROLE "REGRESS_USER5" NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN ROLE regress_user3,"regress user #4";/, + 'add a role as a member of the newly created role'); +$node->issues_sql_like( + [ 'createuser', '-v', '2029 12 31', 'regress_user6' ], + qr/statement: CREATE ROLE regress_user6 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN VALID UNTIL \'2029 12 31\';/, + 'create a role with a password expiration date'); +$node->issues_sql_like( + [ 'createuser', '--bypassrls', 'regress_user7' ], + qr/statement: CREATE ROLE regress_user7 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN BYPASSRLS;/, + 'create a BYPASSRLS role'); +$node->issues_sql_like( + [ 'createuser', '--no-bypassrls', 'regress_user8' ], + qr/statement: CREATE ROLE regress_user8 NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN NOBYPASSRLS;/, + 'create a role without BYPASSRLS'); $node->command_fails([ 'createuser', 'regress_user1' ], 'fails if role already exists'); |