@Test public void testRoleSetAllUnknownGroup() { backend.initialize(context); assertEquals( Sets.newHashSet(), backend.getPrivileges(Sets.newHashSet("not-a-group"), ActiveRoleSet.ALL)); }
@Test public void testRoleSetOne() { backend.initialize(context); assertEquals( Sets.newHashSet("server=server1->functions"), backend.getPrivileges( Sets.newHashSet("manager"), new ActiveRoleSet(Sets.newHashSet("functions")))); }
@Test public void testRoleSetNone() { backend.initialize(context); assertEquals( Sets.newHashSet(), backend.getPrivileges( Sets.newHashSet("manager"), new ActiveRoleSet(new HashSet<String>()))); }
@Test public void testRoleSetTwo() { backend.initialize(context); assertEquals( Sets.newHashSet("server=server1->db=jranalyst1", "server=server1->functions"), backend.getPrivileges( Sets.newHashSet("manager"), new ActiveRoleSet(Sets.newHashSet("junior_analyst_role", "functions")))); }
@Test public void testInitializeTwice() { backend.initialize(context); try { backend.initialize(context); fail("Expected IllegalStateException on second initialze"); } catch (IllegalStateException e) { // expected } }
@Test public void testRoleSetAll() { backend.initialize(context); assertEquals( Sets.newHashSet( "server=server1->db=customers->table=purchases->select", "server=server1->db=analyst1", "server=server1->db=jranalyst1->table=*->select", "server=server1->db=jranalyst1", "server=server1->functions"), backend.getPrivileges(Sets.newHashSet("manager"), ActiveRoleSet.ALL)); }
@Test(expected = IllegalStateException.class) public void testUninitializeValidatePolicy() { backend.validatePolicy(true); }
@Test(expected = IllegalStateException.class) public void testUninitializeGetPrivileges() { backend.getPrivileges(new HashSet<String>(), ActiveRoleSet.ALL); }