diff --git a/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/SelectDataJdbc.java b/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/SelectDataJdbc.java index 6901953732..9de445577b 100644 --- a/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/SelectDataJdbc.java +++ b/core/src/main/java/io/aiven/klaw/helpers/db/rdbms/SelectDataJdbc.java @@ -186,8 +186,12 @@ public List 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 { diff --git a/core/src/main/java/io/aiven/klaw/service/BaseOverviewService.java b/core/src/main/java/io/aiven/klaw/service/BaseOverviewService.java index 3c1444181d..2ef97ff059 100644 --- a/core/src/main/java/io/aiven/klaw/service/BaseOverviewService.java +++ b/core/src/main/java/io/aiven/klaw/service/BaseOverviewService.java @@ -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; @@ -260,7 +261,16 @@ protected List 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); } } diff --git a/core/src/test/java/io/aiven/klaw/service/TopicOverviewServiceTest.java b/core/src/test/java/io/aiven/klaw/service/TopicOverviewServiceTest.java index c4f230ddd5..88d1edb931 100644 --- a/core/src/test/java/io/aiven/klaw/service/TopicOverviewServiceTest.java +++ b/core/src/test/java/io/aiven/klaw/service/TopicOverviewServiceTest.java @@ -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(); @@ -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 @@ -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())) @@ -780,6 +790,8 @@ 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); @@ -787,7 +799,7 @@ public void getTopicOverviewFromDifferentTeam_OnlyReturnClaimBooleanAndOpenRequs 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(); @@ -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 getKwClusterMap() {