[backend] test(multi-tenancy): dashboards API for multi-tenancy (#5718)#5943
Open
damgouj wants to merge 6 commits into
Open
[backend] test(multi-tenancy): dashboards API for multi-tenancy (#5718)#5943damgouj wants to merge 6 commits into
damgouj wants to merge 6 commits into
Conversation
6a3f89e to
e5ebc80
Compare
Contributor
There was a problem hiding this comment.
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_idsupport forwidgets(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; |
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