diff --git a/src/AuthorizationServer.php b/src/AuthorizationServer.php index 805d1e73..1122749b 100644 --- a/src/AuthorizationServer.php +++ b/src/AuthorizationServer.php @@ -73,7 +73,7 @@ class AuthorizationServer implements EmitterAwareInterface /** * @var string */ - private $defaultScope = null; + private $defaultScope = ''; /** * New server instance. @@ -209,4 +209,14 @@ class AuthorizationServer implements EmitterAwareInterface return $this->responseType; } + + /** + * Set the default scope for the authorization server. + * + * @param string $defaultScope + */ + public function setDefaultScope($defaultScope) + { + $this->defaultScope = $defaultScope; + } } diff --git a/tests/AuthorizationServerTest.php b/tests/AuthorizationServerTest.php index 15376c22..594a7ca6 100644 --- a/tests/AuthorizationServerTest.php +++ b/tests/AuthorizationServerTest.php @@ -45,7 +45,6 @@ class AuthorizationServerTest extends \PHPUnit_Framework_TestCase $this->getMockBuilder(ScopeRepositoryInterface::class)->getMock(), 'file://' . __DIR__ . '/Stubs/private.key', base64_encode(random_bytes(36)), - self::DEFAULT_SCOPE, new StubResponseType() ); @@ -78,10 +77,10 @@ class AuthorizationServerTest extends \PHPUnit_Framework_TestCase $scopeRepositoryMock, 'file://' . __DIR__ . '/Stubs/private.key', base64_encode(random_bytes(36)), - self::DEFAULT_SCOPE, new StubResponseType() ); + $server->setDefaultScope(self::DEFAULT_SCOPE); $server->enableGrantType(new ClientCredentialsGrant(), new \DateInterval('PT1M')); $_POST['grant_type'] = 'client_credentials'; @@ -166,9 +165,10 @@ class AuthorizationServerTest extends \PHPUnit_Framework_TestCase $this->getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(), $scopeRepositoryMock, 'file://' . __DIR__ . '/Stubs/private.key', - 'file://' . __DIR__ . '/Stubs/public.key', - self::DEFAULT_SCOPE + 'file://' . __DIR__ . '/Stubs/public.key' ); + + $server->setDefaultScope(self::DEFAULT_SCOPE); $server->enableGrantType($grant); $request = new ServerRequest( diff --git a/tests/Middleware/AuthorizationServerMiddlewareTest.php b/tests/Middleware/AuthorizationServerMiddlewareTest.php index b41774de..1556405a 100644 --- a/tests/Middleware/AuthorizationServerMiddlewareTest.php +++ b/tests/Middleware/AuthorizationServerMiddlewareTest.php @@ -40,10 +40,10 @@ class AuthorizationServerMiddlewareTest extends \PHPUnit_Framework_TestCase $scopeRepositoryMock, 'file://' . __DIR__ . '/../Stubs/private.key', base64_encode(random_bytes(36)), - self::DEFAULT_SCOPE, new StubResponseType() ); + $server->setDefaultScope(self::DEFAULT_SCOPE); $server->enableGrantType(new ClientCredentialsGrant()); $_POST['grant_type'] = 'client_credentials';