fix(multi_tenancy): default and current tenant cannot be deleted (#6227)#6248
Conversation
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #6248 +/- ##
============================================
- Coverage 42.90% 42.82% -0.09%
- Complexity 6811 6847 +36
============================================
Files 2247 2253 +6
Lines 61220 61648 +428
Branches 8015 8100 +85
============================================
+ Hits 26267 26400 +133
- Misses 33272 33564 +292
- Partials 1681 1684 +3
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:
|
There was a problem hiding this comment.
Pull request overview
This PR addresses multi-tenancy hardening by (1) gating the Tenants management UI behind the MULTI_TENANCY feature flag + RBAC access, and (2) preventing deletion of the default tenant and the currently-selected tenant at the service layer, with added test coverage.
Changes:
- Frontend: deny access to the Tenants admin page when MULTI_TENANCY is disabled or the user lacks TENANTS access.
- Backend: block soft-delete of the default tenant and the current tenant; convert some tenant lifecycle errors to
BadRequestException. - Tests/UI flows: add service tests for the new soft-delete guards; adjust dialog handling around delete/reactivate flows.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| openaev-front/src/components/common/DialogConfirmation.tsx | Reworks loading/submission handling for confirmation dialogs (currently introduces async/loading correctness issues). |
| openaev-front/src/admin/components/platform/tenants/Tenants.tsx | Adds feature-flag + RBAC gating for the tenants page (currently violates Rules of Hooks due to early return). |
| openaev-front/src/admin/components/platform/tenants/TenantPopover.tsx | Ensures dialogs close in finally for delete/reactivate actions. |
| openaev-api/src/main/java/io/openaev/service/tenants/TenantService.java | Adds guards to prevent deleting default/current tenant; uses BadRequestException for user-facing invalid operations. |
| openaev-api/src/test/java/io/openaev/service/tenants/TenantServiceTest.java | Adds tests asserting deletion is blocked for default and current tenant (needs TenantContext cleanup to avoid test leakage). |
… accesible when multi-tenancy featured-flag is disabled
damgouj
left a comment
There was a problem hiding this comment.
Some remarks, don't hesitate if necessary
…needed bc the TenantInterceptorTest already does this
… is no tenant context in this case.
Description
On main, navigating to the Security settings page exposes two critical issues related to the multi-tenancy feature:
Proposed changes
https://main.oaev.staging.filigran.io/<instance-id>/admin/settings/security/tenants/Testing Instructions
If featuredFlag is enabled:
https://main.oaev.staging.filigran.io/<instance-id>/admin/settings/security/tenants/If featuredFlag is disabled:
https://main.oaev.staging.filigran.io/<instance-id>/admin/settings/security/tenants/Related issues
Checklist