Skip to content

[backend] test(multi-tenancy): endpoints API for multi-tenancy (#5718)#5946

Open
damgouj wants to merge 3 commits into
mainfrom
issue/5718_tenant_isolation_endpoint
Open

[backend] test(multi-tenancy): endpoints API for multi-tenancy (#5718)#5946
damgouj wants to merge 3 commits into
mainfrom
issue/5718_tenant_isolation_endpoint

Conversation

@damgouj
Copy link
Copy Markdown
Member

@damgouj damgouj commented May 26, 2026

Proposed changes

  • Add tenant isolation and tests for endpoints API

Testing Instructions

  1. Check everything is working as before

Checklist

  • I consider the submitted work as finished
  • I tested the code for its functionality
  • I wrote test cases for the relevant uses case
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality
  • For bug fix -> I implemented a test that covers the bug

@damgouj damgouj self-assigned this May 26, 2026
@damgouj damgouj added the filigran team use to identify PR from the Filigran team label May 26, 2026
@damgouj damgouj force-pushed the issue/5718_tenant_isolation_endpoint branch from 659056c to 0635b49 Compare May 26, 2026 14:03
@damgouj damgouj marked this pull request as ready for review May 26, 2026 14:26
Copilot AI review requested due to automatic review settings May 26, 2026 14:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 EndpointService and 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));
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already clear in TenantInterceptorTest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

filigran team use to identify PR from the Filigran team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants