@Test public void testGetAllRoles() throws Exception { String role1 = "r1", role2 = "r2"; Set<String> twoGroups = Sets.newHashSet("g1", "g2"); String grantor = "grantor"; sentryStore.createRole(SEARCH, role1, grantor); sentryStore.createRole(SEARCH, role2, grantor); sentryStore.alterRoleAddGroups(SEARCH, role1, twoGroups, grantor); sentryStore.alterRoleAddGroups(SEARCH, role2, twoGroups, grantor); //test get all roles by groupName=null String groupName = null; Set<String> groups = Sets.newHashSet(groupName); assertEquals(Sets.newHashSet(role1,role2), sentryStore.getRolesByGroups(SEARCH, groups)); groups.clear(); assertEquals(0, sentryStore.getRolesByGroups(SEARCH, groups).size()); } }
@Test public void testGetAllRoles() throws Exception { String role1 = "r1", role2 = "r2"; Set<String> twoGroups = Sets.newHashSet("g1", "g2"); String grantor = "grantor"; sentryStore.createRole(SEARCH, role1, grantor); sentryStore.createRole(SEARCH, role2, grantor); sentryStore.alterRoleAddGroups(SEARCH, role1, twoGroups, grantor); sentryStore.alterRoleAddGroups(SEARCH, role2, twoGroups, grantor); //test get all roles by groupName=null String groupName = null; Set<String> groups = Sets.newHashSet(groupName); assertEquals(Sets.newHashSet(role1,role2), sentryStore.getRolesByGroups(SEARCH, groups)); groups.clear(); assertEquals(0, sentryStore.getRolesByGroups(SEARCH, groups).size()); } }
@Test public void testGetRolesByGroupNames() throws Exception { String role1 = "r1", role2 = "r2"; Set<String> twoGroups = Sets.newHashSet("g1", "g2"); String grantor = "grantor"; sentryStore.createRole(SEARCH, role1, grantor); sentryStore.createRole(SEARCH, role2, grantor); sentryStore.alterRoleAddGroups(SEARCH, role1, twoGroups, grantor); sentryStore.alterRoleAddGroups(SEARCH, role2, twoGroups, grantor); assertEquals(Sets.newHashSet(role1,role2), sentryStore.getRolesByGroups(SEARCH, twoGroups)); }
@Test public void testGetRolesByGroupNames() throws Exception { String role1 = "r1", role2 = "r2"; Set<String> twoGroups = Sets.newHashSet("g1", "g2"); String grantor = "grantor"; sentryStore.createRole(SEARCH, role1, grantor); sentryStore.createRole(SEARCH, role2, grantor); sentryStore.alterRoleAddGroups(SEARCH, role1, twoGroups, grantor); sentryStore.alterRoleAddGroups(SEARCH, role2, twoGroups, grantor); assertEquals(Sets.newHashSet(role1,role2), sentryStore.getRolesByGroups(SEARCH, twoGroups)); }
@Test public void testAddDeleteRoleToGroups() throws Exception { String role1 = "r1", role2 = "r2"; Set<String> twoGroups = Sets.newHashSet("g1", "g2"); Set<String> oneGroup = Sets.newHashSet("g3"); String grantor = "grantor"; sentryStore.createRole(SEARCH, role1, grantor); sentryStore.createRole(SEARCH, role2, grantor); sentryStore.alterRoleAddGroups(SEARCH, role1, twoGroups, grantor); assertEquals(twoGroups, sentryStore.getGroupsByRoles(SEARCH,Sets.newHashSet(role1))); assertEquals(Sets.newHashSet(role1), sentryStore.getRolesByGroups(SEARCH, twoGroups)); sentryStore.alterRoleAddGroups(SEARCH, role2, oneGroup, grantor); assertEquals(oneGroup, sentryStore.getGroupsByRoles(SEARCH, Sets.newHashSet(role2))); sentryStore.alterRoleDeleteGroups(SEARCH, role1, Sets.newHashSet("g1"), grantor); assertEquals(Sets.newHashSet("g2"), sentryStore.getGroupsByRoles(SEARCH, Sets.newHashSet(role1))); sentryStore.alterRoleDeleteGroups(SEARCH, role2, oneGroup, grantor); assertEquals(Sets.newHashSet(), sentryStore.getGroupsByRoles(SEARCH, Sets.newHashSet(role2))); }
assertEquals(Sets.newHashSet(role1), sentryStore.getRolesByGroups(SEARCH, twoGroups)); tRoles = sentryStore.getTSentryRolesByGroupName(SEARCH, tempGroups); assertEquals(3, tRoles.size()); //Should get all roles assertEquals(Sets.newHashSet(role1, role2, role3), sentryStore.getRolesByGroups(SEARCH, tempGroups));