Skip to content

Commit

Permalink
Improve Claim experience (#2403)
Browse files Browse the repository at this point in the history
* Improve Claim experience

Signed-off-by: Aindriu Lavelle <aindriu.lavelle@aiven.io>

* Remove unnecessary boxing in parsing of an int

Signed-off-by: Aindriu Lavelle <aindriu.lavelle@aiven.io>

* Update unit tests to check if showClaimAcl is being correctly set.

Signed-off-by: Aindriu Lavelle <aindriu.lavelle@aiven.io>

---------

Signed-off-by: Aindriu Lavelle <aindriu.lavelle@aiven.io>
  • Loading branch information
aindriu-aiven authored Apr 10, 2024
1 parent 8dd2930 commit b7bb0b4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,12 @@ public List<AclRequests> selectFilteredAclRequests(

if (RequestOperationType.DELETE.value.equals(rowRequestOperationType)) {
teamId = row.getRequestingteam();
} else if (RequestOperationType.CLAIM.value.equals(rowRequestOperationType)) {

} else if (RequestOperationType.CLAIM.value.equals(rowRequestOperationType)
&& row.getApprovals().stream()
.anyMatch(approval -> requestor.equals(approval.getApproverName()))) {
// Multi Approval filtering remove this row as it is an approval that has already been
// approved by this user.
continue;
}

} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.aiven.klaw.model.enums.KafkaClustersType;
import io.aiven.klaw.model.enums.KafkaFlavors;
import io.aiven.klaw.model.enums.PromotionStatusType;
import io.aiven.klaw.model.enums.RequestStatus;
import io.aiven.klaw.model.response.AclOverviewInfo;
import io.aiven.klaw.model.response.PromotionStatus;
import io.aiven.klaw.model.response.TopicOverview;
Expand Down Expand Up @@ -260,7 +261,16 @@ protected List<AclOverviewInfo> applyFiltersAclsForSOT(
// Claim Acl is available to teams that are unable to delete the Acl as they do not own the
// ACL.
// Will need to add an extra check when an acl claim is opened.
mp.setShowClaimAcl(!mp.isShowDeleteAcl());
mp.setShowClaimAcl(
!mp.isShowDeleteAcl()
&& !manageDatabase
.getHandleDbRequests()
.existsSpecificAclRequest(
mp.getTopicname(),
RequestStatus.CREATED.value,
mp.getEnvironment(),
tenantId,
Integer.parseInt(mp.getReq_no())));
aclList.add(mp);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -735,11 +735,17 @@ public void getTopicOverviewWithNoAcls_OpenClaimRequest() {
when(handleDbRequests.existsClaimTopicRequest(
eq(TESTTOPIC), eq(RequestStatus.CREATED.value), eq(101)))
.thenReturn(true);
when(handleDbRequests.existsSpecificAclRequest(
eq(TESTTOPIC), eq(RequestStatus.CREATED.value), anyString(), eq(101), anyInt()))
.thenReturn(true);
when(kwClustersHashMap.get(anyInt())).thenReturn(kwClusters);

when(handleDbRequests.getSyncAcls(anyString(), eq(TESTTOPIC), eq(101)))
.thenReturn(getAclsSOT(TESTTOPIC));

topicOverview = topicOverviewService.getTopicOverview(TESTTOPIC, "1", AclGroupBy.NONE);

assertThat(topicOverview.getTopicInfoList().get(0).isHasACL()).isFalse(); // topic hasAcl
assertThat(topicOverview.getTopicInfoList().get(0).isHasACL()).isTrue(); // topic hasAcl

assertThat(topicOverview.getTopicInfoList().get(0).isHasOpenClaimRequest()).isTrue();

Expand All @@ -751,6 +757,9 @@ public void getTopicOverviewWithNoAcls_OpenClaimRequest() {
assertThat(topicOverview.getTopicInfoList().get(0).isHasOpenRequestOnAnyEnv())
.isTrue(); // topic hasAcl
assertThat(topicOverview.getTopicInfoList().get(0).isHasSchema()).isFalse(); // topic hasAcl
assertThat(topicOverview.getAclInfoList().get(0).isShowClaimAcl())
.isFalse(); // topic has open claim request so this can't be claimed twice. Don't offer UI
// choice to claim it.
}

@Test
Expand All @@ -767,7 +776,8 @@ public void getTopicOverviewFromDifferentTeam_OnlyReturnClaimBooleanAndOpenRequs
createListOfEnvs(KafkaClustersType.SCHEMA_REGISTRY, 5);
when(commonUtilsService.getTopicsForTopicName(anyString(), anyInt()))
.thenReturn(utilMethods.getTopicInMultipleEnvs("testtopic", TEAMID, 3));

when(manageDatabase.getClusters(any(KafkaClustersType.class), anyInt()))
.thenReturn(kwClustersHashMap);
when(kwClustersHashMap.get(anyInt())).thenReturn(kwClusters);

when(commonUtilsService.getTopicsForTopicName(anyString(), anyInt()))
Expand All @@ -780,14 +790,16 @@ public void getTopicOverviewFromDifferentTeam_OnlyReturnClaimBooleanAndOpenRequs
eq(TESTTOPIC), eq(RequestStatus.CREATED.value), eq(101)))
.thenReturn(true);
when(kwClustersHashMap.get(anyInt())).thenReturn(kwClusters);
when(handleDbRequests.getSyncAcls(anyString(), eq(TESTTOPIC), eq(101)))
.thenReturn(getAclsSOT(TESTTOPIC));

TopicOverview topicOverview =
topicOverviewService.getTopicOverview(TESTTOPIC, "1", AclGroupBy.NONE);

verify(handleDbRequests, times(0)).existsTopicRequest(any(), any(), any(), anyInt());
verify(handleDbRequests, times(0)).existsAclRequest(any(), any(), any(), anyInt());
verify(handleDbRequests, times(0)).existsSchemaRequest(any(), any(), any(), anyInt());
assertThat(topicOverview.getTopicInfoList().get(0).isHasACL()).isFalse(); // topic claim
assertThat(topicOverview.getTopicInfoList().get(0).isHasACL()).isTrue();

assertThat(topicOverview.getTopicInfoList().get(0).isHasOpenClaimRequest()).isTrue();
assertThat(topicOverview.getTopicInfoList().get(0).isHasOpenACLRequest()).isFalse();
Expand All @@ -796,6 +808,7 @@ public void getTopicOverviewFromDifferentTeam_OnlyReturnClaimBooleanAndOpenRequs
assertThat(topicOverview.getTopicInfoList().get(0).isHasOpenRequestOnAnyEnv())
.isTrue(); // topic hasAcl
assertThat(topicOverview.getTopicInfoList().get(0).isHasSchema()).isFalse();
assertThat(topicOverview.getAclInfoList().get(0).isShowClaimAcl()).isTrue();
}

private static Map<Integer, KwClusters> getKwClusterMap() {
Expand Down

0 comments on commit b7bb0b4

Please sign in to comment.