Mercurial > gemma
comparison schema/auth_tests.sql @ 2147:b66cfcde8ff7
Print templates: Stubbed endpoints under /api/templates/print/{name}
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 08 Feb 2019 11:02:05 +0100 |
parents | c4db392130a4 |
children | 4374d942b23d |
comparison
equal
deleted
inserted
replaced
2146:7267f8168176 | 2147:b66cfcde8ff7 |
---|---|
34 SELECT is_empty($$ | 34 SELECT is_empty($$ |
35 SELECT * FROM waterway.bottlenecks WHERE NOT staging_done | 35 SELECT * FROM waterway.bottlenecks WHERE NOT staging_done |
36 $$, | 36 $$, |
37 'Only staged data should be visible'); | 37 'Only staged data should be visible'); |
38 | 38 |
39 SELECT isnt_empty($$ | 39 --SELECT isnt_empty($$ |
40 SELECT * FROM users.templates | 40 -- SELECT * FROM users.templates |
41 $$, | 41 -- $$, |
42 'User should see templates associated to him'); | 42 -- 'User should see templates associated to him'); |
43 SELECT is_empty($$ | 43 --SELECT is_empty($$ |
44 SELECT * FROM users.templates | 44 -- SELECT * FROM users.templates |
45 JOIN users.user_templates USING (template_name) | 45 -- JOIN users.user_templates USING (template_name) |
46 WHERE username <> current_user | 46 -- WHERE username <> current_user |
47 $$, | 47 -- $$, |
48 'User should only see templates associated to him'); | 48 -- 'User should only see templates associated to him'); |
49 | 49 |
50 -- | 50 -- |
51 -- Run tests as waterway administrator | 51 -- Run tests as waterway administrator |
52 -- | 52 -- |
53 SET SESSION AUTHORIZATION test_admin_at; | 53 SET SESSION AUTHORIZATION test_admin_at; |
77 $$, | 77 $$, |
78 42501, NULL, | 78 42501, NULL, |
79 'Waterway admin cannot insert data outside his region'); | 79 'Waterway admin cannot insert data outside his region'); |
80 | 80 |
81 -- template management | 81 -- template management |
82 SELECT isnt_empty($$ | 82 --SELECT isnt_empty($$ |
83 SELECT * FROM users.templates | 83 -- SELECT * FROM users.templates |
84 JOIN users.user_templates USING (template_name) | 84 -- JOIN users.user_templates USING (template_name) |
85 WHERE username <> current_user | 85 -- WHERE username <> current_user |
86 $$, | 86 -- $$, |
87 'Waterway admin should see templates of other users'); | 87 -- 'Waterway admin should see templates of other users'); |
88 | 88 |
89 SELECT lives_ok($$ | 89 --SELECT lives_ok($$ |
90 INSERT INTO users.templates (template_name, template_data) | 90 -- INSERT INTO users.templates (template_name, template_data) |
91 VALUES ('New AT', '\x'); | 91 -- VALUES ('New AT', '\x'); |
92 INSERT INTO users.user_templates | 92 -- INSERT INTO users.user_templates |
93 VALUES ('test_user_at', 'New AT') | 93 -- VALUES ('test_user_at', 'New AT') |
94 $$, | 94 -- $$, |
95 'Waterway admin can add templates for users in his country'); | 95 -- 'Waterway admin can add templates for users in his country'); |
96 | 96 |
97 SELECT throws_ok($$ | 97 --SELECT throws_ok($$ |
98 INSERT INTO users.user_templates VALUES ('waterway_user2', 'AT') | 98 -- INSERT INTO users.user_templates VALUES ('waterway_user2', 'AT') |
99 $$, | 99 -- $$, |
100 42501, NULL, | 100 -- 42501, NULL, |
101 'Waterway admin cannot add template for other country'); | 101 -- 'Waterway admin cannot add template for other country'); |
102 | 102 |
103 SELECT isnt_empty($$ | 103 SELECT isnt_empty($$ |
104 UPDATE users.templates SET template_data = '\xDABE' | 104 UPDATE users.templates SET template_data = '\xDABE' |
105 WHERE template_name = 'AT' RETURNING * | 105 WHERE template_name = 'AT' RETURNING * |
106 $$, | 106 $$, |