@Test public void testRemoveUserInGroup() throws Exception { testAssignUserToGroup(); GeoServerUserGroupService ugService = getSecurityManager().loadUserGroupService(ugStore.getName()); GeoServerUserGroupStore ugStore = ugService.createStore(); GeoServerUser bill = ugStore.getUserByUsername("bill"); ugStore.removeUser(bill); ugStore.store(); assertNull(ugStore.getUserByUsername("bill")); }
@Test public void testCreateNewUser() throws Exception { setAuth(); GeoServerUserGroupService ugService = getSecurityManager().loadUserGroupService(ugStore.getName()); GeoServerUserGroupStore ugStore = ugService.createStore(); GeoServerUser bill = ugStore.createUserObject("bill", "foobar", true); ugStore.addUser(bill); ugStore.store(); assertNotNull(ugService.getUserByUsername("bill")); }
@Test public void testHideGroups() throws Exception { GeoServerUserGroupService ugService = getSecurityManager().loadUserGroupService(ugStore.getName()); assertTrue(ugService.getUserGroups().contains(users)); assertNotNull(ugService.getGroupByGroupname("users")); assertTrue(ugService.getUserGroups().contains(admins)); assertNotNull(ugService.getGroupByGroupname("admins")); setAuth(); ugService = getSecurityManager().loadUserGroupService(ugStore.getName()); assertTrue(ugService.getUserGroups().contains(users)); assertNotNull(ugService.getGroupByGroupname("users")); assertFalse(ugService.getUserGroups().contains(admins)); assertNull(ugService.getGroupByGroupname("admins")); }
@Test public void testAssignUserToGroup() throws Exception { testCreateNewUser(); GeoServerUserGroupService ugService = getSecurityManager().loadUserGroupService(ugStore.getName()); GeoServerUserGroupStore ugStore = ugService.createStore(); GeoServerUser bill = ugStore.getUserByUsername("bill"); ugStore.associateUserToGroup(bill, users); ugStore.store(); assertEquals(1, ugStore.getGroupsForUser(bill).size()); assertTrue(ugStore.getGroupsForUser(bill).contains(users)); ugStore.associateUserToGroup(bill, admins); ugStore.store(); assertEquals(1, ugStore.getGroupsForUser(bill).size()); assertTrue(ugStore.getGroupsForUser(bill).contains(users)); assertFalse(ugStore.getGroupsForUser(bill).contains(admins)); }
@Test public void testRemoveUserNotInGroup() throws Exception { GeoServerUserGroupService ugService = getSecurityManager().loadUserGroupService(ugStore.getName()); GeoServerUserGroupStore ugStore = ugService.createStore(); GeoServerUser sally = ugStore.createUserObject("sally", "foobar", true); ugStore.addUser(sally); ugStore.associateUserToGroup(sally, admins); ugStore.store(); setAuth(); ugService = getSecurityManager().loadUserGroupService(ugStore.getName()); ugStore = ugService.createStore(); try { ugStore.removeUser(sally); fail(); } catch (IOException e) { ugStore.load(); } ; }