Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MishNajam committed Oct 27, 2023
1 parent 71ab2f4 commit c13a0e7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,13 @@ public function create_authorisation_request(): void
$this->issuerBuilder->reveal(),
$this->cacheFactory->reveal(),
);
$authorisationRequest = $authorisationRequestService->createAuthorisationRequest('en');
$fakeRedirect = 'http://fakehost/auth/redirect';
$authorisationRequest = $authorisationRequestService->createAuthorisationRequest('en', $fakeRedirect);
$authorisationRequestUrl = $authorisationRequest['url'];
$this->assertStringContainsString('client_id=client-id', $authorisationRequestUrl);
$this->assertStringContainsString('scope=openid+email', $authorisationRequestUrl);
$this->assertStringContainsString('vtr=["Cl.Cm.P2"]', urldecode($authorisationRequestUrl));
$this->assertStringContainsString('ui_locales=en', $authorisationRequestUrl);
$this->assertStringContainsString(
'redirect_uri=http://localhost:9002/auth/redirect',
urldecode($authorisationRequestUrl)
);
$this->assertStringContainsString('redirect_uri=' . $fakeRedirect, urldecode($authorisationRequestUrl));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ class OneLoginServiceTest extends TestCase
/** @test */
public function can_get_authorisation_request_uri(): void
{
$state = 'STATE';
$nonce = 'aEwkamaos5B';
$uri = '/authorize?response_type=code
$state = 'STATE';
$nonce = 'aEwkamaos5B';
$redirect = 'FAKE_REDIRECT';
$uri = '/authorize?response_type=code
&scope=YOUR_SCOPES
&client_id=YOUR_CLIENT_ID
&state=' . $state .
'&redirect_uri=YOUR_REDIRECT_URI
&nonce=' . $nonce .
'&redirect_uri=' . $redirect .
'&nonce=' . $nonce .
'&vtr=["Cl.Cm"]
&ui_locales=en';

Expand All @@ -33,12 +34,13 @@ public function can_get_authorisation_request_uri(): void
->httpGet(
'/v1/auth-one-login',
[
'ui_locale' => 'en',
'ui_locale' => 'en',
'redirect_url' => $redirect,
]
)->willReturn(['state' => $state, 'nonce' => $nonce, 'url' => $uri]);

$oneLoginService = new OneLoginService($apiClientProphecy->reveal());
$response = $oneLoginService->authorise('en');
$response = $oneLoginService->authorise('en', $redirect);
$this->assertEquals(['state' => $state, 'nonce' => $nonce, 'url' => $uri], $response);
}
}

0 comments on commit c13a0e7

Please sign in to comment.