@Test public void testRoleServiceReadOnly() throws Exception { setAuth(); GeoServerRoleService roleService = getSecurityManager().getActiveRoleService(); assertFalse(roleService.canCreateStore()); assertNull(roleService.createStore()); }
@Test public void testWrapRoleService() throws Exception { GeoServerRoleService roleService = getSecurityManager().getActiveRoleService(); assertFalse(roleService instanceof GroupAdminRoleService); setAuth(); roleService = getSecurityManager().getActiveRoleService(); assertTrue(roleService instanceof GroupAdminRoleService); }
@Test public void testWrapUserGroupService() throws Exception { GeoServerUserGroupService ugService = getSecurityManager().loadUserGroupService(ugStore.getName()); assertFalse(ugService instanceof GroupAdminUserGroupService); setAuth(); ugService = getSecurityManager().loadUserGroupService(ugStore.getName()); assertTrue(ugService instanceof GroupAdminUserGroupService); }
@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 testHideAdminRole() throws Exception { GeoServerRoleService roleService = getSecurityManager().getActiveRoleService(); GeoServerRole adminRole = roleService.createRoleObject("adminRole"); assertTrue(roleService.getRoles().contains(adminRole)); assertNotNull(roleService.getAdminRole()); assertNotNull(roleService.getRoleByName("adminRole")); setAuth(); roleService = getSecurityManager().getActiveRoleService(); assertFalse(roleService.getRoles().contains(adminRole)); assertNull(roleService.getAdminRole()); assertNull(roleService.getRoleByName("adminRole")); }
@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(); } ; } }