Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -968,9 +968,11 @@ public Task closeTask(Task task, String user, String comment) {
* resolve the task".
*
* <p>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
Comment on lines 970 to +974
* 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
Expand Down Expand Up @@ -1073,32 +1075,7 @@ private void addIncidentEditRequests(List<AuthRequest> 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 '{}': {}",
Expand All @@ -1107,6 +1084,45 @@ private void addIncidentEditRequests(List<AuthRequest> 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<AuthRequest> buildIncidentEditRequests(TestCase testCase) {
List<AuthRequest> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,11 @@ protected static List<AuthRequest> 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<AuthRequest> buildEditAuthRequests(
ResourceContextInterface testCaseResourceContext,
ResourceContextInterface entityResourceContext) {
Expand All @@ -848,6 +853,9 @@ protected static List<AuthRequest> 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),
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -123,7 +124,10 @@ public TestCaseResource(Authorizer authorizer, Limits limits) {
@Override
protected List<MetadataOperation> 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<TestCase> {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<MetadataOperation> 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<MetadataOperation> 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<MetadataOperation> 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<AuthRequest> 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<MetadataOperation> testCaseOperations(List<AuthRequest> requests) {
List<MetadataOperation> operations = new ArrayList<>();
for (AuthRequest request : requests) {
if (Entity.TEST_CASE.equals(request.operationContext().getResource())) {
operations.addAll(request.operationContext().getOperations(request.resourceContext()));
}
}
return operations;
}
}
Original file line number Diff line number Diff line change
@@ -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<AuthRequest> requests =
TestCaseResolutionStatusResource.buildEditAuthRequests(context, context);

List<MetadataOperation> 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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
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,
Expand All @@ -44,7 +45,7 @@
} from '../../../../generated/tests/testCase';
import { TestCaseResolutionStatus } from '../../../../generated/tests/testCaseResolutionStatus';
import { TestSuite } from '../../../../generated/tests/testSuite';
import { TestCasePageTabs } from '../../../../pages/IncidentManager/IncidentManager.interface';

Check warning on line 48 in openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/DataQualityTab/DataQualityTab.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here
import { deleteEntity } from '../../../../rest/miscAPI';
import {
removeTestCaseFromTestSuite,
Expand All @@ -56,6 +57,7 @@
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';
Expand Down Expand Up @@ -132,7 +134,7 @@
hasActiveFilters = false,
emptyStateAction,
deletionMode = TEST_CASE_DELETION_MODE.HARD,
}: DataQualityTabProps) => {

Check warning on line 137 in openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/DataQualityTab/DataQualityTab.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

{"message":"Function has a complexity of 18 which is greater than 10 authorized.","cost":8,"secondaryLocations":[{"line":137,"column":24,"endLine":137,"endColumn":26,"message":"+1"},{"line":799,"column":19,"endLine":799,"endColumn":21,"message":"+1"},{"line":802,"column":41,"endLine":802,"endColumn":43,"message":"+1"},{"line":802,"column":25,"endLine":802,"endColumn":27,"message":"+1"},{"line":867,"column":38,"endLine":867,"endColumn":40,"message":"+1"},{"line":869,"column":37,"endLine":869,"endColumn":39,"message":"+1"},{"line":875,"column":43,"endLine":875,"endColumn":44,"message":"+1"},{"line":905,"column":29,"endLine":905,"endColumn":30,"message":"+1"},{"line":949,"column":36,"endLine":949,"endColumn":38,"message":"+1"},{"line":949,"column":18,"endLine":949,"endColumn":20,"message":"+1"},{"line":950,"column":25,"endLine":950,"endColumn":27,"message":"+1"},{"line":967,"column":45,"endLine":967,"endColumn":47,"message":"+1"},{"line":977,"column":27,"endLine":977,"endColumn":29,"message":"+1"},{"line":996,"column":54,"endLine":996,"endColumn":56,"message":"+1"},{"line":995,"column":28,"endLine":995,"endColumn":30,"message":"+1"},{"line":1000,"column":48,"endLine":1000,"endColumn":50,"message":"+1"},{"line":1008,"column":54,"endLine":1008,"endColumn":56,"message":"+1"},{"line":1007,"column":28,"endLine":1007,"endColumn":30,"message":"+1"}]}
const { t } = useTranslation();
const navigate = useNavigate();
const { getEntityPermissionByFqn } = usePermissionProvider();
Expand Down Expand Up @@ -329,7 +331,7 @@
});
};

const handleSortChange = (descriptor: SortDescriptor) => {

Check warning on line 334 in openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/DataQualityTab/DataQualityTab.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

{"message":"Function has a complexity of 11 which is greater than 10 authorized.","cost":1,"secondaryLocations":[{"line":334,"column":56,"endLine":334,"endColumn":58,"message":"+1"},{"line":336,"column":50,"endLine":336,"endColumn":52,"message":"+1"},{"line":339,"column":4,"endLine":339,"endColumn":6,"message":"+1"},{"line":341,"column":6,"endLine":341,"endColumn":8,"message":"+1"},{"line":351,"column":4,"endLine":351,"endColumn":6,"message":"+1"},{"line":351,"column":40,"endLine":351,"endColumn":42,"message":"+1"},{"line":356,"column":12,"endLine":356,"endColumn":13,"message":"+1"},{"line":360,"column":12,"endLine":360,"endColumn":13,"message":"+1"},{"line":363,"column":11,"endLine":363,"endColumn":13,"message":"+1"},{"line":364,"column":72,"endLine":364,"endColumn":74,"message":"+1"},{"line":364,"column":37,"endLine":364,"endColumn":39,"message":"+1"}]}
const isSameSort =
descriptor.column === sortDescriptor.column &&
descriptor.direction === sortDescriptor.direction;
Expand Down Expand Up @@ -450,7 +452,7 @@
} else {
setIsStatusLoading(false);
}
}, [testCases]);

