diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TaskRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TaskRepository.java index 3f4d6f53e014..b06e5ac18083 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TaskRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TaskRepository.java @@ -968,9 +968,11 @@ public Task closeTask(Task task, String user, String comment) { * resolve the task". * *

For incident-style tasks ({@code TestCaseResolution}, {@code IncidentResolution}) a - * fallback is permitted: a non-filer user with {@code EditTests}/{@code EditAll} on the related - * entity can resolve the task even if the task policy alone would deny — preserving the - * historical behaviour that test owners can act on incidents. The filer check is intentional: + * fallback is permitted: a non-filer user with {@code EditStatus}, {@code EditTests} or + * {@code EditAll} on the related entity can resolve the task even if the task policy alone would + * deny — preserving the historical behaviour that test owners can act on incidents, and letting + * {@code EditStatus} alone grant incident management without test case edit rights. The filer + * check is intentional: * mixing the task policy and the incident fallback in a single {@code AuthorizationLogic.ANY} * call would let a filer who also owns the related entity bypass the {@code isTaskFiler()} deny * rule and approve their own task. The two checks are therefore evaluated sequentially with the @@ -1073,32 +1075,7 @@ private void addIncidentEditRequests(List requests, Task task) { if (testCase == null) { return; } - ResourceContextInterface testCaseResourceContext = - TestCaseResourceContext.builder().name(testCase.getFullyQualifiedName()).build(); - EntityLink entityLink = MessageParser.EntityLink.parse(testCase.getEntityLink()); - ResourceContextInterface entityResourceContext = - entityLink != null - ? TestCaseResourceContext.builder().entityLink(entityLink).build() - : TestCaseResourceContext.builder().build(); - - if (entityLink != null) { - requests.add( - new AuthRequest( - new OperationContext(entityLink.getEntityType(), MetadataOperation.EDIT_TESTS), - entityResourceContext)); - requests.add( - new AuthRequest( - new OperationContext(entityLink.getEntityType(), MetadataOperation.EDIT_ALL), - entityResourceContext)); - } - requests.add( - new AuthRequest( - new OperationContext(Entity.TEST_CASE, MetadataOperation.EDIT_TESTS), - testCaseResourceContext)); - requests.add( - new AuthRequest( - new OperationContext(Entity.TEST_CASE, MetadataOperation.EDIT_ALL), - testCaseResourceContext)); + requests.addAll(buildIncidentEditRequests(testCase)); } catch (Exception e) { LOG.warn( "[TaskRepository] Failed to build incident permission fallback for task '{}': {}", @@ -1107,6 +1084,45 @@ private void addIncidentEditRequests(List requests, Task task) { } } + /** + * Auth requests accepted for the task-first incident fallback. {@code EditStatus} on the test + * case is the Incident Manager grant: it lets a user drive incident transitions (status, + * severity, assignment) without holding edit rights on the test case itself. The historical + * {@code EditTests}/{@code EditAll} grants — on the test case and on the entity under test — + * remain accepted. + */ + static List buildIncidentEditRequests(TestCase testCase) { + List requests = new ArrayList<>(); + ResourceContextInterface testCaseResourceContext = + TestCaseResourceContext.builder().name(testCase.getFullyQualifiedName()).build(); + EntityLink entityLink = MessageParser.EntityLink.parse(testCase.getEntityLink()); + if (entityLink != null) { + ResourceContextInterface entityResourceContext = + TestCaseResourceContext.builder().entityLink(entityLink).build(); + requests.add( + new AuthRequest( + new OperationContext(entityLink.getEntityType(), MetadataOperation.EDIT_TESTS), + entityResourceContext)); + requests.add( + new AuthRequest( + new OperationContext(entityLink.getEntityType(), MetadataOperation.EDIT_ALL), + entityResourceContext)); + } + requests.add( + new AuthRequest( + new OperationContext(Entity.TEST_CASE, MetadataOperation.EDIT_STATUS), + testCaseResourceContext)); + requests.add( + new AuthRequest( + new OperationContext(Entity.TEST_CASE, MetadataOperation.EDIT_TESTS), + testCaseResourceContext)); + requests.add( + new AuthRequest( + new OperationContext(Entity.TEST_CASE, MetadataOperation.EDIT_ALL), + testCaseResourceContext)); + return requests; + } + private void validateUnderlyingEntityPermission( Authorizer authorizer, SecurityContext securityContext, Task task) { EntityReference about = task.getAbout(); diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestCaseResolutionStatusResource.java b/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestCaseResolutionStatusResource.java index be192b91c501..1116e6ebc9bc 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestCaseResolutionStatusResource.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestCaseResolutionStatusResource.java @@ -839,6 +839,11 @@ protected static List buildViewAuthRequests( entityResourceContext)); } + /** + * Incident writes are allowed for {@code EditStatus} on the test case in addition to the + * historical {@code EditTests}/{@code EditAll} grants, so that a role can manage incidents + * (status, severity, assignment) without edit rights on the test case itself. + */ protected static List buildEditAuthRequests( ResourceContextInterface testCaseResourceContext, ResourceContextInterface entityResourceContext) { @@ -848,6 +853,9 @@ protected static List buildEditAuthRequests( entityResourceContext), new AuthRequest( new OperationContext(Entity.TABLE, MetadataOperation.EDIT_ALL), entityResourceContext), + new AuthRequest( + new OperationContext(Entity.TEST_CASE, MetadataOperation.EDIT_STATUS), + testCaseResourceContext), new AuthRequest( new OperationContext(Entity.TEST_CASE, MetadataOperation.EDIT_TESTS), testCaseResourceContext), 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 54a15046b0f9..b299dc2024d9 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 @@ -1,5 +1,6 @@ package org.openmetadata.service.resources.dqtests; +import static org.openmetadata.common.utils.CommonUtil.listOf; import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty; import static org.openmetadata.schema.type.EventType.ENTITY_NO_CHANGE; import static org.openmetadata.schema.type.Include.ALL; @@ -123,7 +124,10 @@ public TestCaseResource(Authorizer authorizer, Limits limits) { @Override protected List getEntitySpecificOperations() { addViewOperation("testSuite,testDefinition", MetadataOperation.VIEW_BASIC); - return null; + // EditStatus governs the Incident Manager (test case resolution status, severity and incident + // assignment). It is advertised separately from EditTests/EditAll so that a role can grant + // incident management without granting edit rights on the test case itself. + return listOf(MetadataOperation.EDIT_STATUS); } public static class TestCaseList extends ResultList { diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/TaskRepositoryIncidentAuthRequestsTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/TaskRepositoryIncidentAuthRequestsTest.java new file mode 100644 index 000000000000..9f5934fff101 --- /dev/null +++ b/openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/TaskRepositoryIncidentAuthRequestsTest.java @@ -0,0 +1,80 @@ +/* + * Copyright 2026 Collate + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openmetadata.service.jdbi3; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.ArrayList; +import java.util.List; +import org.junit.jupiter.api.Test; +import org.openmetadata.schema.tests.TestCase; +import org.openmetadata.schema.type.MetadataOperation; +import org.openmetadata.service.Entity; +import org.openmetadata.service.security.AuthRequest; + +class TaskRepositoryIncidentAuthRequestsTest { + + private static final String TABLE_LINK = "<#E::table::svc.db.schema.orders>"; + + @Test + void incident_fallback_requests_accept_edit_status_on_test_case() { + List testCaseOperations = testCaseOperations(incidentRequests()); + + assertTrue( + testCaseOperations.contains(MetadataOperation.EDIT_STATUS), + "EditStatus on testCase must authorize the task incident fallback"); + } + + @Test + void incident_fallback_requests_keep_legacy_test_case_edit_grants() { + List testCaseOperations = testCaseOperations(incidentRequests()); + + assertTrue( + testCaseOperations.contains(MetadataOperation.EDIT_TESTS) + && testCaseOperations.contains(MetadataOperation.EDIT_ALL), + "EditTests/EditAll on testCase must keep authorizing the task incident fallback"); + } + + @Test + void incident_fallback_requests_keep_grants_on_the_entity_under_test() { + List tableOperations = new ArrayList<>(); + for (AuthRequest request : incidentRequests()) { + if (Entity.TABLE.equals(request.operationContext().getResource())) { + tableOperations.addAll(request.operationContext().getOperations(request.resourceContext())); + } + } + + assertTrue( + tableOperations.contains(MetadataOperation.EDIT_TESTS) + && tableOperations.contains(MetadataOperation.EDIT_ALL), + "EditTests/EditAll on the entity under test must keep authorizing the incident fallback"); + } + + private static List incidentRequests() { + TestCase testCase = + new TestCase() + .withFullyQualifiedName("svc.db.schema.orders.column_values_to_be_not_null") + .withEntityLink(TABLE_LINK); + return TaskRepository.buildIncidentEditRequests(testCase); + } + + private static List testCaseOperations(List requests) { + List operations = new ArrayList<>(); + for (AuthRequest request : requests) { + if (Entity.TEST_CASE.equals(request.operationContext().getResource())) { + operations.addAll(request.operationContext().getOperations(request.resourceContext())); + } + } + return operations; + } +} diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/resources/dqtests/TestCaseResolutionStatusAuthRequestsTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/resources/dqtests/TestCaseResolutionStatusAuthRequestsTest.java new file mode 100644 index 000000000000..f38ed938469e --- /dev/null +++ b/openmetadata-service/src/test/java/org/openmetadata/service/resources/dqtests/TestCaseResolutionStatusAuthRequestsTest.java @@ -0,0 +1,46 @@ +/* + * Copyright 2026 Collate + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openmetadata.service.resources.dqtests; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.ArrayList; +import java.util.List; +import org.junit.jupiter.api.Test; +import org.openmetadata.schema.type.MetadataOperation; +import org.openmetadata.service.Entity; +import org.openmetadata.service.security.AuthRequest; +import org.openmetadata.service.security.policyevaluator.ResourceContextInterface; +import org.openmetadata.service.security.policyevaluator.TestCaseResourceContext; + +class TestCaseResolutionStatusAuthRequestsTest { + + @Test + void edit_auth_requests_accept_edit_status_on_test_case() { + ResourceContextInterface context = TestCaseResourceContext.builder().build(); + List requests = + TestCaseResolutionStatusResource.buildEditAuthRequests(context, context); + + List testCaseOperations = new ArrayList<>(); + for (AuthRequest request : requests) { + if (Entity.TEST_CASE.equals(request.operationContext().getResource())) { + testCaseOperations.addAll( + request.operationContext().getOperations(request.resourceContext())); + } + } + + assertTrue( + testCaseOperations.contains(MetadataOperation.EDIT_STATUS), + "EditStatus on testCase must authorize incident writes"); + } +} diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/DataQualityTab/DataQualityTab.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/DataQualityTab/DataQualityTab.tsx index 0490218a6a17..dc3aac390d55 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/DataQualityTab/DataQualityTab.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/DataQualityTab/DataQualityTab.tsx @@ -37,6 +37,7 @@ import { usePermissionProvider } from '../../../../context/PermissionProvider/Pe import { ResourceEntity } from '../../../../context/PermissionProvider/PermissionProvider.interface'; import { SORT_ORDER } from '../../../../enums/common.enum'; import { EntityTabs, EntityType } from '../../../../enums/entity.enum'; +import { Operation } from '../../../../generated/entity/policies/policy'; import { TestCase, TestCaseResult, @@ -56,6 +57,7 @@ import { getColumnNameFromEntityLink } from '../../../../utils/EntityPureUtils'; import { getEntityFQN } from '../../../../utils/FeedUtilsPure'; import { getNameFromFQN } from '../../../../utils/FqnUtils'; import observabilityRouterClassBase from '../../../../utils/ObservabilityRouterClassBase'; +import { getPrioritizedEditPermission } from '../../../../utils/PermissionsUtils'; import { getEntityDetailsPath } from '../../../../utils/RouterUtils'; import { replacePlus } from '../../../../utils/StringUtils'; import { showErrorToast, showSuccessToast } from '../../../../utils/ToastUtils'; @@ -541,8 +543,16 @@ const DataQualityTab: React.FC = ({ (permission) => permission.fullyQualifiedName === record.fullyQualifiedName ); + // Incident status is gated by `EditStatus` on the test case so that incidents can be managed + // without test case edit permissions. const hasEditPermission = Boolean( - !record.deleted && (isEditAllowed || testCasePermission?.EditAll) + !record.deleted && + (isEditAllowed || + (testCasePermission && + getPrioritizedEditPermission( + testCasePermission, + Operation.EditStatus + ))) ); return ( diff --git a/openmetadata-ui/src/main/resources/ui/src/components/IncidentManager/IncidentManagerTable.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/IncidentManager/IncidentManagerTable.component.tsx index 389b44182d30..1d5a242ea4df 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/IncidentManager/IncidentManagerTable.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/IncidentManager/IncidentManagerTable.component.tsx @@ -24,6 +24,7 @@ import { useTranslation } from 'react-i18next'; import { Link } from 'react-router-dom'; import { EntityTabs, EntityType, FqnPart } from '../../enums/entity.enum'; import { Table as TableType } from '../../generated/entity/data/table'; +import { Operation } from '../../generated/entity/policies/policy'; import { EntityReference } from '../../generated/tests/testCase'; import { Assigned, @@ -37,6 +38,7 @@ import { getPartialNameFromTableFQN, } from '../../utils/FqnUtils'; import observabilityRouterClassBase from '../../utils/ObservabilityRouterClassBase'; +import { getPrioritizedEditPermission } from '../../utils/PermissionsUtils'; import { getEntityDetailsPath } from '../../utils/RouterUtils'; import DateTimeDisplay from '../common/DateTimeDisplay/DateTimeDisplay'; import NextPrevious from '../common/NextPrevious/NextPrevious'; @@ -87,6 +89,19 @@ const IncidentManagerTable = ({ }: IncidentManagerTableProps) => { const { t } = useTranslation(); + /** + * Incident actions (status, severity and assignee) are gated by `EditStatus` on the test case + * rather than `EditAll`, so a role can manage incidents while keeping read-only access to the + * test cases themselves. `getPrioritizedEditPermission` falls back to `EditAll` when the + * permission payload does not carry `EditStatus`. + */ + const hasIncidentEditPermission = (permission?: TestCasePermission) => + Boolean( + permission && + getPrioritizedEditPermission(permission, Operation.EditStatus) && + !tableDetails?.deleted + ); + const testCaseResolutionStatusDetailsRender = ( value?: Assigned, record?: TestCaseResolutionStatus @@ -106,7 +121,7 @@ const IncidentManagerTable = ({ )} @@ -228,7 +243,7 @@ const IncidentManagerTable = ({ ) : ( handleSeveritySubmit(record, severity)} />