Use OAuth2AuthenticationException(String errorCode)

Closes gh-402
This commit is contained in:
Joe Grandja
2021-08-18 14:06:58 -04:00
parent ea1f95b4ed
commit f3c29bd545
12 changed files with 29 additions and 38 deletions

View File

@@ -171,7 +171,7 @@ public class OidcClientRegistrationEndpointFilterTests {
SecurityContextHolder.setContext(securityContext);
when(this.authenticationManager.authenticate(any()))
.thenThrow(new OAuth2AuthenticationException(new OAuth2Error(errorCode)));
.thenThrow(new OAuth2AuthenticationException(errorCode));
// @formatter:off
OidcClientRegistration clientRegistrationRequest = OidcClientRegistration.builder()

View File

@@ -147,7 +147,7 @@ public class OAuth2ClientAuthenticationFilterTests {
@Test
public void doFilterWhenRequestMatchesAndInvalidCredentialsThenInvalidRequestError() throws Exception {
when(this.authenticationConverter.convert(any(HttpServletRequest.class))).thenThrow(
new OAuth2AuthenticationException(new OAuth2Error(OAuth2ErrorCodes.INVALID_REQUEST)));
new OAuth2AuthenticationException(OAuth2ErrorCodes.INVALID_REQUEST));
MockHttpServletRequest request = new MockHttpServletRequest("POST", this.filterProcessesUrl);
request.setServletPath(this.filterProcessesUrl);
@@ -169,7 +169,7 @@ public class OAuth2ClientAuthenticationFilterTests {
when(this.authenticationConverter.convert(any(HttpServletRequest.class))).thenReturn(
new OAuth2ClientAuthenticationToken("clientId", ClientAuthenticationMethod.CLIENT_SECRET_BASIC, "invalid-secret", null));
when(this.authenticationManager.authenticate(any(Authentication.class))).thenThrow(
new OAuth2AuthenticationException(new OAuth2Error(OAuth2ErrorCodes.INVALID_CLIENT)));
new OAuth2AuthenticationException(OAuth2ErrorCodes.INVALID_CLIENT));
MockHttpServletRequest request = new MockHttpServletRequest("POST", this.filterProcessesUrl);
request.setServletPath(this.filterProcessesUrl);