fix: validate dossier scope and accurate directory MFA status

This commit is contained in:
2026-10-29 22:42:22 +02:00
parent 4f72751b8b
commit fb9a363e9e
7 changed files with 135 additions and 5 deletions
@@ -190,9 +190,13 @@ final class OpportunityPromotionTest extends TestCase
public function test_profile_directory_uses_existing_accounts_without_exposing_authentication_secrets(): void
{
$other = User::factory()->create();
$missingSecret = User::factory()->create(['two_factor_secret' => null, 'two_factor_confirmed_at' => now()]);
$unconfirmed = User::factory()->create(['two_factor_secret' => Crypt::encryptString('SYNTHETIC-QA'), 'two_factor_confirmed_at' => null]);
DB::table('portal_superuser_pair')->updateOrInsert(['id' => 1], ['first_user_id' => $this->actor->id, 'second_user_id' => $other->id, 'approved_by' => $other->id]);
$this->get('/perfis/gestao')->assertOk()->assertInertia(fn (AssertableInertia $page) => $page
->has('staffAccounts')->where('staffAccounts', fn ($rows) => collect($rows)->contains(fn ($row) => $row['id'] === $this->actor->id && $row['email'] === $this->actor->email && $row['verified'] && $row['mfa'])
&& collect($rows)->contains(fn ($row) => $row['id'] === $missingSecret->id && $row['mfa'] === false)
&& collect($rows)->contains(fn ($row) => $row['id'] === $unconfirmed->id && $row['mfa'] === false)
&& collect($rows)->every(fn ($row) => ! isset($row['password']) && ! isset($row['two_factor_secret']))));
}
}