Refactoring - Move OTPHP logic to TwoFAccount model

This commit is contained in:
Bubka
2022-07-05 10:10:24 +02:00
parent 1d99c27675
commit 720eb16750
24 changed files with 1297 additions and 1268 deletions

View File

@ -61,6 +61,12 @@ class HandlerTest extends TestCase
[
'\App\Exceptions\InvalidGoogleAuthMigration'
],
[
'\App\Exceptions\UndecipherableException'
],
[
'\App\Exceptions\UnsupportedOtpTypeException'
],
];
}
@ -103,4 +109,30 @@ class HandlerTest extends TestCase
],
];
}
/**
* @test
*/
public function test_authenticationException_returns_proxyAuthRequired_json_response_with_proxy_guard()
{
$request = $this->createMock(Request::class);
$instance = new Handler($this->createMock(Container::class));
$class = new \ReflectionClass(Handler::class);
$method = $class->getMethod('render');
$method->setAccessible(true);
$mockException = $this->createMock(\Illuminate\Auth\AuthenticationException::class);
$mockException->method("guards")->willReturn(['reverse-proxy-guard']);
$response = $method->invokeArgs($instance, [$request, $mockException]);
$this->assertInstanceOf(JsonResponse::class, $response);
$response = \Illuminate\Testing\TestResponse::fromBaseResponse($response);
$response->assertStatus(407)
->assertJsonStructure([
'message'
]);
}
}