172 logger.info(
"testDashboards()");
174 HeavyDBTestClient su = HeavyDBTestClient.getClient(
175 "localhost", 6274,
"omnisci",
"admin",
"HyperInteractive");
177 List<String> users = su.get_users();
179 su.runSql(
"CREATE USER dba (password = 'password', is_super = 'true');");
180 su.runSql(
"CREATE USER jason (password = 'password', is_super = 'false');");
181 su.runSql(
"CREATE USER bob (password = 'password', is_super = 'false');");
183 su.runSql(
"CREATE ROLE salesDept;");
184 su.runSql(
"CREATE USER foo (password = 'password', is_super = 'false');");
186 su.runSql(
"GRANT salesDept TO foo;");
188 HeavyDBTestClient dba =
189 HeavyDBTestClient.getClient(
"localhost", 6274,
"omnisci",
"dba",
"password");
190 HeavyDBTestClient jason = HeavyDBTestClient.getClient(
191 "localhost", 6274,
"omnisci",
"jason",
"password");
192 HeavyDBTestClient bob =
193 HeavyDBTestClient.getClient(
"localhost", 6274,
"omnisci",
"bob",
"password");
194 HeavyDBTestClient foo =
195 HeavyDBTestClient.getClient(
"localhost", 6274,
"omnisci",
"foo",
"password");
197 su.runSql(
"GRANT CREATE DASHBOARD ON DATABASE omnisci TO jason;");
199 shouldThrowException(
"bob should not be able to create dashboards",
200 () -> bob.create_dashboard(
"for_bob"));
201 shouldThrowException(
"foo should not be able to create dashboards",
202 () -> foo.create_dashboard(
"for_bob"));
204 int for_bob = jason.create_dashboard(
"for_bob");
205 int for_sales = jason.create_dashboard(
"for_sales");
206 int for_all = jason.create_dashboard(
"for_all");
208 HeavyDBAsserts.assertEqual(0, bob.get_dashboards().size());
209 HeavyDBAsserts.assertEqual(0, foo.get_dashboards().size());
211 HeavyDBTestClient granter = jason;
212 granter.runSql(
"GRANT VIEW ON DASHBOARD " + for_bob +
" TO bob;");
213 granter.runSql(
"GRANT VIEW ON DASHBOARD " + for_sales +
" TO salesDept;");
214 granter.runSql(
"GRANT VIEW ON DASHBOARD " + for_all +
" TO bob;");
215 granter.runSql(
"GRANT VIEW ON DASHBOARD " + for_all +
" TO salesDept;");
217 HeavyDBAsserts.assertEqual(2, bob.get_dashboards().size());
218 HeavyDBAsserts.assertEqual(2, foo.get_dashboards().size());
220 shouldThrowException(
"bob should not be able to access for_sales",
221 () -> bob.get_dashboard(for_sales));
222 shouldThrowException(
223 "foo should not be able to access for_bob", () -> foo.get_dashboard(for_bob));
225 HeavyDBAsserts.assertEqual(
"for_bob", bob.get_dashboard(for_bob));
226 HeavyDBAsserts.assertEqual(
"for_all", bob.get_dashboard(for_all));
228 HeavyDBAsserts.assertEqual(
"for_sales", foo.get_dashboard(for_sales));
229 HeavyDBAsserts.assertEqual(
"for_all", foo.get_dashboard(for_all));
232 shouldThrowException(
"bob can not edit for_bob",
233 () -> bob.replace_dashboard(for_bob,
"for_bob2",
"jason"));
234 shouldThrowException(
"foo can not edit for_bob",
235 () -> foo.replace_dashboard(for_bob,
"for_bob2",
"jason"));
236 shouldThrowException(
"bob can not edit for_sales",
237 () -> bob.replace_dashboard(for_sales,
"for_sales2",
"jason"));
238 shouldThrowException(
"foo can not edit for_sales",
239 () -> foo.replace_dashboard(for_sales,
"for_sales2",
"jason"));
241 jason.runSql(
"GRANT EDIT ON DASHBOARD " + for_bob +
" TO bob;");
242 jason.runSql(
"GRANT EDIT ON DASHBOARD " + for_sales +
" TO salesDept;");
243 shouldThrowException(
"foo can not edit for_bob",
244 () -> foo.replace_dashboard(for_bob,
"for_bob2",
"jason"));
245 shouldThrowException(
"bob can not edit for_sales",
246 () -> bob.replace_dashboard(for_sales,
"for_sales2",
"jason"));
248 jason.replace_dashboard(for_all,
"for_all2",
"jason");
249 bob.replace_dashboard(for_bob,
"for_bob2",
"jason");
250 foo.replace_dashboard(for_sales,
"for_sales2",
"jason");
252 HeavyDBAsserts.assertEqual(
"for_bob2", bob.get_dashboard(for_bob));
253 HeavyDBAsserts.assertEqual(
"for_all2", bob.get_dashboard(for_all));
255 HeavyDBAsserts.assertEqual(
"for_sales2", foo.get_dashboard(for_sales));
256 HeavyDBAsserts.assertEqual(
"for_all2", foo.get_dashboard(for_all));
258 shouldThrowException(
259 "foo can not delete for_bob", () -> foo.delete_dashboard(for_bob));
260 shouldThrowException(
261 "foo can not delete for_sales", () -> foo.delete_dashboard(for_sales));
262 shouldThrowException(
263 "foo can not delete for_all", () -> foo.delete_dashboard(for_all));
265 shouldThrowException(
266 "bob can not delete for_bob", () -> bob.delete_dashboard(for_bob));
267 shouldThrowException(
268 "bob can not delete for_sales", () -> bob.delete_dashboard(for_sales));
269 shouldThrowException(
270 "bob can not delete for_all", () -> bob.delete_dashboard(for_all));
272 jason.delete_dashboard(for_bob);
274 HeavyDBAsserts.assertEqual(1, bob.get_dashboards().size());
275 HeavyDBAsserts.assertEqual(2, foo.get_dashboards().size());
276 HeavyDBAsserts.assertEqual(
"for_all2", bob.get_dashboard(for_all));
277 HeavyDBAsserts.assertEqual(
"for_sales2", foo.get_dashboard(for_sales));
278 HeavyDBAsserts.assertEqual(
"for_all2", foo.get_dashboard(for_all));
280 jason.delete_dashboard(for_all);
282 HeavyDBAsserts.assertEqual(0, bob.get_dashboards().size());
283 HeavyDBAsserts.assertEqual(1, foo.get_dashboards().size());
284 HeavyDBAsserts.assertEqual(
"for_sales2", foo.get_dashboard(for_sales));
286 jason.delete_dashboard(for_sales);
288 HeavyDBAsserts.assertEqual(0, bob.get_dashboards().size());
289 HeavyDBAsserts.assertEqual(0, foo.get_dashboards().size());
291 su.runSql(
"DROP USER foo;");
292 su.runSql(
"DROP ROLE salesDept;");
293 su.runSql(
"DROP USER bob;");
294 su.runSql(
"DROP USER jason;");
295 su.runSql(
"DROP USER dba;");