Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACS-5506 Add description and hasSubgroups to groups API #2035

Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d9fe82a
ACS-5506 Add description and hasSubgroups to groups API
MichalKinas Jul 3, 2023
4d22931
ACS-5506 Correct Nodes bean
MichalKinas Jul 4, 2023
9a11075
ACS-5506 Proper description storage
MichalKinas Jul 4, 2023
da7f187
ACS-5506 Fix saving properties
MichalKinas Jul 5, 2023
7a8cf67
ACS-5506 Test fixes
MichalKinas Jul 5, 2023
05f0df1
ACS-5506 Proper Group serialization
MichalKinas Jul 5, 2023
0b753c2
ACS-5506 Tests cleanup
MichalKinas Jul 5, 2023
effb697
ACS-5506 Tests fixes
MichalKinas Jul 6, 2023
71cbb9e
ACS-5506 Tests cleanup
MichalKinas Jul 6, 2023
ef9d724
ACS-5506 PMD fixes
MichalKinas Jul 6, 2023
4f4f7cc
ACS-5506 Tests cleanup
MichalKinas Jul 6, 2023
925a4f4
ACS-5506 Add properties to authority service
MichalKinas Jul 7, 2023
1f72faa
ACS-5506 Add proper exception handling
MichalKinas Jan 17, 2024
ecfeb77
ACS-5506 Add PMD fixes
MichalKinas Jan 17, 2024
d3c7342
ACS-5506 Description handling rework
MichalKinas Jan 30, 2024
605c3a6
ACS-5506 Add missing annotations, hasSubgroups not required
MichalKinas Jan 30, 2024
12d1ecd
ACS-5506 CR fixes applied
MichalKinas Feb 2, 2024
197acb3
ACS-5506 Add allowed methods
MichalKinas Feb 5, 2024
9ffe27f
ACS-5506 Update properties correctly
MichalKinas Feb 6, 2024
cfc0916
ACS-5506 Unit tests fixes
MichalKinas Feb 6, 2024
c537166
ACS-5506 Add temporary logging
MichalKinas Feb 6, 2024
11030f5
ACS-5506 Add temporary logging
MichalKinas Feb 6, 2024
5e85b81
ACS-5506 Cleanup and test fixes
MichalKinas Feb 8, 2024
f737c3e
ACS-5506 Test fix
MichalKinas Feb 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/
package org.alfresco.rest.model;

import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonProperty;

Expand All @@ -38,13 +38,17 @@ public class RestGroupsModel extends TestModel implements IRestModel<RestGroupsM
private String id;
@JsonProperty(required = true)
private String displayName;
@JsonProperty()
private String description;
@JsonProperty(required = true)
private Boolean isRoot;
@JsonProperty()
private Boolean hasSubgroups;

@JsonProperty("parentIds")
private ArrayList<String> parentIds;
private List<String> parentIds;
@JsonProperty("zones")
private ArrayList<String> zones;
private List<String> zones;

@JsonProperty(value = "entry")
RestGroupsModel model;
Expand Down Expand Up @@ -75,6 +79,22 @@ public void setDisplayName(String displayName)
this.displayName = displayName;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public Boolean getHasSubgroups() {
return hasSubgroups;
}

public void setHasSubgroups(Boolean hasSubgroups) {
this.hasSubgroups = hasSubgroups;
}

public Boolean getIsRoot()
{
return isRoot;
Expand All @@ -85,22 +105,22 @@ public void setIsRoot(Boolean isRoot)
this.isRoot = isRoot;
}

public ArrayList<String> getParentIds()
public List<String> getParentIds()
{
return parentIds;
}

public void setParentIds(ArrayList<String> parentIds)
public void setParentIds(List<String> parentIds)
{
this.parentIds = parentIds;
}

public ArrayList<String> getZones()
public List<String> getZones()
{
return zones;
}

public void setZones(ArrayList<String> zones)
public void setZones(List<String> zones)
{
this.zones = zones;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,44 +31,73 @@ public void dataPreparation() throws Exception
@Test(groups = { TestGroup.REST_API, TestGroup.GROUPS, TestGroup.SANITY })
@TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY,
description = "Verify creation, listing, updating and deletion of groups.")
public void createListUpdateAndDeleteGroup() throws Exception
public void createListUpdateAndDeleteGroup()
{
String groupName = "ZtestGroup" + UUID.randomUUID().toString();
JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build();
String groupName = "ZtestGroup" + UUID.randomUUID();
String subGroupName = "ZtestSubgroup" + UUID.randomUUID();
String groupDescription = "ZtestGroup description" + UUID.randomUUID();
JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).add("description", groupDescription).build();
JsonObject subgroupBody = Json.createObjectBuilder().add("id", subGroupName).add("displayName", subGroupName).build();
String groupBodyCreate = groupBody.toString();
String subgroupBodyCreate = subgroupBody.toString();

//GroupCreation:
//-ve
restClient.authenticateUser(userModel).withCoreAPI().usingGroups().createGroup(groupBodyCreate);
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN);
//+ve
restClient.authenticateUser(adminUser).withCoreAPI().usingParams("include=zones").usingGroups().createGroup(groupBodyCreate)
restClient.authenticateUser(adminUser).withCoreAPI().usingParams("include=zones,hasSubgroups,description").usingGroups().createGroup(groupBodyCreate)
.assertThat().field("zones").contains("APP.DEFAULT")
.and().field("isRoot").is(true)
.and().field("displayName").is(groupName);
.and().field("displayName").is(groupName)
.and().field("description").is(groupDescription)
.and().field("hasSubgroups").is(false);
restClient.assertStatusCodeIs(HttpStatus.CREATED);

//AddChildGroup
restClient.authenticateUser(adminUser).withCoreAPI().usingParams("include=zones").usingGroups().createGroup(subgroupBodyCreate);
restClient.assertStatusCodeIs(HttpStatus.CREATED);

//LinkChildGroupToParent
JsonObject groupMembershipGroupBody = Json.createObjectBuilder().add("id", "GROUP_"+subGroupName).add("memberType", "GROUP").build();
String groupMembershipGroupBodyCreate = groupMembershipGroupBody.toString();
restClient.authenticateUser(adminUser).withCoreAPI().usingGroups().createGroupMembership("GROUP_"+groupName, groupMembershipGroupBodyCreate);
restClient.assertStatusCodeIs(HttpStatus.CREATED);

//ListGroups:
restClient.withCoreAPI().usingParams("orderBy=displayName DESC&maxItems=10").usingGroups().listGroups()
.assertThat().entriesListContains("id", "GROUP_"+groupName)
.and().entriesListContains("id", "GROUP_"+subGroupName)
.and().entriesListDoesNotContain("zones")
.and().paginationField("maxItems").is("10");
restClient.assertStatusCodeIs(HttpStatus.OK);

groupBody = Json.createObjectBuilder().add("displayName", "Z"+groupName).build();
groupBody = Json.createObjectBuilder().add("displayName", "Z"+groupName).add("description", "Z"+groupDescription).build();
String groupBodyUpdate = groupBody.toString();
//UpdateGroup:
restClient.withCoreAPI().usingGroups().updateGroupDetails("GROUP_"+groupName, groupBodyUpdate)
restClient.withCoreAPI().usingParams("include=description").usingGroups().updateGroupDetails("GROUP_"+groupName, groupBodyUpdate)
.assertThat().field("displayName").is("Z"+groupName)
.and().field("description").is("Z"+groupDescription)
.and().field("id").is("GROUP_"+groupName)
.and().field("zones").isNull();
restClient.assertStatusCodeIs(HttpStatus.OK);

//GetGroupDetails:
restClient.withCoreAPI().usingParams("include=zones").usingGroups().getGroupDetail("GROUP_"+groupName)
restClient.withCoreAPI().usingParams("include=zones,hasSubgroups").usingGroups().getGroupDetail("GROUP_"+groupName)
.assertThat().field("id").is("GROUP_"+groupName)
.and().field("zones").contains("APP.DEFAULT")
.and().field("isRoot").is(true);
.and().field("isRoot").is(true)
.and().field("hasSubgroups").is(true);
restClient.assertStatusCodeIs(HttpStatus.OK);

//DeleteChildGroup:
restClient.authenticateUser(adminUser).withCoreAPI().usingGroups().deleteGroup("GROUP_"+subGroupName);
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);

//VerifyIfParentHasNoSubgroups:
restClient.withCoreAPI().usingParams("include=zones,hasSubgroups").usingGroups().getGroupDetail("GROUP_"+groupName)
.assertThat().field("id").is("GROUP_"+groupName)
.and().field("hasSubgroups").is(false);
restClient.assertStatusCodeIs(HttpStatus.OK);

//DeleteGroup:
Expand All @@ -83,9 +112,9 @@ public void createListUpdateAndDeleteGroup() throws Exception
@Test(groups = { TestGroup.REST_API, TestGroup.GROUPS, TestGroup.SANITY })
@TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY,
description = "Verify creation, listing(only for person) and deletion of group memberships. ")
public void createListDeleteGroupMembership() throws Exception
public void createListDeleteGroupMembership()
{
String groupName = "ZtestGroup" + UUID.randomUUID().toString();
String groupName = "ZtestGroup" + UUID.randomUUID();
JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build();
String groupBodyCreate = groupBody.toString();

Expand All @@ -95,6 +124,7 @@ public void createListDeleteGroupMembership() throws Exception

JsonObject groupMembershipBody = Json.createObjectBuilder().add("id", userModel.getUsername()).add("memberType", "PERSON").build();
String groupMembershipBodyCreate = groupMembershipBody.toString();

//MembershipCreation:
//-ve
restClient.authenticateUser(userModel).withCoreAPI().usingGroups().createGroupMembership("GROUP_"+groupName, groupMembershipBodyCreate);
Expand Down Expand Up @@ -127,7 +157,7 @@ public void createListDeleteGroupMembership() throws Exception
description = "Verify listing of group memberships.")
public void listGroupMembership() throws Exception
{
String groupName = "testGroup" + UUID.randomUUID().toString();
String groupName = "testGroup" + UUID.randomUUID();
JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build();
String groupBodyCreate = groupBody.toString();

Expand All @@ -146,12 +176,10 @@ public void listGroupMembership() throws Exception
restClient.assertStatusCodeIs(HttpStatus.CREATED);

//ListGroupMembership
RetryOperation op = new RetryOperation(){
public void execute() throws Exception{
restClient.withCoreAPI().usingGroups().listGroupMemberships("GROUP_"+groupName)
.assertThat().entriesListContains("id", userModel.getUsername());
restClient.assertStatusCodeIs(HttpStatus.OK);
}
RetryOperation op = () -> {
restClient.withCoreAPI().usingGroups().listGroupMemberships("GROUP_"+groupName)
.assertThat().entriesListContains("id", userModel.getUsername());
restClient.assertStatusCodeIs(HttpStatus.OK);
};
Utility.sleep(500, 35000, op);// Allow indexing to complete.
}
Expand Down
2 changes: 2 additions & 0 deletions remote-api/src/main/java/org/alfresco/rest/api/Groups.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ public interface Groups
{
String PARAM_ID = "id";
String PARAM_DISPLAY_NAME = "displayName";
String PARAM_INCLUDE_DESCRIPTION = "description";
String PARAM_INCLUDE_PARENT_IDS = "parentIds";
String PARAM_INCLUDE_ZONES = "zones";
String PARAM_INCLUDE_HAS_SUBGROUPS = "hasSubgroups";
String PARAM_IS_ROOT = "isRoot";
String PARAM_CASCADE = "cascade";
String PARAM_MEMBER_TYPE = "memberType";
Expand Down
Loading
Loading