diff --git a/tests/AuthorizationValidators/BearerTokenValidatorTest.php b/tests/AuthorizationValidators/BearerTokenValidatorTest.php new file mode 100644 index 00000000..5690c9a9 --- /dev/null +++ b/tests/AuthorizationValidators/BearerTokenValidatorTest.php @@ -0,0 +1,41 @@ +getMockBuilder(AccessTokenRepositoryInterface::class)->getMock(); + + $bearerTokenValidator = new BearerTokenValidator($accessTokenRepositoryMock); + $bearerTokenValidator->setPublicKey(new CryptKey('file://' . __DIR__ . '/../Stubs/public.key')); + + $unsignedJwt = (new Builder()) + ->setAudience('client-id') + ->setId('token-id', true) + ->setIssuedAt(time()) + ->setNotBefore(time()) + ->setExpiration(time()) + ->setSubject('user-id') + ->set('scopes', 'scope1 scope2 scope3 scope4') + ->getToken(); + + $request = new ServerRequest(); + $request = $request->withHeader('authorization', sprintf('Bearer %s', $unsignedJwt)); + + $bearerTokenValidator->validateAuthorization($request); + } +}