From 41d71684afe634f6d4a23809c31a220f140ad95b Mon Sep 17 00:00:00 2001 From: Sriharsha Chintalapani Date: Sat, 14 Dec 2024 14:03:45 -0800 Subject: [PATCH 1/2] issue-11002: user with Delete permission not able to delete testCases --- .../service/resources/dqtests/TestCaseResource.java | 4 ++-- .../service/resources/dqtests/TestSuiteResource.java | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestCaseResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestCaseResource.java index 4e96e18eba93..ee49b6d17bb4 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestCaseResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestCaseResource.java @@ -830,7 +830,7 @@ public Response delete( String fqn) { ResourceContextInterface resourceContext = TestCaseResourceContext.builder().name(fqn).build(); OperationContext operationContext = - new OperationContext(Entity.TABLE, MetadataOperation.EDIT_TESTS); + new OperationContext(Entity.TEST_CASE, MetadataOperation.DELETE); authorizer.authorize(securityContext, operationContext, resourceContext); return deleteByName(uriInfo, securityContext, fqn, recursive, hardDelete); } @@ -854,7 +854,7 @@ public Response deleteLogicalTestCase( @PathParam("id") UUID id) { ResourceContextInterface resourceContext = TestCaseResourceContext.builder().id(id).build(); OperationContext operationContext = - new OperationContext(Entity.TEST_SUITE, MetadataOperation.EDIT_TESTS); + new OperationContext(Entity.TEST_CASE, MetadataOperation.DELETE); authorizer.authorize(securityContext, operationContext, resourceContext); DeleteResponse response = repository.deleteTestCaseFromLogicalTestSuite(testSuiteId, id); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestSuiteResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestSuiteResource.java index bc4887c1d5d0..b89e085d2f78 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestSuiteResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestSuiteResource.java @@ -689,7 +689,8 @@ public Response delete( @Parameter(description = "Id of the logical test suite", schema = @Schema(type = "UUID")) @PathParam("id") UUID id) { - OperationContext operationContext = new OperationContext(entityType, MetadataOperation.DELETE); + OperationContext operationContext = + new OperationContext(Entity.TEST_SUITE, MetadataOperation.DELETE); authorizer.authorize(securityContext, operationContext, getResourceContextById(id)); TestSuite testSuite = Entity.getEntity(Entity.TEST_SUITE, id, "*", ALL); if (Boolean.TRUE.equals(testSuite.getExecutable())) { @@ -724,7 +725,8 @@ public Response delete( @Parameter(description = "FQN of the logical test suite", schema = @Schema(type = "String")) @PathParam("name") String name) { - OperationContext operationContext = new OperationContext(entityType, MetadataOperation.DELETE); + OperationContext operationContext = + new OperationContext(Entity.TEST_SUITE, MetadataOperation.DELETE); authorizer.authorize(securityContext, operationContext, getResourceContextByName(name)); TestSuite testSuite = Entity.getEntityByName(Entity.TEST_SUITE, name, "*", ALL); if (Boolean.TRUE.equals(testSuite.getExecutable())) { From 85c9eb1858ae304a38d05ddb9ef78e581314cf45 Mon Sep 17 00:00:00 2001 From: Sriharsha Chintalapani Date: Sat, 14 Dec 2024 14:27:03 -0800 Subject: [PATCH 2/2] Fix creation of testSuite if there are conditions in policies --- .../openmetadata/service/jdbi3/TestSuiteRepository.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestSuiteRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestSuiteRepository.java index 7d4b486e8f08..63863c1e09b0 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestSuiteRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestSuiteRepository.java @@ -154,6 +154,14 @@ public void setFullyQualifiedName(TestSuite testSuite) { } } + @Override + public EntityInterface getParentEntity(TestSuite entity, String fields) { + if (entity.getExecutable()) { + return Entity.getEntity(entity.getExecutableEntityReference(), fields, ALL); + } + return null; + } + private TestSummary getTestCasesExecutionSummary(JsonObject aggregation) { // Initialize the test summary with 0 values TestSummary testSummary =