comparison schema/manage_users_tests.sql @ 185:a9d9c2b1d08c

Add database function to create role and user profile
author Tom Gottfried <tom@intevation.de>
date Thu, 19 Jul 2018 16:37:52 +0200
parents
children 5dc8e734487a
comparison
equal deleted inserted replaced
184:bc7829defa99 185:a9d9c2b1d08c
1 BEGIN;
2 --
3 -- pgTAP test script for user management functions
4 --
5 SELECT plan(5); -- Give number of tests that have to be run
6
7 SET search_path TO public, gemma, gemma_waterway, gemma_fairway;
8
9 --
10 -- Run tests as system_admin
11 --
12 SET SESSION AUTHORIZATION sys_admin;
13
14 SELECT lives_ok($$
15 SELECT create_user(
16 'waterway_user', 'test1', 'secret', 'AT', NULL, 'test1')
17 $$,
18 'New waterway user can be added');
19
20 SELECT throws_ok($$
21 SELECT create_user(
22 'invalid', 'test2', 'secret', 'AT', NULL, 'test2')
23 $$,
24 42704, NULL,
25 'Valid role name has to be provided');
26
27 SELECT throws_ok($$
28 SELECT create_user(
29 'waterway_user', NULL, 'secret', 'AT', NULL, 'test3')
30 $$,
31 23502, NULL,
32 'username is mandatory');
33 -- Though other arguments are mandatory, too, there are no explicit tests
34
35 SELECT throws_ok($$
36 SELECT create_user(
37 'waterway_user', 'waterway_user', 'secret', 'AT', NULL, 'test4')
38 $$,
39 23505, NULL,
40 'No duplicate user name is allowed');
41
42 SELECT throws_ok($$
43 SELECT create_user(
44 'waterway_user', 'test2', 'secret', 'AT', NULL, 'xxx')
45 $$,
46 23505, NULL,
47 'No duplicate e-mail adress is allowed');
48
49 --
50 -- finish tests
51 --
52 SELECT * FROM finish();
53
54 -- Rollback because we don't want test roles to stay in the cluster, which
55 -- would make tests not repeatable
56 ROLLBACK;