test_class.declarator: geoStoreClient
test_class.original_string: AdministratorGeoStoreClient geoStoreClient;
test_class.type: AdministratorGeoStoreClient
test_class.var_name: geoStoreClient
test_class.declarator: geoStoreUserClient
test_class.original_string: GeoStoreClient geoStoreUserClient;
test_class.type: GeoStoreClient
test_class.var_name: geoStoreUserClient
test_class.declarator: LOGGER = Logger.getLogger(AdministratorGeostoreClientTest.class)
test_class.modifier: private final static
test_class.original_string: private final static Logger LOGGER = Logger.getLogger(AdministratorGeostoreClientTest.class);
test_class.type: Logger
test_class.var_name: LOGGER
test_class.declarator: DEFAULTCATEGORYNAME = "TestCategory1"
test_class.modifier: final
test_class.original_string: final String DEFAULTCATEGORYNAME = "TestCategory1";
test_class.type: String
test_class.var_name: DEFAULTCATEGORYNAME
test_class.declarator: KEY_STRING = "stringAtt"
test_class.modifier: final
test_class.original_string: final String KEY_STRING = "stringAtt";
test_class.type: String
test_class.var_name: KEY_STRING
test_class.declarator: origString = "OrigStringValue"
test_class.modifier: final
test_class.original_string: final String origString = "OrigStringValue";
test_class.type: String
test_class.var_name: origString
test_class.file: src/modules/rest/client/src/test/java/it/geosolutions/geostore/services/rest/AdministratorGeostoreClientTest.java
test_class.identifier: AdministratorGeostoreClientTest
test_case.body: @Test
      public void updateSecurityRulesTest() {
          
          // Create a group
          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);
          
          // Create 2 user
          createUser("u1", Role.USER, "u1");
          createUser("u2", Role.USER, "u2", ug, anotherGroup);
                  
          GeoStoreClient u1Client = createUserClient("u1", "u1");
          GeoStoreClient u2Client = createUserClient("u2", "u2");
          
          // Create a resource with the user "user". So user will be the owner
          createUser("user", Role.USER, "user");
          createDefaultCategory();
          ShortResource sr = createAResource();
          ShortResource sr2 = createAResource();
          
          
          // Since "user" is the owner the users
          // "u1" and "u2" should not be allowed to READ or WRITE, because they are not the owner of the reosource, it belong to at least one group and the resource doesn't have any groups rule security
          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());
          }
  
          
          // Update permissions for users belong to "usergroupTest1" ("u1") group
          // The effect of this service call will be: 
          // 1) The resource will be added with a group rule on usergroupTest1
          // 2) "u2" will have WRITE permission but not READ permissions
          // 3) Nothing will change for "u1"
          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());
          
          // READ shouldn't allowed, WRITE allowed
          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());
      }
