File manager - Edit - /var/www/html/homologBancodetalentos/tests/Feature/TalentBank/SsoAuthTest.php
Back
<?php namespace Tests\Feature\TalentBank; use App\Models\TalentBank\Company; use App\Support\SsoWebSession; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\Http; use Tests\TestCase; class SsoAuthTest extends TestCase { use DatabaseTransactions; public function test_sso_callback_redirects_company_to_bt_dashboard(): void { config([ 'services.angra_sso.exchange_url' => 'https://angra.test/sso/exchange', 'services.angra_sso.secret' => 'test-secret', ]); Http::fake([ 'https://angra.test/sso/exchange' => Http::response([ 'cpf' => '12345678000199', 'name' => 'Empresa Teste', 'email' => 'empresa@test.com', 'phone' => '21999999999', ], 200), ]); $response = $this->postJson(route('entrar.sso-callback'), [ 'code' => 'auth-code-123', 'state' => 'state-uuid', ]); $response->assertOk() ->assertJsonPath('success', true) ->assertJsonPath('redirect_url', route('talent-bank.company.dashboard')); $this->assertTrue(SsoWebSession::hasToken()); $this->assertTrue(SsoWebSession::isAngraSsoSession()); $this->assertDatabaseHas('companies', [ 'cnpj' => '12345678000199', 'email' => 'empresa@test.com', ]); } public function test_sso_callback_redirects_candidate_to_profile(): void { config([ 'services.angra_sso.exchange_url' => 'https://angra.test/sso/exchange', 'services.angra_sso.secret' => 'test-secret', ]); Http::fake([ 'https://angra.test/sso/exchange' => Http::response([ 'cpf' => '12345678901', 'name' => 'Candidato Teste', 'email' => 'candidato@test.com', ], 200), ]); $response = $this->postJson(route('entrar.sso-callback'), [ 'code' => 'auth-code-456', 'state' => 'state-uuid-2', ]); $response->assertOk() ->assertJsonPath('redirect_url', route('talent-bank.candidate.profile')); } public function test_auth_status_requires_session(): void { $this->getJson(route('auth.status')) ->assertOk() ->assertExactJson(['authenticated' => false]); } public function test_bridge_route_is_public(): void { $this->get(route('sso.bridge', ['state' => 'test-state', 'code' => 'x'])) ->assertOk() ->assertSee('Autenticação concluída', false); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings