Skip to content

Commit

Permalink
ACS-5506 Tests cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalKinas committed Jan 17, 2024
1 parent 8cd2416 commit 9dff65f
Showing 1 changed file with 25 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ public void dataPreparation() throws Exception
description = "Verify creation, listing, updating and deletion of groups.")
public void createListUpdateAndDeleteGroup() {
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
Expand All @@ -50,9 +53,20 @@ public void createListUpdateAndDeleteGroup() {
.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);
Expand All @@ -72,7 +86,17 @@ public void createListUpdateAndDeleteGroup() {
.assertThat().field("id").is("GROUP_"+groupName)
.and().field("zones").contains("APP.DEFAULT")
.and().field("isRoot").is(true)
.and().field("hasSubgroups").is(false);
.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").usingGroups().getGroupDetail("GROUP_"+groupName)
.assertThat().field("id").is("GROUP_"+groupName)
.and().field("hasSubgroups").is(false);
restClient.assertStatusCodeIs(HttpStatus.OK);

//DeleteGroup:
Expand All @@ -89,11 +113,8 @@ public void createListUpdateAndDeleteGroup() {
description = "Verify creation, listing(only for person) and deletion of group memberships. ")
public void createListDeleteGroupMembership() {
String groupName = "ZtestGroup" + UUID.randomUUID();
String subGroupName = "ZtestSubgroup" + UUID.randomUUID();
JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build();
JsonObject subgroupBody = Json.createObjectBuilder().add("id", subGroupName).add("displayName", subGroupName).build();
String groupBodyCreate = groupBody.toString();
String subgroupBodyCreate = subgroupBody.toString();

//GroupCreation:
restClient.authenticateUser(adminUser).withCoreAPI().usingParams("include=zones").usingGroups().createGroup(groupBodyCreate);
Expand All @@ -115,20 +136,6 @@ public void createListDeleteGroupMembership() {
.assertThat().entriesListContains("id", "GROUP_"+groupName);
restClient.assertStatusCodeIs(HttpStatus.OK);

//AddChildGroup
restClient.authenticateUser(adminUser).withCoreAPI().usingParams().usingGroups().createGroup(subgroupBodyCreate);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
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);

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

//DeleteGroupMembership
//-ve
restClient.withCoreAPI().usingGroups().deleteGroupMembership("GROUP_"+groupName, userModel.getUsername());
Expand Down

0 comments on commit 9dff65f

Please sign in to comment.