-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* UML-3132 service api one login dummy endpoint returns a user * Rename handler and return test user details * Rename api calls
- Loading branch information
Showing
6 changed files
with
87 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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/callback', []); | ||
|
||
$this->ui->assertSession()->statusCodeEquals(StatusCodeInterface::STATUS_OK); | ||
|
||
$response = $this->getResponseAsJson(); | ||
|
||
Assert::assertEquals('bf9e7e77-f283-49c6-a79c-65d5d309ef77', $response['Id']); | ||
Assert::assertEquals('[email protected]', $response['Email']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
41 changes: 41 additions & 0 deletions
41
service-api/app/src/App/src/Handler/OneLoginAuthenticationCallbackHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 OneLoginAuthenticationCallbackHandler implements RequestHandlerInterface | ||
{ | ||
public function __construct() | ||
{ | ||
} | ||
|
||
/** | ||
* @param ServerRequestInterface $request | ||
* @return ResponseInterface | ||
* @throws Exception | ||
*/ | ||
public function handle(ServerRequestInterface $request): ResponseInterface | ||
{ | ||
$requestData = $request->getQueryParams(); | ||
|
||
$user = [ | ||
'Id' => 'bf9e7e77-f283-49c6-a79c-65d5d309ef77', | ||
'Email' => '[email protected]', | ||
'LastLogin' => (new DateTime('-1 day'))->format(DateTimeInterface::ATOM), | ||
]; | ||
|
||
return new JsonResponse($user); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters