Skip to content

Commit bab50ee

Browse files
author
Greg Bowler
committed
Begin test for malformed responses
1 parent f0f0730 commit bab50ee

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/phpunit/AuthenticatorTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,4 +233,31 @@ public function testGetEmail() {
233233
);
234234
self::assertEquals($expectedEmail, $sut->getEmail());
235235
}
236+
237+
// When the remote provider redirects back to the client application, a query
238+
// string parameter "authwave" is provided, with encrypted user and config data.
239+
// In this example, we make our own query string parameter, which will NOT
240+
// decrypt properly, and should throw an exception to prevent unauthorised
241+
// access.
242+
public function testAuthInProgressMalformedUri() {
243+
$currentUri = "/?authwave=0123456789abcdef";
244+
$expectedRedirectUri = "http://localhost:8080/my-configured-redirect-uri";
245+
246+
$redirectHandler = self::createMock(RedirectHandler::class);
247+
$redirectHandler->expects(self::once())
248+
->method("redirect")
249+
->with(self::callback(fn(UriInterface $uri) =>
250+
(string)$uri === $expectedRedirectUri
251+
));
252+
253+
self::expectException(MalformedReponseDataException::class);
254+
new Authenticator(
255+
"test-key",
256+
"test-secret",
257+
$currentUri,
258+
AuthUri::DEFAULT_BASE_URI,
259+
null,
260+
$redirectHandler
261+
);
262+
}
236263
}

0 commit comments

Comments
 (0)