Check warning on line 455 in openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/DataQualityTab/DataQualityTab.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

React Hook useEffect has missing dependencies: 'collectInlineIncidentStatuses' and 'fetchTestCasePermissions'. Either include them or remove the dependency array

const handleOpenBundleSuiteForm = (cases: TestCase[]) => {
setBundleSuiteFormInitialCases(cases);
Expand Down Expand Up @@ -541,8 +543,16 @@
(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 (
Expand All @@ -555,7 +565,7 @@
);
};

const renderActionsCell = (record: TestCase) => {

Check warning on line 568 in openmetadata-ui/src/main/resources/ui/src/components/Database/Profiler/DataQualityTab/DataQualityTab.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

{"message":"Function has a complexity of 16 which is greater than 10 authorized.","cost":6,"secondaryLocations":[{"line":568,"column":47,"endLine":568,"endColumn":49,"message":"+1"},{"line":569,"column":4,"endLine":569,"endColumn":6,"message":"+1"},{"line":573,"column":47,"endLine":573,"endColumn":49,"message":"+1"},{"line":580,"column":49,"endLine":580,"endColumn":51,"message":"+1"},{"line":582,"column":37,"endLine":582,"endColumn":39,"message":"+1"},{"line":585,"column":52,"endLine":585,"endColumn":54,"message":"+1"},{"line":588,"column":6,"endLine":588,"endColumn":7,"message":"+1"},{"line":592,"column":6,"endLine":592,"endColumn":7,"message":"+1"},{"line":593,"column":31,"endLine":593,"endColumn":33,"message":"+1"},{"line":596,"column":6,"endLine":596,"endColumn":7,"message":"+1"},{"line":614,"column":36,"endLine":614,"endColumn":37,"message":"+1"},{"line":619,"column":14,"endLine":619,"endColumn":15,"message":"+1"},{"line":626,"column":31,"endLine":626,"endColumn":33,"message":"+1"},{"line":631,"column":16,"endLine":631,"endColumn":17,"message":"+1"},{"line":639,"column":42,"endLine":639,"endColumn":44,"message":"+1"},{"line":654,"column":48,"endLine":654,"endColumn":50,"message":"+1"}]}
if (isPermissionLoading) {
return <Skeleton height={30} width={30} />;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,21 @@
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,
Severities,
TestCaseResolutionStatus,
} from '../../generated/tests/testCaseResolutionStatus';
import { TestCaseIncidentStatusData } from '../../pages/IncidentManager/IncidentManager.interface';

Check warning on line 34 in openmetadata-ui/src/main/resources/ui/src/components/IncidentManager/IncidentManagerTable.component.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

Pages are route-level composition modules. Move the shared implementation/type to a lower layer instead of importing a page from here
import { getEntityName } from '../../utils/EntityNameUtils';
import {
getNameFromFQN,
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';
Expand Down Expand Up @@ -87,6 +89,19 @@
}: 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
Expand All @@ -106,14 +121,14 @@
<OwnerLabel
isCompactView
className="m-0"
hasPermission={hasPermission?.EditAll && !tableDetails?.deleted}
hasPermission={hasIncidentEditPermission(hasPermission)}
multiple={{
user: false,
team: false,
}}
owners={value?.assignee ? [value.assignee] : []}
placeHolder={t('label.no-entity', {
entity: t('label.assignee'),

Check warning on line 131 in openmetadata-ui/src/main/resources/ui/src/components/IncidentManager/IncidentManagerTable.component.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

Define a constant instead of duplicating this literal 3 times
})}
tooltipText={t('label.edit-entity', {
entity: t('label.assignee'),
Expand Down Expand Up @@ -217,7 +232,7 @@
<TestCaseIncidentManagerStatus
isInline
data={record}
hasPermission={hasPermission?.EditAll && !tableDetails?.deleted}
hasPermission={hasIncidentEditPermission(hasPermission)}
onSubmit={handleStatusSubmit}
/>
)}
Expand All @@ -228,7 +243,7 @@
) : (
<Severity
isInline
hasPermission={hasPermission?.EditAll && !tableDetails?.deleted}
hasPermission={hasIncidentEditPermission(hasPermission)}
severity={record.severity}
onSubmit={(severity) => handleSeveritySubmit(record, severity)}
/>
Expand Down
Loading