Skip to content

[backend] test(multi-tenancy): dashboards API for multi-tenancy (#5718)#5943

Open
damgouj wants to merge 6 commits into
mainfrom
issue/5718_tenant_isolation_dashboards
Open

[backend] test(multi-tenancy): dashboards API for multi-tenancy (#5718)#5943
damgouj wants to merge 6 commits into
mainfrom
issue/5718_tenant_isolation_dashboards

Conversation

@damgouj
Copy link
Copy Markdown
Member

@damgouj damgouj commented May 26, 2026

Proposed changes

  • Add tenant isolation and tests for dashboards 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

@github-actions github-actions Bot added the filigran team use to identify PR from the Filigran team label May 26, 2026
@damgouj damgouj self-assigned this May 26, 2026
@damgouj damgouj force-pushed the issue/5718_tenant_isolation_dashboards branch from 6a3f89e to e5ebc80 Compare May 26, 2026 14:04
@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 strengthens multi-tenancy isolation for the dashboards feature by tenant-scoping Widgets at the database/model layer and adding integration tests to ensure cross-tenant access is blocked.

Changes:

  • Add tenant_id support for widgets (model + Flyway migration) and enforce tenant scoping in lookups.
  • Tighten CustomDashboardRepository.findByResourceId() tenant constraints for scenario/exercise-linked dashboards.
  • Add tenant isolation integration tests for dashboards, widgets, import/export flows.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
openaev-model/src/main/java/io/openaev/database/repository/WidgetRepository.java Adds tenant-scoped lookup method for widgets.
openaev-model/src/main/java/io/openaev/database/repository/CustomDashboardRepository.java Adds tenant constraint to native findByResourceId(); adds tenant-scoped findByIdAndTenantId().
openaev-model/src/main/java/io/openaev/database/model/Widget.java Converts Widget to TenantBase, adds tenant filter + tenant relationship.
openaev-api/src/main/java/io/openaev/rest/custom_dashboard/WidgetService.java Uses tenant-scoped dashboard/widget lookups for isolation.
openaev-api/src/main/java/io/openaev/rest/custom_dashboard/CustomDashboardService.java Uses tenant-scoped dashboard lookup for isolation.
openaev-api/src/main/java/io/openaev/migration/V5_12__AddTenantToWidgets.java Adds and backfills tenant_id on widgets, adds FK + index.
openaev-api/src/test/java/io/openaev/rest/dashboard/DashboardApiTest.java Adds tenant isolation tests around custom dashboards + widget dashboard endpoints.
openaev-api/src/test/java/io/openaev/rest/custom_dashboard/CustomDashboardWidgetApiTest.java Adds tenant isolation tests around widget CRUD on tenant dashboards.
openaev-api/src/test/java/io/openaev/api/custom_dashboard/CustomDashboardApiImporterTest.java Adds tenant isolation tests for dashboard import.
openaev-api/src/test/java/io/openaev/api/custom_dashboard/CustomDashboardApiExporterTest.java Adds tenant isolation tests for dashboard export.

@JsonIgnore
private CustomDashboard customDashboard;

@ManyToOne
Comment on lines +48 to +58
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1
FROM information_schema.table_constraints
WHERE constraint_name = 'fk_widgets_tenant_id'
) THEN
ALTER TABLE widgets
ADD CONSTRAINT fk_widgets_tenant_id
FOREIGN KEY (tenant_id) REFERENCES tenants(tenant_id) ON DELETE CASCADE;
END IF;
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