From db1f89d8dd52e64185fa30177f322d5aeca511d4 Mon Sep 17 00:00:00 2001 From: Mishkat Najam Date: Tue, 10 Oct 2023 11:25:00 +0100 Subject: [PATCH] rename classes, methods and test names --- .../app/src/App/src/Handler/AuthRedirectHandler.php | 6 +++--- ...ice.php => OneLoginAuthorisationRequestService.php} | 10 +++++----- ...php => OneLoginAuthorisationRequestServiceTest.php} | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) rename service-api/app/src/App/src/Service/Authentication/{AuthenticationService.php => OneLoginAuthorisationRequestService.php} (89%) rename service-api/app/test/AppTest/Service/Authentication/{AuthenticationServiceTest.php => OneLoginAuthorisationRequestServiceTest.php} (84%) diff --git a/service-api/app/src/App/src/Handler/AuthRedirectHandler.php b/service-api/app/src/App/src/Handler/AuthRedirectHandler.php index 26e01dd477..6763716c6d 100644 --- a/service-api/app/src/App/src/Handler/AuthRedirectHandler.php +++ b/service-api/app/src/App/src/Handler/AuthRedirectHandler.php @@ -5,7 +5,7 @@ namespace App\Handler; use App\Exception\BadRequestException; -use App\Service\Authentication\AuthenticationService; +use App\Service\Authentication\OneLoginAuthorisationRequestService; use Exception; use Laminas\Diactoros\Response\JsonResponse; use Psr\Http\Message\ResponseInterface; @@ -18,7 +18,7 @@ class AuthRedirectHandler implements RequestHandlerInterface { public function __construct( - private AuthenticationService $authenticationService, + private OneLoginAuthorisationRequestService $authorisationRequestService, ) { } @@ -44,7 +44,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface throw new BadRequestException('ui_locale is not set to en or cy'); } - $authorisationUri = $this->authenticationService->redirect($params['ui_locale']); + $authorisationUri = $this->authorisationRequestService->createAuthorisationRequest($params['ui_locale']); return new JsonResponse($authorisationUri); } diff --git a/service-api/app/src/App/src/Service/Authentication/AuthenticationService.php b/service-api/app/src/App/src/Service/Authentication/OneLoginAuthorisationRequestService.php similarity index 89% rename from service-api/app/src/App/src/Service/Authentication/AuthenticationService.php rename to service-api/app/src/App/src/Service/Authentication/OneLoginAuthorisationRequestService.php index 4e996ff597..4da1552d09 100644 --- a/service-api/app/src/App/src/Service/Authentication/AuthenticationService.php +++ b/service-api/app/src/App/src/Service/Authentication/OneLoginAuthorisationRequestService.php @@ -15,7 +15,7 @@ use function Facile\OpenIDClient\base64url_encode; -class AuthenticationService +class OneLoginAuthorisationRequestService { public function __construct( private JWKFactory $JWKFactory, @@ -24,7 +24,7 @@ public function __construct( ) { } - public function redirect(string $uiLocale): string + public function createAuthorisationRequest(string $uiLocale): string { //TODO UML-3080 Configure cache @@ -51,9 +51,9 @@ public function redirect(string $uiLocale): string $authorisationService = (new AuthorizationServiceBuilder())->build(); - $redirectAuthorisationUri = ''; + $authorisationRequest = ''; try { - $redirectAuthorisationUri = $authorisationService->getAuthorizationUri( + $authorisationRequest = $authorisationService->getAuthorizationUri( $client, [ 'scope' => 'openid email', @@ -69,6 +69,6 @@ public function redirect(string $uiLocale): string throw new RuntimeException('Could not create authorisation uri'); } - return $redirectAuthorisationUri; + return $authorisationRequest; } } diff --git a/service-api/app/test/AppTest/Service/Authentication/AuthenticationServiceTest.php b/service-api/app/test/AppTest/Service/Authentication/OneLoginAuthorisationRequestServiceTest.php similarity index 84% rename from service-api/app/test/AppTest/Service/Authentication/AuthenticationServiceTest.php rename to service-api/app/test/AppTest/Service/Authentication/OneLoginAuthorisationRequestServiceTest.php index 225b013122..eb6946464f 100644 --- a/service-api/app/test/AppTest/Service/Authentication/AuthenticationServiceTest.php +++ b/service-api/app/test/AppTest/Service/Authentication/OneLoginAuthorisationRequestServiceTest.php @@ -4,7 +4,7 @@ namespace AppTest\Service\Authentication; -use App\Service\Authentication\AuthenticationService; +use App\Service\Authentication\OneLoginAuthorisationRequestService; use App\Service\Authentication\JWKFactory; use Facile\OpenIDClient\Issuer\IssuerBuilder; use Facile\OpenIDClient\Issuer\IssuerBuilderInterface; @@ -16,7 +16,7 @@ use Prophecy\Prophecy\ObjectProphecy; use Psr\Log\LoggerInterface; -class AuthenticationServiceTest extends TestCase +class OneLoginAuthorisationRequestServiceTest extends TestCase { use ProphecyTrait; @@ -42,14 +42,14 @@ public function setup(): void /** * @test */ - public function get_redirect_uri(): void + public function create_authorisation_request(): void { - $authenticationService = new AuthenticationService( + $authenticationService = new OneLoginAuthorisationRequestService( $this->JWKFactory->reveal(), $this->logger->reveal(), $this->issuerBuilder->reveal() ); - $redirectUri = $authenticationService->redirect('en'); + $redirectUri = $authenticationService->createAuthorisationRequest('en'); $this->assertStringContainsString('client_id=client-id', $redirectUri); $this->assertStringContainsString('scope=openid+email', $redirectUri); $this->assertStringContainsString('vtr=%5B%22Cl.Cm.P2%22%5D', $redirectUri);