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
@@ -144,12 +144,20 @@ class PortalProfileInstallationTest extends TestCase
$this->login($actor, false);
$this->postJson('/management/profile-install', $this->data())->assertForbidden();
$this->login($actor);
$this->postJson('/management/profile-install/bootstrap', [...$this->data(), 'first_user_id' => $actor->id, 'second_user_id' => $second->id])->assertUnprocessable();
$this->postJson('/management/profile-install/bootstrap', [...$this->data(), 'first_user_id' => $first->id, 'second_user_id' => $second->id])->assertOk()->assertJsonPath('holders', [$first->id, $second->id]);
$this->getJson('/management/profile-install')->assertForbidden();
$this->postJson('/management/profile-install/bootstrap', [...$this->data(), 'first_user_id' => $first->id, 'second_user_id' => $second->id])->assertForbidden();
$pending = $this->postJson('/management/profile-install/bootstrap', [...$this->data(), 'first_user_id' => $actor->id, 'second_user_id' => $second->id])->assertOk()->assertJsonPath('initialized', false)->assertJsonPath('privileges_granted', false)->json();
$this->assertSame(0, DB::table('portal_superuser_pair')->count());
$url = '/management/profile-install/bootstrap/'.$pending['approval_id'];
$view = $this->getJson($url)->assertOk()->json();
$this->postJson($url.'/confirm', [...$this->data(), 'hash' => $view['hash']])->assertForbidden();
$this->login($second);
$view = $this->getJson($url)->assertOk()->json();
$this->postJson($url.'/confirm', ['hash' => $view['hash'], 'confirm' => true, 'idempotency_key' => (string) Str::uuid(), 'reason' => 'Synthetic independent QA confirmation'])->assertOk()->assertJsonPath('holders', [$actor->id, $second->id]);
$this->login($first);
$this->getJson('/management/profile-install')->assertForbidden();
$this->login($actor);
$this->getJson('/management/profile-install')->assertOk()->assertJsonPath('bootstrap.initialized', true);
$this->postJson('/management/profile-install/bootstrap', [...$this->data(), 'first_user_id' => $first->id, 'second_user_id' => $actor->id])->assertConflict();
$this->postJson('/management/profile-install/bootstrap', [...$this->data(), 'first_user_id' => $actor->id, 'second_user_id' => $first->id])->assertConflict();
$this->assertSame(1, DB::table('portal_superuser_pair')->count());
$this->assertSame(0, DB::table('portal_role_assignments')->count());
$this->assertFalse(config('portal_profiles.bootstrap_authorized'));
@@ -192,13 +200,15 @@ class PortalProfileInstallationTest extends TestCase
$first = $this->actor();
$second = $this->actor();
$first->forceFill(['two_factor_secret' => 'synthetic-invalid-ciphertext'])->save();
$this->login($manager);
config(['portal.managers' => [$first->email]]);
$this->login($first);
$this->postJson('/management/profile-install/bootstrap', [...$this->data(), 'first_user_id' => $first->id, 'second_user_id' => $second->id])->assertUnprocessable();
$this->assertSame(0, DB::table('portal_superuser_pair')->count());
$first->forceFill(['two_factor_secret' => Crypt::encryptString('JBSWY3DPEHPK3PXP')])->save();
$input = [...$this->data(), 'first_user_id' => $first->id, 'second_user_id' => $second->id];
app(PortalProfileAdministration::class)->insertGrant((string) Str::uuid(), $manager, [
'user_id' => $first->id, 'role' => 'auditor', 'opportunity_types' => [], 'source' => 'unit-synthetic-fixture']);
$this->postJson('/management/profile-install/bootstrap', [...$this->data(), 'first_user_id' => $first->id, 'second_user_id' => $second->id])->assertUnprocessable();
$this->postJson('/management/profile-install/bootstrap', $input)->assertForbidden();
$this->assertSame(0, DB::table('portal_superuser_pair')->count());
$this->assertFalse(config('portal_profiles.bootstrap_authorized'));
}