fix: complete InvesteMoz validation and error corrections

This commit is contained in:
2026-10-29 21:47:33 +02:00
parent 63147312e2
commit daf8623441
718 changed files with 127308 additions and 20959 deletions
+23 -4
View File
@@ -14,6 +14,7 @@ use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Inertia\Testing\AssertableInertia as Assert;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Tests\TestCase;
class PortalProfileAccessTest extends TestCase
@@ -36,6 +37,19 @@ class PortalProfileAccessTest extends TestCase
return $user;
}
private function initializePair(User $first, User $second): void
{
$approval = (string) Str::uuid();
DB::table('portal_security_approvals')->insert([
'id' => $approval, 'kind' => 'bootstrap', 'requested_by' => $first->id,
'subject_user_id' => $second->id, 'approved_by' => $second->id,
'scope' => '{}', 'reason' => self::REASON, 'expires_at' => now()->addMinutes(15),
'created_at' => now(), 'updated_at' => now(),
]);
$this->mfa($second);
app(PortalSuperusers::class)->initialize($first, $second, $second, $approval);
}
private function organization(User ...$users): string
{
$id = (string) Str::uuid();
@@ -121,7 +135,7 @@ class PortalProfileAccessTest extends TestCase
$bootstrap = $this->actor();
config(['portal_profiles.bootstrap_authorized' => true]);
$this->mfa($bootstrap);
app(PortalSuperusers::class)->initialize($first, $second, $bootstrap);
$this->initializePair($first, $second);
$doc = (string) Str::uuid();
DB::table('documents')->insert(['id' => $doc, 'file_name' => 'synthetic-authorization-fixture.txt', 'storage_key' => 'synthetic/'.$doc,
'media_type' => 'text/plain', 'sha256' => str_repeat('b', 64), 'malware_scanned_sha256' => str_repeat('b', 64),
@@ -206,7 +220,7 @@ class PortalProfileAccessTest extends TestCase
$approver = $this->actor();
config(['portal_profiles.bootstrap_authorized' => true]);
$this->mfa($approver);
app(PortalSuperusers::class)->initialize($first, $second, $approver);
$this->initializePair($first, $second);
$promoter = $this->actor();
$assignment = $this->grant($promoter, 'promoter');
$draft = $this->draft($promoter);
@@ -233,8 +247,13 @@ class PortalProfileAccessTest extends TestCase
config(['portal_profiles.bootstrap_authorized' => true]);
$this->mfa($approver);
$service = app(PortalSuperusers::class);
$service->initialize($first, $second, $approver);
$service->initialize($first, $second, $approver);
$this->initializePair($first, $second);
try {
$this->initializePair($first, $second);
$this->fail('An existing pair must not be initialized again.');
} catch (HttpException $error) {
$this->assertSame(409, $error->getStatusCode());
}
$this->assertSame(1, DB::table('portal_superuser_pair')->count());
$this->mfa($first)->deleteJson('/user/two-factor-authentication')->assertForbidden();
$this->deleteJson('/settings/profile')->assertForbidden();