@@ -20,6 +20,25 @@ class PortalServicesTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_service_intake_preserves_same_origin_entry_page_and_replay_without_trusting_external_referers(): void
|
||||
{
|
||||
$key = (string) Str::uuid();
|
||||
$payload = ['kind' => 'investor', 'fullName' => 'Pessoa sintética QA', 'email' => 'qa-entry-source@example.invalid',
|
||||
'country' => 'PT', 'declared_origin_country_code' => 'ZA', 'sectorInterest' => 'Ensaio da origem do formulário',
|
||||
'message' => 'Descrição sintética QA para testar a rastreabilidade do formulário.', 'privacyConsent' => true, 'submission_key' => $key];
|
||||
$this->post('http://localhost/apoio', $payload, ['Referer' => 'http://localhost/formularios/investidor?context=qa'])->assertRedirect();
|
||||
$row = InterestRequest::where('email', $payload['email'])->firstOrFail();
|
||||
$this->assertSame('/formularios/investidor', $row->source_page);
|
||||
$this->assertSame('ZA', $row->metadata['declared_origin_country_code']);
|
||||
$this->post('http://localhost/apoio', $payload, ['Referer' => 'http://localhost/apoio'])->assertRedirect();
|
||||
$this->assertDatabaseCount('interest_requests', 1);
|
||||
$this->assertSame('/formularios/investidor', $row->fresh()->source_page);
|
||||
foreach (['https://foreign.example/formularios/empresa', 'http://localhost/management/interests', 'http://localhost:9999/formularios/investidor'] as $referer) {
|
||||
$this->post('http://localhost/apoio', [...$payload, 'submission_key' => (string) Str::uuid()], ['Referer' => $referer])->assertRedirect();
|
||||
$this->assertSame('/apoio', InterestRequest::latest('id')->first()->source_page);
|
||||
}
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Reference in New Issue
Block a user