Add test to ensure public clients are asked to provide a code challenge

This commit is contained in:
sephster 2018-08-13 22:54:12 +01:00
parent 0105a20126
commit 8ab27ede39
No known key found for this signature in database
GPG Key ID: 077754CA23023F4F
2 changed files with 8 additions and 1 deletions

View File

@ -148,6 +148,7 @@ class AuthorizationServerTest extends TestCase
{ {
$client = new ClientEntity(); $client = new ClientEntity();
$client->setRedirectUri('http://foo/bar'); $client->setRedirectUri('http://foo/bar');
$client->setIsConfidential();
$clientRepositoryMock = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock(); $clientRepositoryMock = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock();
$clientRepositoryMock->method('getClientEntity')->willReturn($client); $clientRepositoryMock->method('getClientEntity')->willReturn($client);

View File

@ -84,6 +84,7 @@ class AuthCodeGrantTest extends TestCase
{ {
$client = new ClientEntity(); $client = new ClientEntity();
$client->setRedirectUri('http://foo/bar'); $client->setRedirectUri('http://foo/bar');
$client->setIsConfidential();
$clientRepositoryMock = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock(); $clientRepositoryMock = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock();
$clientRepositoryMock->method('getClientEntity')->willReturn($client); $clientRepositoryMock->method('getClientEntity')->willReturn($client);
@ -123,6 +124,7 @@ class AuthCodeGrantTest extends TestCase
{ {
$client = new ClientEntity(); $client = new ClientEntity();
$client->setRedirectUri(['http://foo/bar']); $client->setRedirectUri(['http://foo/bar']);
$client->setIsConfidential();
$clientRepositoryMock = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock(); $clientRepositoryMock = $this->getMockBuilder(ClientRepositoryInterface::class)->getMock();
$clientRepositoryMock->method('getClientEntity')->willReturn($client); $clientRepositoryMock->method('getClientEntity')->willReturn($client);
@ -198,6 +200,7 @@ class AuthCodeGrantTest extends TestCase
} }
/** /**
* $this->expectException(OAuth
* @expectedException \League\OAuth2\Server\Exception\OAuthServerException * @expectedException \League\OAuth2\Server\Exception\OAuthServerException
*/ */
public function testValidateAuthorizationRequestCodeChallengeInvalidLengthTooShort() 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);
} }
} }