Skip to content

Commit

Permalink
UML-3132 service api one login dummy endpoint returns a user
Browse files Browse the repository at this point in the history
  • Loading branch information
MishNajam committed Nov 2, 2023
1 parent 35cd031 commit ceb04cd
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
2 changes: 2 additions & 0 deletions service-api/app/config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use Mezzio\MiddlewareFactory;
use Psr\Container\ContainerInterface;
use App\Handler\OneLoginAuthenticationRequestHandler;
use App\Handler\OneLoginAuthorisationProcessHandler;

/**
* Setup routes with a single request method:
Expand Down Expand Up @@ -136,6 +137,7 @@
$app->patch('/v1/auth', AuthHandler::class, 'user.auth');

$app->get('/v1/auth-one-login', OneLoginAuthenticationRequestHandler::class, 'user.auth-one-login');
$app->get('/v1/auth-one-login-process', OneLoginAuthorisationProcessHandler::class, 'user.auth-process');

$app->post('/v1/email-user/{emailTemplate}', NotifyHandler::class, 'lpa.user.notify');
};
31 changes: 31 additions & 0 deletions service-api/app/features/context/Acceptance/AccountContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -1292,4 +1292,35 @@ public function iShouldBeToldThatABadRequestWasMade(): void
{
$this->ui->assertSession()->statusCodeEquals(StatusCodeInterface::STATUS_BAD_REQUEST);
}

/**
* @Given /^I am on the temporary one login page$/
*/
public function iAmOnTheTemporaryOneLoginPage(): void
{
// Not needed in this context
}

/**
* @When /^I click the one login button$/
*/
public function iClickTheOneLoginButton(): void
{
// Not needed in this context
}

/**
* @Then /^I am redirected to the redirect page$/
*/
public function iAmRedirectedToTheRedirectPage(): void
{
$this->apiGet('/v1/auth-one-login-process', []);

$this->ui->assertSession()->statusCodeEquals(StatusCodeInterface::STATUS_OK);

$response = $this->getResponseAsJson();

Assert::assertEquals('one-login-user', $response['Id']);
Assert::assertEquals('[email protected]', $response['Email']);
}
}
8 changes: 8 additions & 0 deletions service-api/app/features/one-login.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@actor @onelogin
Feature: Authorise One Login

@acceptance
Scenario: I initiate authentication via one login
Given I am on the temporary one login page
When I click the one login button
Then I am redirected to the redirect page
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

namespace App\Handler;

use DateTime;
use DateTimeInterface;
use Exception;
use Laminas\Diactoros\Response\JsonResponse;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Psr\Http\Message\ServerRequestInterface;

/**
* @codeCoverageIgnore
*/
class OneLoginAuthorisationProcessHandler implements RequestHandlerInterface
{
public function __construct()
{
}

/**
* @param ServerRequestInterface $request
* @return ResponseInterface
* @throws Exception
*/
public function handle(ServerRequestInterface $request): ResponseInterface
{
$requestData = $request->getQueryParams();

$user = [
'Id' => 'one-login-user',
'Email' => '[email protected]',
'LastLogin' => (new DateTime('now'))->format(DateTimeInterface::ATOM),
];

return new JsonResponse($user);
}
}

0 comments on commit ceb04cd

Please sign in to comment.