Skip to content

Commit

Permalink
rename classes, methods and test names
Browse files Browse the repository at this point in the history
  • Loading branch information
MishNajam committed Oct 10, 2023
1 parent 62db8b7 commit db1f89d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions service-api/app/src/App/src/Handler/AuthRedirectHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -18,7 +18,7 @@
class AuthRedirectHandler implements RequestHandlerInterface
{
public function __construct(
private AuthenticationService $authenticationService,
private OneLoginAuthorisationRequestService $authorisationRequestService,
) {
}

Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use function Facile\OpenIDClient\base64url_encode;

class AuthenticationService
class OneLoginAuthorisationRequestService
{
public function __construct(
private JWKFactory $JWKFactory,
Expand All @@ -24,7 +24,7 @@ public function __construct(
) {
}

public function redirect(string $uiLocale): string
public function createAuthorisationRequest(string $uiLocale): string
{
//TODO UML-3080 Configure cache

Expand All @@ -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',
Expand All @@ -69,6 +69,6 @@ public function redirect(string $uiLocale): string
throw new RuntimeException('Could not create authorisation uri');

Check warning on line 69 in service-api/app/src/App/src/Service/Authentication/OneLoginAuthorisationRequestService.php

View check run for this annotation

Codecov / codecov/patch

service-api/app/src/App/src/Service/Authentication/OneLoginAuthorisationRequestService.php#L67-L69

Added lines #L67 - L69 were not covered by tests
}

return $redirectAuthorisationUri;
return $authorisationRequest;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -16,7 +16,7 @@
use Prophecy\Prophecy\ObjectProphecy;
use Psr\Log\LoggerInterface;

class AuthenticationServiceTest extends TestCase
class OneLoginAuthorisationRequestServiceTest extends TestCase
{
use ProphecyTrait;

Expand All @@ -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);
Expand Down

0 comments on commit db1f89d

Please sign in to comment.