fix(api): restrict deprecated endpoint jobs-by-reference API to JOB resource - #8013
Conversation
…rce (#322) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
📖 Documentation check — ✅ Passed 1 functional file(s), 0 doc file(s) changed. No documentation gaps detected. |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
One or more issues must be addressed before approval.
Pull request overview
This PR restricts the deprecated endpoint job retrieval API to the agent runtime capability instead of general asset access.
Changes:
- Changed the endpoint authorization resource from
ASSETtoJOB. - Added regression tests for allowed and denied capability combinations.
File summaries
| File | Description |
|---|---|
| openaev-api/src/test/java/io/openaev/service/account/AgentRuntimeAccessControlTest.java | Updated as part of this pull request. |
| openaev-api/src/main/java/io/openaev/rest/asset/endpoint/EndpointApi.java | Updated as part of this pull request. |
Review details
Suppressed comments (1)
openaev-api/src/test/java/io/openaev/service/account/AgentRuntimeAccessControlTest.java:187
- issue (blocking): This regression test does not exercise the old authorization path:
ResourceType.ASSET+READresolves toACCESS_ASSETS, but the mock user only hasMANAGE_ASSETS, so the old code would already return 403 and this test would pass before the fix. GrantACCESS_ASSETS(or both asset capabilities) and rename the test accordingly so it fails with the previous annotation.
@DisplayName("should be forbidden with only MANAGE_ASSETS capability")
@WithMockUser(withCapabilities = {Capability.MANAGE_ASSETS})
void given_manageAssetsOnly_should_forbidJobsByExternalReference() throws Exception {
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project check has failed because the head coverage (11.57%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #8013 +/- ##
============================================
- Coverage 47.12% 46.97% -0.16%
- Complexity 12509 13000 +491
============================================
Files 3053 3033 -20
Lines 101872 103431 +1559
Branches 16510 16751 +241
============================================
+ Hits 48006 48582 +576
- Misses 49984 51031 +1047
+ Partials 3882 3818 -64
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Proposed changes
EndpointApi.java— changed@AccessControlon the deprecatedGET /endpoints/jobs/{endpointExternalReference}fromresourceType = ResourceType.ASSETtoresourceType = ResourceType.JOB, so the required capability becomesAGENT_RUNTIME_ACCESSinstead ofACCESS_ASSETS. The endpoint returnsAssetAgentJobentries which can carry agent tokens; gating it onASSETopened it to any asset-management user instead of just agents/service accounts.AgentRuntimeAccessControlTest.java— added aGetEndpointJobsByExternalReferencenested test class covering: forbidden with onlyMANAGE_ASSETS, allowed withAGENT_RUNTIME_ACCESS(proves old agents can still call this deprecated API to complete their upgrade), and forbidden with no capability.Testing Instructions
see with Hedi (@heditar)
Related issues
Checklist