Skip to content

Commit

Permalink
Fix OAuthStorage::checkGrantExtension return strict type
Browse files Browse the repository at this point in the history
  • Loading branch information
klapaudius committed Dec 10, 2024
1 parent abe1500 commit 4f0a463
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Storage/OAuthStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public function unsetRefreshToken($tokenString)
/**
* {@inheritdoc}
*/
public function checkGrantExtension(IOAuth2Client $client, $uri, array $inputData, array $authHeaders): array|bool
public function checkGrantExtension(IOAuth2Client $client, $uri, array $inputData, array $authHeaders): bool|array
{
if (!isset($this->grantExtensions[$uri])) {
throw new OAuth2ServerException(Response::HTTP_BAD_REQUEST, OAuth2::ERROR_UNSUPPORTED_GRANT_TYPE);
Expand Down
22 changes: 22 additions & 0 deletions Tests/Storage/OAuthStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,28 @@ public function testValidGrantExtensionWithData(): void
);
}

public function testValidGrantExtensionWithData(): void
{
$grantExtension = $this->getMockBuilder('FOS\OAuthServerBundle\Storage\GrantExtensionInterface')
->disableOriginalConstructor()
->getMock()
;
$grantExtensionData = ['data' => 'Foo'];
$grantExtension
->expects($this->once())
->method('checkGrantExtension')
->will($this->returnValue($grantExtensionData))
;
$this->storage->setGrantExtension('https://friendsofsymfony.com/grants/foo', $grantExtension);
$client = $this->getMockBuilder('OAuth2\Model\IOAuth2Client')
->disableOriginalConstructor()
->getMock()
;
$this->assertEquals(
$grantExtensionData,
$this->storage->checkGrantExtension($client, 'https://friendsofsymfony.com/grants/foo', [], [])
);
}
public function testInvalidGrantExtension(): void
{
$this->expectException(\OAuth2\OAuth2ServerException::class);
Expand Down

0 comments on commit 4f0a463

Please sign in to comment.