diff --git a/Storage/OAuthStorage.php b/Storage/OAuthStorage.php index bb0bc86b..dd17c897 100644 --- a/Storage/OAuthStorage.php +++ b/Storage/OAuthStorage.php @@ -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); diff --git a/Tests/Storage/OAuthStorageTest.php b/Tests/Storage/OAuthStorageTest.php index 345cbd8e..c6891bc6 100644 --- a/Tests/Storage/OAuthStorageTest.php +++ b/Tests/Storage/OAuthStorageTest.php @@ -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);