AdministratorGeoStoreClient extends GeoStoreClient { public ShortResourceList updateSecurityRules(ShortResourceList resourcesToSet, Long groupId, boolean canRead, boolean canWrite) { WebResource wr = getBaseWebResource("usergroups","update_security_rules", groupId, canRead, canWrite); ShortResourceList updatedResources = wr.header("Content-Type", MediaType.TEXT_XML) .accept(MediaType.TEXT_XML).put(ShortResourceList.class, resourcesToSet); return updatedResources; }  User getUser(long id); User getUser(String name); User getUser(long id, Boolean includeAttributes); UserList getUsers(); UserList getUsers(Integer page, Integer entries); User getUserDetails(); Long insert(User user); void deleteUser(Long id); void update(Long id, User user); long insertUserGroup(UserGroup usergroup); void deleteUserGroup(long usergroupId); void assignUserGroup(long userId, long usergroupId); void deassignUserGroup(long userId, long usergroupId); RESTUserGroup getUserGroup(long usergroupId); UserGroupList getUserGroups(Integer page, Integer entries, boolean all); ShortResourceList updateSecurityRules(ShortResourceList resourcesToSet, Long groupId,
            boolean canRead, boolean canWrite); RESTUserGroup getUserGroup(String name);  }
@Test public void updateSecurityRulesTest() { UserGroup ug = new UserGroup(); ug.setGroupName("usergroupTest1"); long gid = geoStoreClient.insertUserGroup(ug); UserGroup ug2 = new UserGroup(); ug2.setGroupName("unusedGroup"); long gid2 = geoStoreClient.insertUserGroup(ug2); UserGroup anotherGroup = new UserGroup(); anotherGroup.setGroupName("anotherGroup"); long anotherGid = geoStoreClient.insertUserGroup(anotherGroup); Set<UserGroup> ugroups = new HashSet<>(); ugroups.add(ug); ugroups.add(anotherGroup); createUser("u1", Role.USER, "u1"); createUser("u2", Role.USER, "u2", ug, anotherGroup); GeoStoreClient u1Client = createUserClient("u1", "u1"); GeoStoreClient u2Client = createUserClient("u2", "u2"); createUser("user", Role.USER, "user"); createDefaultCategory(); ShortResource sr = createAResource(); ShortResource sr2 = createAResource(); try{ u1Client.getResource(sr.getId(), true); fail("Untrapped exception"); } catch(UniformInterfaceException e){ assertEquals(403, e.getResponse().getStatus()); } try{ u2Client.getResource(sr.getId(), true); fail("Untrapped exception"); } catch(UniformInterfaceException e){ assertEquals(403, e.getResponse().getStatus()); } try{ u1Client.updateResource(sr.getId(), new RESTResource()); fail("Untrapped exception"); } catch(UniformInterfaceException e){ assertEquals(403, e.getResponse().getStatus()); } try{ u2Client.updateResource(sr.getId(), new RESTResource()); fail("Untrapped exception"); } catch(UniformInterfaceException e){ assertEquals(403, e.getResponse().getStatus()); } List<ShortResource> srl = new ArrayList<ShortResource>(); srl.add(sr); ShortResourceList srll = new ShortResourceList(srl); ShortResourceList srlf = geoStoreClient.getAllShortResource(0, 1000); assertEquals(2, srlf.getList().size()); geoStoreClient.updateSecurityRules(srll, gid, false, true); geoStoreClient.updateSecurityRules(srll, gid2, false, false); srlf = geoStoreClient.getAllShortResource(0, 1000); assertEquals(2, srlf.getList().size()); try{ u1Client.getResource(sr.getId(), true); } catch(UniformInterfaceException e){ assertEquals(403, e.getResponse().getStatus()); } try{ u2Client.getResource(sr.getId(), true); } catch(UniformInterfaceException e){ assertEquals(403, e.getResponse().getStatus()); } try{ u1Client.updateResource(sr.getId(), new RESTResource()); } catch(UniformInterfaceException e){ assertEquals(403, e.getResponse().getStatus()); } u2Client.updateResource(sr.getId(), new RESTResource()); }