Repository navigation
Fixes 36581: Authorize a non-admin PUT of a new test case - #36590
Conversation
PUT /v1/dataQuality/testCases authorized CREATE and EDIT_ALL on a context that loads the test case by name. Since AuthorizationLogic.ANY evaluates every request, a non-admin PUT of a new test case failed with 404 from that lookup. Ask for CREATE against the request for a new test case and EDIT_ALL for an existing one, using the FQN the repository stores.
prepare creates the table's test suite when it is missing, so it must not run for a caller the PUT refuses. Set only the FQN before authorizing. Cover a Create-only and an EditAll-only caller on test cases.
Only a new test case changes how it is authorized. An existing one is checked as before, the same way ODCSTestCaseWriteGuard checks an update.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
| // Only the FQN before authorizing: prepare creates the table's test suite if it is missing. | ||
| repository.setFullyQualifiedName(test); | ||
| OperationContext tableOpContext = | ||
| new OperationContext(Entity.TABLE, MetadataOperation.EDIT_TESTS); |
There was a problem hiding this comment.
We need to apply the same logic here too -- if we create do you have createTest on table resource if we edit do you have edittest on table resource
There was a problem hiding this comment.
Done in 53af873: a create now checks CreateTests on the table, an update EditTests, the same request sets as ODCSTestCaseWriteGuard. The IT covers both directions (CreateTests creates but can't update, EditTests updates but can't create).
Creating needs CreateTests on the table, as POST does, and updating needs EditTests, the same request sets ODCSTestCaseWriteGuard uses.
…port Both build their create and update request sets from TestCaseWriteAuthRequests, and the rule is recorded in a decision record.
Code Review ✅ Approved 2 closed / 2 findings🔴 High risk · Changing test-case PUT authorization grants create and update paths different permissions; a faulty check could allow unauthorized writes to data-quality tests. Fixes non-admin PUT of new test cases failing with a 404 by building test-case write authorization from a shared helper, ✅ 2 closed✅ Quality: PUT-create no longer accepts table EditTests; rule is not recorded
✅ Quality: PUT auth request sets duplicate ODCSTestCaseWriteGuard and can drift
VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
🚦 Removed from the merge queue —
|
* Authorize a test case PUT for a test case that does not exist yet PUT /v1/dataQuality/testCases authorized CREATE and EDIT_ALL on a context that loads the test case by name. Since AuthorizationLogic.ANY evaluates every request, a non-admin PUT of a new test case failed with 404 from that lookup. Ask for CREATE against the request for a new test case and EDIT_ALL for an existing one, using the FQN the repository stores. * Authorize before preparing a test case PUT, and test each grant prepare creates the table's test suite when it is missing, so it must not run for a caller the PUT refuses. Set only the FQN before authorizing. Cover a Create-only and an EditAll-only caller on test cases. * Keep the update checks a test case PUT shared with the ODCS import guard Only a new test case changes how it is authorized. An existing one is checked as before, the same way ODCSTestCaseWriteGuard checks an update. * Check CreateTests on the table when a test case PUT creates Creating needs CreateTests on the table, as POST does, and updating needs EditTests, the same request sets ODCSTestCaseWriteGuard uses. * Share the test-case write permission sets between PUT and the ODCS import Both build their create and update request sets from TestCaseWriteAuthRequests, and the rule is recorded in a decision record.



Describe your changes:
Fixes #36581
Since #36156,
AuthorizationLogic.ANYevaluates every request.PUT /v1/dataQuality/testCasesbuilt its test-case checks on a context that loads the test case by name, so a non-admin PUT of a new test case failed with404 Entity not found: testCase …. Admins skip the authorizer, so only non-admin callers (e.g. the ingestion bot) hit it.ODCSTestCaseWriteGuardnow build their checks from one helper,TestCaseWriteAuthRequests. Creating needsCreateTestson the table orCreateon the test case, as POST does, checked against the request. Updating needsEditTestson the table, orCreateorEditAllon the existing test case.prepareInternalstill runs after authorization, because it creates the table's test suite when one is missing.Behaviour change: a role whose only grant is
EditTestson tables can no longer create a test case through PUT. It needsCreateTests, as it already did for POST. The rule is recorded in ADR:2026-10-30-a-test-case-write-is-authorized-as-a-create-or-an-update.Out of scope, and the same as before #36156: PUT-create skips
enforceLimits, which POST calls.Type of change:
High-level design:
N/A — small change.
Tests:
Backend integration tests
TestCaseCreateOrUpdateAuthorizationIT(new), each case as a non-admin with a single grant. TableCreateTestscreates a table test and a column test but can't update them. TableEditTestsupdates them but can't create one.Createon test cases creates one.EditAllupdates an existing column test. A caller with no permissions gets 403 and no test suite is created.make java_affectedpassed on 7ecbf6f. On 48f31fa:TestCaseCreateOrUpdateAuthorizationIT,TestCaseResourceIT,TestCaseResultAuthorizationIT,DataContractResourceIT,DataContractPermissionITandSubResourceAuthorizationITpass (845 tests, 0 failures).TestCaseWriteAuthRequests/ODCSTestCaseWriteGuard:CreateResourceContextneeds the live entity registry, so the ITs above cover them.Playwright (UI) tests
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.REVIEW.mdand fixed its 🔴 findings:prepareInternalhad moved before authorization, and the update checks had drifted from the ODCS guard.🤖 Generated with Claude Code