[backend] test(multi-tenancy): endpoints API for multi-tenancy (#5718)#5946
Open
damgouj wants to merge 3 commits into
Open
[backend] test(multi-tenancy): endpoints API for multi-tenancy (#5718)#5946damgouj wants to merge 3 commits into
damgouj wants to merge 3 commits into
Conversation
659056c to
0635b49
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens multi-tenant isolation for the Endpoint (asset) API by making tenant scoping explicit in repository operations and by adding regression tests that verify cross-tenant access is blocked.
Changes:
- Add tenant scoping to endpoint deletion and introduce a tenant-aware endpoint lookup repository method.
- Update
EndpointServiceand unit tests to use tenant-scoped endpoint lookups. - Add integration tests validating CRUD/search isolation across
/api/tenants/{tenantId}/endpoints/...routes.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| openaev-model/src/main/java/io/openaev/database/repository/EndpointRepository.java | Adds tenant-scoped delete native query and a tenant-aware findByIdAndTenantId lookup. |
| openaev-api/src/main/java/io/openaev/service/EndpointService.java | Switches endpoint lookup to a tenant-scoped repository call. |
| openaev-api/src/test/java/io/openaev/service/endpoint/EndpointServiceTest.java | Updates unit tests and adds tenant isolation unit coverage around tenant-scoped lookups. |
| openaev-api/src/test/java/io/openaev/rest/EndpointApiTest.java | Adds integration tests asserting endpoints are not readable/searchable/updatable across tenants. |
Comment on lines
127
to
131
| public Endpoint endpoint(@NotBlank final String endpointId) { | ||
| return this.endpointRepository | ||
| .findById(endpointId) | ||
| .findByIdAndTenantId(endpointId, TenantContext.getCurrentTenant()) | ||
| .orElseThrow(() -> new ElementNotFoundException("Endpoint not found")); | ||
| } |
| .getContentAsString(); | ||
|
|
||
| String endpointId = JsonPath.read(createResponse, "$.asset_id"); | ||
| return endpointRepository.findById(endpointId).orElseThrow(); |
Comment on lines
+239
to
+245
| void given_endpointInTenantX_should_beReadableFromTenantX() { | ||
| // -------- Prepare -------- | ||
| TenantContext.setCurrentTenant("tenant-x"); | ||
| Endpoint endpoint = new Endpoint(); | ||
| endpoint.setId("ep-tenant-x"); | ||
| when(endpointRepository.findByIdAndTenantId("ep-tenant-x", "tenant-x")) | ||
| .thenReturn(Optional.of(endpoint)); |
Member
Author
There was a problem hiding this comment.
Already clear in TenantInterceptorTest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Testing Instructions
Checklist