|
static void | main (String[] args) throws Exception |
|
|
static final Logger | logger = LoggerFactory.getLogger(ViewPermissionsTest.class) |
|
Definition at line 23 of file ViewPermissionsTest.java.
static void com.mapd.tests.ViewPermissionsTest.main |
( |
String[] |
args | ) |
throws Exception |
|
inlinestatic |
Definition at line 26 of file ViewPermissionsTest.java.
27 ViewPermissionsTest test =
new ViewPermissionsTest();
28 test.testViewPermissions();
29 test.testCreateViewPermission();
void com.mapd.tests.ViewPermissionsTest.testCreateViewPermission |
( |
| ) |
throws Exception |
|
inline |
Definition at line 32 of file ViewPermissionsTest.java.
33 logger.info(
"testCreateViewPermission()");
35 HeavyDBTestClient su = HeavyDBTestClient.getClient(
36 "localhost", 6274,
"mapd",
"mapd",
"HyperInteractive");
38 su.runSql(
"CREATE USER dba (password = 'password', is_super = 'true');");
39 su.runSql(
"CREATE USER bob (password = 'password', is_super = 'false');");
40 su.runSql(
"CREATE USER bill (password = 'password', is_super = 'false');");
42 su.runSql(
"CREATE ROLE salesDept;");
43 su.runSql(
"CREATE USER foo (password = 'password', is_super = 'false');");
44 su.runSql(
"GRANT salesDept TO foo;");
46 su.runSql(
"CREATE DATABASE db1;");
48 su.runSql(
"GRANT ACCESS on database db1 TO bob;");
49 su.runSql(
"GRANT ACCESS on database db1 TO bill;");
50 su.runSql(
"GRANT ACCESS on database db1 TO foo;");
51 su.runSql(
"GRANT ACCESS on database db1 TO dba;");
53 HeavyDBTestClient dba =
54 HeavyDBTestClient.getClient(
"localhost", 6274,
"db1",
"dba",
"password");
55 HeavyDBTestClient bill =
56 HeavyDBTestClient.getClient(
"localhost", 6274,
"db1",
"bill",
"password");
57 HeavyDBTestClient bob =
58 HeavyDBTestClient.getClient(
"localhost", 6274,
"db1",
"bob",
"password");
60 dba.runSql(
"GRANT CREATE ON DATABASE db1 TO bill");
61 dba.runSql(
"GRANT DROP ON DATABASE db1 TO bill");
62 dba.runSql(
"GRANT CREATE VIEW ON DATABASE db1 TO bob");
63 dba.runSql(
"GRANT DROP VIEW ON DATABASE db1 TO bob");
65 bill.runSql(
"CREATE TABLE bill_table(id integer)");
66 shouldThrowException(
"bob cannot see bill_table",
67 () -> bob.runSql(
"CREATE VIEW bob_view AS SELECT id FROM bill_table"));
69 bill.runSql(
"GRANT SELECT ON TABLE bill_table TO bob");
70 bob.runSql(
"CREATE VIEW bob_view AS SELECT id FROM bill_table");
72 su.runSql(
"DROP DATABASE db1;");
73 su.runSql(
"DROP USER foo;");
74 su.runSql(
"DROP ROLE salesDept;");
75 su.runSql(
"DROP USER bob;");
76 su.runSql(
"DROP USER bill;");
77 su.runSql(
"DROP USER dba;");
void com.mapd.tests.ViewPermissionsTest.testViewPermissions |
( |
| ) |
throws Exception |
|
inline |
Definition at line 80 of file ViewPermissionsTest.java.
81 logger.info(
"testViewPermissions()");
83 HeavyDBTestClient su = HeavyDBTestClient.getClient(
84 "localhost", 6274,
"mapd",
"mapd",
"HyperInteractive");
86 su.runSql(
"CREATE USER dba (password = 'password', is_super = 'true');");
87 su.runSql(
"CREATE USER bob (password = 'password', is_super = 'false');");
88 su.runSql(
"CREATE USER bill (password = 'password', is_super = 'false');");
90 su.runSql(
"CREATE ROLE salesDept;");
91 su.runSql(
"CREATE USER foo (password = 'password', is_super = 'false');");
92 su.runSql(
"GRANT salesDept TO foo;");
94 su.runSql(
"CREATE DATABASE db1;");
95 su.runSql(
"CREATE DATABASE db2;");
97 su.runSql(
"GRANT ACCESS on database db1 TO bob;");
98 su.runSql(
"GRANT ACCESS on database db1 TO bill;");
99 su.runSql(
"GRANT ACCESS on database db1 TO foo;");
100 su.runSql(
"GRANT ACCESS on database db1 TO dba;");
102 su.runSql(
"GRANT ACCESS on database db2 TO bob;");
103 su.runSql(
"GRANT ACCESS on database db2 TO bill;");
104 su.runSql(
"GRANT ACCESS on database db2 TO foo;");
105 su.runSql(
"GRANT ACCESS on database db2 TO dba;");
107 HeavyDBTestClient dba =
108 HeavyDBTestClient.getClient(
"localhost", 6274,
"db1",
"dba",
"password");
109 HeavyDBTestClient bill =
110 HeavyDBTestClient.getClient(
"localhost", 6274,
"db1",
"bill",
"password");
111 HeavyDBTestClient bob =
112 HeavyDBTestClient.getClient(
"localhost", 6274,
"db1",
"bob",
"password");
113 HeavyDBTestClient foo =
114 HeavyDBTestClient.getClient(
"localhost", 6274,
"db1",
"foo",
"password");
116 shouldThrowException(
"bill should not be able to create tables",
117 () -> bill.runSql(
"CREATE VIEW bill_view AS SELECT id FROM bill_table"));
118 shouldThrowException(
"bob should not be able to create tables",
119 () -> bob.runSql(
"CREATE VIEW bob_view AS SELECT id FROM bob_table"));
120 shouldThrowException(
"foo should not be able to create tables",
121 () -> foo.runSql(
"CREATE VIEW foo_view AS SELECT id FROM foo_table"));
124 dba.runSql(
"GRANT CREATE ON DATABASE db1 TO bill");
125 dba.runSql(
"GRANT DROP ON DATABASE db1 TO bill");
126 dba.runSql(
"GRANT CREATE VIEW ON DATABASE db1 TO bill");
127 dba.runSql(
"GRANT DROP VIEW ON DATABASE db1 TO bill");
129 bill.runSql(
"CREATE TABLE bill_table(id integer)");
130 bill.runSql(
"CREATE VIEW bill_view AS SELECT id FROM bill_table");
132 shouldThrowException(
133 "not allowed to select", () -> bob.runSql(
"SELECT * from bill_table"));
134 shouldThrowException(
135 "not allowed to select", () -> foo.runSql(
"SELECT * from bill_table"));
136 shouldThrowException(
137 "not allowed to select", () -> bob.runSql(
"SELECT * from bill_view"));
138 shouldThrowException(
139 "not allowed to select", () -> foo.runSql(
"SELECT * from bill_view"));
141 bill.runSql(
"GRANT SELECT ON VIEW bill_view TO bob");
142 shouldThrowException(
143 "not allowed to select", () -> bob.runSql(
"SELECT * from bill_table"));
144 shouldThrowException(
145 "not allowed to select", () -> foo.runSql(
"SELECT * from bill_table"));
146 bob.runSql(
"SELECT * from bill_view");
147 shouldThrowException(
148 "foo not allowed to select", () -> foo.runSql(
"SELECT * from bill_view"));
150 bill.runSql(
"GRANT SELECT ON VIEW bill_view TO salesDept");
151 shouldThrowException(
152 "not allowed to select", () -> bob.runSql(
"SELECT * from bill_table"));
153 shouldThrowException(
154 "not allowed to select", () -> foo.runSql(
"SELECT * from bill_table"));
155 bob.runSql(
"SELECT * from bill_view");
156 foo.runSql(
"SELECT * from bill_view");
160 shouldThrowException(
161 "insert not allowed", () -> bob.runSql(
"INSERT INTO bill_view VALUES(1)"));
162 shouldThrowException(
163 "insert not allowed ", () -> foo.runSql(
"INSERT INTO bill_view VALUES(1)"));
165 bill.runSql(
"GRANT INSERT ON VIEW bill_view TO bob");
166 bob.runSql(
"INSERT INTO bill_view VALUES(1)");
167 shouldThrowException(
168 "insert not allowed ", () -> foo.runSql(
"INSERT INTO bill_view VALUES(1)"));
170 bill.runSql(
"GRANT INSERT ON VIEW bill_view TO salesDept");
171 bob.runSql(
"INSERT INTO bill_view VALUES(1)");
172 foo.runSql(
"INSERT INTO bill_view VALUES(1)");
174 shouldThrowException(
"update not allowed",
175 () -> bob.runSql(
"UPDATE bill_view SET id = 2 WHERE id = 0"));
176 shouldThrowException(
"update not allowed ",
177 () -> foo.runSql(
"UPDATE bill_view SET id = 2 WHERE id = 0"));
179 bill.runSql(
"GRANT UPDATE ON VIEW bill_view TO bob");
180 bob.runSql(
"UPDATE bill_view SET id = 2 WHERE id = 0");
181 shouldThrowException(
"update not allowed ",
182 () -> foo.runSql(
"UPDATE bill_view SET id = 2 WHERE id = 0"));
184 bill.runSql(
"GRANT UPDATE ON VIEW bill_table TO salesDept");
185 bob.runSql(
"UPDATE bill_table SET id = 2 WHERE id = 0");
186 foo.runSql(
"UPDATE bill_table SET id = 2 WHERE id = 0");
188 shouldThrowException(
"update not allowed",
189 () -> bob.runSql(
"DELETE FROM bill_view WHERE id = 0"));
190 shouldThrowException(
"update not allowed ",
191 () -> foo.runSql(
"DELETE FROM bill_view WHERE id = 0"));
193 bill.runSql(
"GRANT DELETE ON VIEW bill_table TO bob");
194 bob.runSql(
"DELETE FROM bill_view WHERE id = 0");
195 shouldThrowException(
"update not allowed ",
196 () -> foo.runSql(
"DELETE FROM bill_view WHERE id = 0"));
198 bill.runSql(
"GRANT DELETE ON VIEW bill_view TO salesDept");
199 bob.runSql(
"DELETE FROM bill_view WHERE id = 0");
200 foo.runSql(
"DELETE FROM bill_view WHERE id = 0");
203 su.runSql(
"DROP DATABASE db1;");
204 su.runSql(
"DROP DATABASE db2;");
205 su.runSql(
"DROP USER foo;");
206 su.runSql(
"DROP ROLE salesDept;");
207 su.runSql(
"DROP USER bob;");
208 su.runSql(
"DROP USER bill;");
209 su.runSql(
"DROP USER dba;");
final Logger com.mapd.tests.ViewPermissionsTest.logger = LoggerFactory.getLogger(ViewPermissionsTest.class) |
|
staticpackage |
The documentation for this class was generated from the following file: