Use OAuth2ErrorCodes.UNSUPPORTED_TOKEN_TYPE

Issue gh-83
This commit is contained in:
Joe Grandja 2020-11-04 07:36:37 -05:00
parent ebcdf7989d
commit cb09aef605
2 changed files with 3 additions and 4 deletions

View File

@ -74,8 +74,7 @@ public class OAuth2TokenRevocationAuthenticationProvider implements Authenticati
} else if (TokenType.ACCESS_TOKEN.getValue().equals(tokenTypeHint)) {
tokenType = TokenType.ACCESS_TOKEN;
} else {
// TODO Add OAuth2ErrorCodes.UNSUPPORTED_TOKEN_TYPE
throw new OAuth2AuthenticationException(new OAuth2Error("unsupported_token_type"));
throw new OAuth2AuthenticationException(new OAuth2Error(OAuth2ErrorCodes.UNSUPPORTED_TOKEN_TYPE));
}
}

View File

@ -100,12 +100,12 @@ public class OAuth2TokenRevocationAuthenticationProviderTests {
RegisteredClient registeredClient = TestRegisteredClients.registeredClient().build();
OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(registeredClient);
OAuth2TokenRevocationAuthenticationToken authentication = new OAuth2TokenRevocationAuthenticationToken(
"token", clientPrincipal, "unsupported_token_type");
"token", clientPrincipal, OAuth2ErrorCodes.UNSUPPORTED_TOKEN_TYPE);
assertThatThrownBy(() -> this.authenticationProvider.authenticate(authentication))
.isInstanceOf(OAuth2AuthenticationException.class)
.extracting(ex -> ((OAuth2AuthenticationException) ex).getError())
.extracting("errorCode")
.isEqualTo("unsupported_token_type");
.isEqualTo(OAuth2ErrorCodes.UNSUPPORTED_TOKEN_TYPE);
}
@Test