@Test
  public void testWithPermissionsFromGroupFromGroup() {
    // Given a new user without permissions nor Groups
    Permission p1 = new Permission("permission1");
    Permission p2 = new Permission("permission2");
    Permission p3 = new Permission("permission3");

    User u = new User();
    Group g1 = new Group();
    u.getGroups().add(g1);
    Group g2 = new Group();
    g1.getGroups().add(g2);

    List<Permission> lp = u.getPermissions();
    lp.add(p1);

    lp = g1.getPermissions();
    lp.add(p2);

    lp = g2.getPermissions();
    lp.add(p3);

    // When we retrieve InheritedPermission
    lp = PermissionsOwnerTools.getInheritedPermission(u);

    // There is no permissions
    Assertions.assertThat(lp.size() == 3).isTrue();
    Assertions.assertThat(lp.contains(p1)).isTrue();
    Assertions.assertThat(lp.contains(p2)).isTrue();
    Assertions.assertThat(lp.contains(p3)).isTrue();
  }
Пример #2
0
 /**
  * Gets the groups depending of the group
  *
  * @param name the name of the group to search insides groups
  * @return a list of group, in XML or JSON if the group can be found otherwise HTTP Error 404
  */
 @GET
 @Path("/name/{name}/groups")
 public List<Group> getGroupsFromGroups(@PathParam("name") String name) {
   Group g = this.service.findByName(name);
   if (g == null) {
     throw new NotFoundException();
   }
   return g.getGroups();
 }
Пример #3
0
 public Group createTestGroup() {
   Group g = new Group();
   g.setName("TestGroup" + Math.round(Math.random() * 1000));
   return g;
 }