From 8ab27ede39fcc1d9d4bf9d5b02d4d6230d2cb519 Mon Sep 17 00:00:00 2001 From: sephster Date: Mon, 13 Aug 2018 22:54:12 +0100 Subject: [PATCH] Add test to ensure public clients are asked to provide a code challenge --- tests/AuthorizationServerTest.php | 1 + tests/Grant/AuthCodeGrantTest.php | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/AuthorizationServerTest.php b/tests/AuthorizationServerTest.php index b003c23f..e0f45d98 100644 --- a/tests/AuthorizationServerTest.php +++ b/tests/AuthorizationServerTest.php @@ -148,6 +148,7 @@ class AuthorizationServerTest extends TestCase { $client = new ClientEntity(); $client->setRedirectUri('http://foo/bar'); + $client->setIsConfidential(); $clientRepositoryMock = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock(); $clientRepositoryMock->method('getClientEntity')->willReturn($client); diff --git a/tests/Grant/AuthCodeGrantTest.php b/tests/Grant/AuthCodeGrantTest.php index 6f91fc0f..b0652d00 100644 --- a/tests/Grant/AuthCodeGrantTest.php +++ b/tests/Grant/AuthCodeGrantTest.php @@ -84,6 +84,7 @@ class AuthCodeGrantTest extends TestCase { $client = new ClientEntity(); $client->setRedirectUri('http://foo/bar'); + $client->setIsConfidential(); $clientRepositoryMock = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock(); $clientRepositoryMock->method('getClientEntity')->willReturn($client); @@ -123,6 +124,7 @@ class AuthCodeGrantTest extends TestCase { $client = new ClientEntity(); $client->setRedirectUri(['http://foo/bar']); + $client->setIsConfidential(); $clientRepositoryMock = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock(); $clientRepositoryMock->method('getClientEntity')->willReturn($client); @@ -198,6 +200,7 @@ class AuthCodeGrantTest extends TestCase } /** + * $this->expectException(OAuth * @expectedException \League\OAuth2\Server\Exception\OAuthServerException */ public function testValidateAuthorizationRequestCodeChallengeInvalidLengthTooShort() @@ -1818,6 +1821,9 @@ class AuthCodeGrantTest extends TestCase ] ); - $this->assertInstanceOf(AuthorizationRequest::class, $grant->validateAuthorizationRequest($request)); + $this->expectException(OAuthServerException::class); + $this->expectExceptionCode(3); + + $grant->validateAuthorizationRequest($request); } }