Mercurial > gemma
view schema/manage_users_tests.sql @ 195:5dc8e734487a
Introduce database schemas as privilege-based namespaces
Some privileges changed (e.g. for responsibility_areas), but additional
privileges were not left off intentionally before.
Search path settings have been replaced by schema-qualifying names in
statements to prevent object definitions from being dependend on
search path settings.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Fri, 20 Jul 2018 17:28:16 +0200 |
parents | a9d9c2b1d08c |
children | b67208d82543 |
line wrap: on
line source
BEGIN; -- -- pgTAP test script for user management functions -- SELECT plan(6); -- Give number of tests that have to be run SET search_path TO public, gemma, gemma_waterway, gemma_fairway; SET SESSION AUTHORIZATION waterway_admin; SELECT throws_ok($$ SELECT sys_admin.create_user( 'waterway_user', 'test0', 'secret', 'AT', NULL, 'test0') $$, 42501, NULL, 'Less privileged user cannot call function in schema sys_admin'); SET SESSION AUTHORIZATION sys_admin; SELECT lives_ok($$ SELECT sys_admin.create_user( 'waterway_user', 'test1', 'secret', 'AT', NULL, 'test1') $$, 'New waterway user can be added'); SELECT throws_ok($$ SELECT sys_admin.create_user( 'invalid', 'test2', 'secret', 'AT', NULL, 'test2') $$, 42704, NULL, 'Valid role name has to be provided'); SELECT throws_ok($$ SELECT sys_admin.create_user( 'waterway_user', NULL, 'secret', 'AT', NULL, 'test3') $$, 23502, NULL, 'username is mandatory'); -- Though other arguments are mandatory, too, there are no explicit tests SELECT throws_ok($$ SELECT sys_admin.create_user( 'waterway_user', 'waterway_user', 'secret', 'AT', NULL, 'test4') $$, 23505, NULL, 'No duplicate user name is allowed'); SELECT throws_ok($$ SELECT sys_admin.create_user( 'waterway_user', 'test2', 'secret', 'AT', NULL, 'xxx') $$, 23505, NULL, 'No duplicate e-mail adress is allowed'); -- -- finish tests -- SELECT * FROM finish(); -- Rollback because we don't want test roles to stay in the cluster, which -- would make tests not repeatable ROLLBACK;