## Summary
- implement Spec 179 to make tenant lifecycle, provider consent, and provider verification the primary truth axes on the targeted Filament surfaces
- demote legacy tenant app status and legacy provider status and health to diagnostic-only roles, add centralized badge mappings for provider consent and verification, and keep provider connections excluded from global search
- add the full Spec 179 artifact set under `specs/179-provider-truth-cleanup/` plus focused Pest coverage for tenant truth cleanup, provider truth cleanup, RBAC, discovery safety, and badge semantics
- fix the numeric out-of-scope tenant route regression so inaccessible `/admin/tenants/{id}` paths return `404 Not Found` instead of `500`
## Testing
- `vendor/bin/sail artisan test --compact tests/Feature/Filament/TenantLifecycleStatusDomainSeparationTest.php`
- `vendor/bin/sail artisan test --compact tests/Feature/Filament/TenantTruthCleanupSpec179Test.php`
- `vendor/bin/sail artisan test --compact tests/Feature/Filament/ProviderConnectionsDbOnlyTest.php`
- `vendor/bin/sail artisan test --compact tests/Feature/ProviderConnections/ProviderConnectionTruthCleanupSpec179Test.php`
- `vendor/bin/sail artisan test --compact tests/Feature/ProviderConnections/RequiredFiltersTest.php`
- `vendor/bin/sail artisan test --compact tests/Feature/Tenants/TenantProviderConnectionsCtaTest.php`
- `vendor/bin/sail artisan test --compact tests/Feature/Rbac/TenantResourceAuthorizationTest.php`
- `vendor/bin/sail artisan test --compact tests/Feature/ProviderConnections/ProviderConnectionListAuthorizationTest.php`
- `vendor/bin/sail artisan test --compact tests/Feature/ProviderConnections/ProviderConnectionAuthorizationTest.php`
- `vendor/bin/sail artisan test --compact tests/Feature/Rbac/AdminGlobalSearchContextSafetyTest.php`
- `vendor/bin/sail artisan test --compact tests/Feature/Filament/TenantGlobalSearchLifecycleScopeTest.php`
- `vendor/bin/sail artisan test --compact tests/Feature/Filament/TenantScopingTest.php`
- `vendor/bin/sail artisan test --compact tests/Unit/Badges/TenantBadgesTest.php`
- `vendor/bin/sail artisan test --compact tests/Unit/Badges/ProviderConnectionBadgesTest.php`
## Manual validation
- integrated-browser smoke on `/admin/tenants`, tenant detail, `/admin/provider-connections`, provider detail, and provider edit
- verified out-of-scope tenant and provider URLs return `404 Not Found` with the current session
## Notes
- branch: `179-provider-truth-cleanup`
- commit: `e54c6632`
- target: `dev`
Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #207
108 lines
4.1 KiB
PHP
108 lines
4.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Filament\Resources\EntraGroupResource;
|
|
use App\Filament\Resources\OperationRunResource;
|
|
use App\Filament\Resources\PolicyResource;
|
|
use App\Filament\Resources\PolicyVersionResource;
|
|
use App\Filament\Resources\ProviderConnectionResource;
|
|
use App\Filament\Resources\TenantResource;
|
|
use App\Models\EntraGroup;
|
|
use App\Models\Policy;
|
|
use App\Models\PolicyVersion;
|
|
use App\Models\Tenant;
|
|
use App\Support\WorkspaceIsolation\TenantOwnedModelFamilies;
|
|
use App\Support\Workspaces\WorkspaceContext;
|
|
use Filament\Facades\Filament;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
function adminGlobalSearchTitles($results): array
|
|
{
|
|
return collect($results)->map(fn ($result): string => (string) $result->title)->all();
|
|
}
|
|
|
|
it('does not collapse administratively discoverable tenant results because remembered tenant context is selector-ineligible', function (): void {
|
|
$activeTenant = Tenant::factory()->active()->create(['name' => 'Search Safety Active']);
|
|
[$user, $activeTenant] = createUserWithTenant(tenant: $activeTenant, role: 'owner');
|
|
|
|
$onboardingTenant = Tenant::factory()->onboarding()->create([
|
|
'workspace_id' => (int) $activeTenant->workspace_id,
|
|
'name' => 'Search Safety Onboarding',
|
|
]);
|
|
|
|
createUserWithTenant(tenant: $onboardingTenant, user: $user, role: 'owner', ensureDefaultMicrosoftProviderConnection: false);
|
|
|
|
$this->actingAs($user);
|
|
|
|
Filament::setCurrentPanel('admin');
|
|
Filament::setTenant(null, true);
|
|
Filament::bootCurrentPanel();
|
|
|
|
session()->put(WorkspaceContext::SESSION_KEY, (int) $activeTenant->workspace_id);
|
|
session()->put(WorkspaceContext::LAST_TENANT_IDS_SESSION_KEY, [
|
|
(string) $activeTenant->workspace_id => (int) $onboardingTenant->getKey(),
|
|
]);
|
|
|
|
expect(adminGlobalSearchTitles(TenantResource::getGlobalSearchResults('Search Safety')))
|
|
->toEqualCanonicalizing([
|
|
'Search Safety Active',
|
|
'Search Safety Onboarding',
|
|
]);
|
|
});
|
|
|
|
it('keeps operation runs out of admin global search regardless of remembered context state', function (): void {
|
|
expect(OperationRunResource::canGloballySearch())->toBeFalse()
|
|
->and(ProviderConnectionResource::canGloballySearch())->toBeFalse();
|
|
});
|
|
|
|
it('keeps representative first-slice admin global-search behavior aligned to the family registry postures', function (): void {
|
|
$tenantA = Tenant::factory()->create();
|
|
[$user, $tenantA] = createUserWithTenant(tenant: $tenantA, role: 'owner');
|
|
|
|
$tenantB = Tenant::factory()->create([
|
|
'workspace_id' => (int) $tenantA->workspace_id,
|
|
]);
|
|
|
|
createUserWithTenant(tenant: $tenantB, user: $user, role: 'owner');
|
|
|
|
EntraGroup::factory()->for($tenantA)->create([
|
|
'display_name' => 'Registry Search Group',
|
|
]);
|
|
|
|
EntraGroup::factory()->for($tenantB)->create([
|
|
'display_name' => 'Registry Search Group',
|
|
]);
|
|
|
|
$policy = Policy::factory()->for($tenantA)->create([
|
|
'display_name' => 'Registry Search Policy',
|
|
]);
|
|
|
|
PolicyVersion::factory()->for($tenantA)->for($policy)->create([
|
|
'version_number' => 77,
|
|
]);
|
|
|
|
$this->actingAs($user);
|
|
|
|
Filament::setCurrentPanel('admin');
|
|
Filament::setTenant(null, true);
|
|
Filament::bootCurrentPanel();
|
|
|
|
session()->put(WorkspaceContext::SESSION_KEY, (int) $tenantA->workspace_id);
|
|
session()->put(WorkspaceContext::LAST_TENANT_IDS_SESSION_KEY, [
|
|
(string) $tenantA->workspace_id => (int) $tenantA->getKey(),
|
|
]);
|
|
|
|
expect(TenantOwnedModelFamilies::searchPostureForModel(EntraGroup::class))->toBe('scoped');
|
|
expect(TenantOwnedModelFamilies::searchPostureForModel(Policy::class))->toBe('disabled');
|
|
expect(TenantOwnedModelFamilies::searchPostureForModel(PolicyVersion::class))->toBe('disabled');
|
|
|
|
expect(adminGlobalSearchTitles(EntraGroupResource::getGlobalSearchResults('Registry Search')))
|
|
->toBe(['Registry Search Group']);
|
|
|
|
expect(PolicyResource::getGlobalSearchResults('Registry Search Policy'))->toHaveCount(0);
|
|
expect(PolicyVersionResource::getGlobalSearchResults('77'))->toHaveCount(0);
|
|
});
|