test_case.class_method_signature: AdministratorGeostoreClientTest.updateSecurityRulesTest()
test_case.full_signature: @Test public void updateSecurityRulesTest()
test_case.identifier: updateSecurityRulesTest
test_case.invocations: setGroupName insertUserGroup setGroupName insertUserGroup setGroupName insertUserGroup add add createUser createUser createUserClient createUserClient createUser createDefaultCategory createAResource createAResource getResource getId fail assertEquals getStatus getResponse getResource getId fail assertEquals getStatus getResponse updateResource getId fail assertEquals getStatus getResponse updateResource getId fail assertEquals getStatus getResponse add getAllShortResource assertEquals size getList updateSecurityRules updateSecurityRules getAllShortResource assertEquals size getList getResource getId assertEquals getStatus getResponse getResource getId assertEquals getStatus getResponse updateResource getId assertEquals getStatus getResponse updateResource getId
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void updateSecurityRulesTest()
focal_class.file: src/modules/rest/client/src/main/java/it/geosolutions/geostore/services/rest/AdministratorGeoStoreClient.java
focal_class.identifier: AdministratorGeoStoreClient
focal_class.class_method_signature: AdministratorGeoStoreClient.getUser(long id)
focal_class.full_signature: public User getUser(long id)
focal_class.identifier: getUser
focal_class.modifiers: public
focal_class.parameters: (long id)
focal_class.return: User
focal_class.signature: User getUser(long id)
focal_class.class_method_signature: AdministratorGeoStoreClient.getUser(String name)
focal_class.full_signature: public User getUser(String name)
focal_class.identifier: getUser
focal_class.modifiers: public
focal_class.parameters: (String name)
focal_class.return: User
focal_class.signature: User getUser(String name)
focal_class.class_method_signature: AdministratorGeoStoreClient.getUser(long id, Boolean includeAttributes)
focal_class.full_signature: public User getUser(long id, Boolean includeAttributes)
focal_class.identifier: getUser
focal_class.modifiers: public
focal_class.parameters: (long id, Boolean includeAttributes)
focal_class.return: User
focal_class.signature: User getUser(long id, Boolean includeAttributes)
focal_class.class_method_signature: AdministratorGeoStoreClient.getUsers()
focal_class.full_signature: public UserList getUsers()
focal_class.identifier: getUsers
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: UserList
focal_class.signature: UserList getUsers()
focal_class.class_method_signature: AdministratorGeoStoreClient.getUsers(Integer page, Integer entries)
focal_class.full_signature: public UserList getUsers(Integer page, Integer entries)
focal_class.identifier: getUsers
focal_class.modifiers: public
focal_class.parameters: (Integer page, Integer entries)
focal_class.return: UserList
focal_class.signature: UserList getUsers(Integer page, Integer entries)
focal_class.class_method_signature: AdministratorGeoStoreClient.getUserDetails()
focal_class.full_signature: public User getUserDetails()
focal_class.identifier: getUserDetails
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: User
focal_class.signature: User getUserDetails()
focal_class.class_method_signature: AdministratorGeoStoreClient.insert(User user)
focal_class.full_signature: public Long insert(User user)
focal_class.identifier: insert
focal_class.modifiers: public
focal_class.parameters: (User user)
focal_class.return: Long
focal_class.signature: Long insert(User user)
focal_class.class_method_signature: AdministratorGeoStoreClient.deleteUser(Long id)
focal_class.full_signature: public void deleteUser(Long id)
focal_class.identifier: deleteUser
focal_class.modifiers: public
focal_class.parameters: (Long id)
focal_class.return: void
focal_class.signature: void deleteUser(Long id)
focal_class.class_method_signature: AdministratorGeoStoreClient.update(Long id, User user)
focal_class.full_signature: public void update(Long id, User user)
focal_class.identifier: update
focal_class.modifiers: public
focal_class.parameters: (Long id, User user)
focal_class.return: void
focal_class.signature: void update(Long id, User user)
focal_class.class_method_signature: AdministratorGeoStoreClient.insertUserGroup(UserGroup usergroup)
focal_class.full_signature: public long insertUserGroup(UserGroup usergroup)
focal_class.identifier: insertUserGroup
focal_class.modifiers: public
focal_class.parameters: (UserGroup usergroup)
focal_class.return: long
focal_class.signature: long insertUserGroup(UserGroup usergroup)
focal_class.class_method_signature: AdministratorGeoStoreClient.deleteUserGroup(long usergroupId)
focal_class.full_signature: public void deleteUserGroup(long usergroupId)
focal_class.identifier: deleteUserGroup
focal_class.modifiers: public
focal_class.parameters: (long usergroupId)
focal_class.return: void
focal_class.signature: void deleteUserGroup(long usergroupId)
focal_class.class_method_signature: AdministratorGeoStoreClient.assignUserGroup(long userId, long usergroupId)
focal_class.full_signature: public void assignUserGroup(long userId, long usergroupId)
focal_class.identifier: assignUserGroup
focal_class.modifiers: public
focal_class.parameters: (long userId, long usergroupId)
focal_class.return: void
focal_class.signature: void assignUserGroup(long userId, long usergroupId)
focal_class.class_method_signature: AdministratorGeoStoreClient.deassignUserGroup(long userId, long usergroupId)
focal_class.full_signature: public void deassignUserGroup(long userId, long usergroupId)
focal_class.identifier: deassignUserGroup
focal_class.modifiers: public
focal_class.parameters: (long userId, long usergroupId)
focal_class.return: void
focal_class.signature: void deassignUserGroup(long userId, long usergroupId)
focal_class.class_method_signature: AdministratorGeoStoreClient.getUserGroup(long usergroupId)
focal_class.full_signature: public RESTUserGroup getUserGroup(long usergroupId)
focal_class.identifier: getUserGroup
focal_class.modifiers: public
focal_class.parameters: (long usergroupId)
focal_class.return: RESTUserGroup
focal_class.signature: RESTUserGroup getUserGroup(long usergroupId)
focal_class.class_method_signature: AdministratorGeoStoreClient.getUserGroups(Integer page, Integer entries, boolean all)
focal_class.full_signature: public UserGroupList getUserGroups(Integer page, Integer entries, boolean all)
focal_class.identifier: getUserGroups
focal_class.modifiers: public
focal_class.parameters: (Integer page, Integer entries, boolean all)
focal_class.return: UserGroupList
focal_class.signature: UserGroupList getUserGroups(Integer page, Integer entries, boolean all)
focal_class.class_method_signature: AdministratorGeoStoreClient.updateSecurityRules(ShortResourceList resourcesToSet, Long groupId,
              boolean canRead, boolean canWrite)
focal_class.full_signature: public ShortResourceList updateSecurityRules(ShortResourceList resourcesToSet, Long groupId,
              boolean canRead, boolean canWrite)
focal_class.identifier: updateSecurityRules
focal_class.modifiers: public
focal_class.parameters: (ShortResourceList resourcesToSet, Long groupId,
              boolean canRead, boolean canWrite)
focal_class.return: ShortResourceList
focal_class.signature: ShortResourceList updateSecurityRules(ShortResourceList resourcesToSet, Long groupId,
              boolean canRead, boolean canWrite)
focal_class.class_method_signature: AdministratorGeoStoreClient.getUserGroup(String name)
focal_class.full_signature: public RESTUserGroup getUserGroup(String name)
focal_class.identifier: getUserGroup
focal_class.modifiers: public
focal_class.parameters: (String name)
focal_class.return: RESTUserGroup
focal_class.signature: RESTUserGroup getUserGroup(String name)
focal_class.superclass: extends GeoStoreClient
focal_method.body: 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;
      }
focal_method.class_method_signature: AdministratorGeoStoreClient.updateSecurityRules(ShortResourceList resourcesToSet, Long groupId,
              boolean canRead, boolean canWrite)
focal_method.full_signature: public ShortResourceList updateSecurityRules(ShortResourceList resourcesToSet, Long groupId,
              boolean canRead, boolean canWrite)
focal_method.identifier: updateSecurityRules
focal_method.invocations: getBaseWebResource put accept header
focal_method.modifiers: public
focal_method.parameters: (ShortResourceList resourcesToSet, Long groupId,
              boolean canRead, boolean canWrite)
focal_method.return: ShortResourceList
focal_method.signature: ShortResourceList updateSecurityRules(ShortResourceList resourcesToSet, Long groupId,
              boolean canRead, boolean canWrite)