## Summary - consolidate internal platform naming from `Tenant` to `Environment` / `ManagedEnvironment` across models, controllers, services, and Filament resources - rename environment-scoped UI surfaces such as dashboards, chooser flows, navigation, and related widgets to match the updated environment-first domain language - align middleware, onboarding/review lifecycle services, jobs, and route/context controllers with the new environment-scoped architecture ## Validation - not rerun as part of this commit/push/PR request ## Notes - branch is 1 commit ahead of `platform-dev` - main commit: `refactor: consolidate internal tenant model naming` Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #355
56 lines
2.0 KiB
PHP
56 lines
2.0 KiB
PHP
<?php
|
|
|
|
use App\Models\AuditLog;
|
|
use App\Models\User;
|
|
use App\Models\WorkspaceMembership;
|
|
use App\Services\Auth\ManagedEnvironmentMembershipManager;
|
|
use App\Support\Audit\AuditActionId;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
it('writes audit logs for environment access scope grant and remove without sensitive fields', function () {
|
|
[$actor, $tenant] = createUserWithTenant(role: 'owner');
|
|
$member = User::factory()->create();
|
|
WorkspaceMembership::factory()->create([
|
|
'workspace_id' => (int) $tenant->workspace_id,
|
|
'user_id' => (int) $member->getKey(),
|
|
'role' => 'readonly',
|
|
]);
|
|
|
|
$manager = app(ManagedEnvironmentMembershipManager::class);
|
|
|
|
$membership = $manager->addMember($tenant, $actor, $member, 'readonly');
|
|
$manager->removeMember($tenant, $actor, $membership);
|
|
|
|
$actions = AuditLog::query()
|
|
->where('managed_environment_id', $tenant->getKey())
|
|
->whereIn('action', [
|
|
AuditActionId::ManagedEnvironmentAccessScopeGrant->value,
|
|
AuditActionId::ManagedEnvironmentAccessScopeRemove->value,
|
|
])
|
|
->pluck('action')
|
|
->all();
|
|
|
|
expect($actions)->toContain(AuditActionId::ManagedEnvironmentAccessScopeGrant->value);
|
|
expect($actions)->toContain(AuditActionId::ManagedEnvironmentAccessScopeRemove->value);
|
|
|
|
$metadata = AuditLog::query()
|
|
->where('managed_environment_id', $tenant->getKey())
|
|
->whereIn('action', [
|
|
AuditActionId::ManagedEnvironmentAccessScopeGrant->value,
|
|
AuditActionId::ManagedEnvironmentAccessScopeRemove->value,
|
|
])
|
|
->get()
|
|
->pluck('metadata')
|
|
->all();
|
|
|
|
foreach ($metadata as $entry) {
|
|
expect($entry)->toBeArray();
|
|
expect(array_key_exists('app_client_secret', $entry))->toBeFalse();
|
|
expect(array_key_exists('client_secret', $entry))->toBeFalse();
|
|
expect(array_key_exists('refresh_token', $entry))->toBeFalse();
|
|
expect(array_key_exists('access_token', $entry))->toBeFalse();
|
|
}
|
|
});
|