|
|
|
@ -28,7 +28,6 @@ import org.springframework.mock.http.MockHttpInputMessage; |
|
|
|
import org.springframework.mock.http.client.MockClientHttpResponse; |
|
|
|
import org.springframework.mock.http.client.MockClientHttpResponse; |
|
|
|
import org.springframework.security.oauth2.core.OAuth2AuthorizationException; |
|
|
|
import org.springframework.security.oauth2.core.OAuth2AuthorizationException; |
|
|
|
import org.springframework.security.oauth2.core.OAuth2Error; |
|
|
|
import org.springframework.security.oauth2.core.OAuth2Error; |
|
|
|
import org.springframework.web.client.UnknownHttpStatusCodeException; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType; |
|
|
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType; |
|
|
|
import static org.mockito.ArgumentMatchers.any; |
|
|
|
import static org.mockito.ArgumentMatchers.any; |
|
|
|
@ -102,8 +101,9 @@ public class OAuth2ErrorResponseErrorHandlerTests { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void handleErrorWhenErrorResponseWithInvalidStatusCodeThenHandled() { |
|
|
|
public void handleErrorWhenErrorResponseWithInvalidStatusCodeThenHandled() { |
|
|
|
CustomMockClientHttpResponse response = new CustomMockClientHttpResponse(new byte[0], 596); |
|
|
|
CustomMockClientHttpResponse response = new CustomMockClientHttpResponse(new byte[0], 596); |
|
|
|
assertThatExceptionOfType(UnknownHttpStatusCodeException.class) |
|
|
|
assertThatExceptionOfType(IllegalArgumentException.class) |
|
|
|
.isThrownBy(() -> this.errorHandler.handleError(response)).withMessage("596 : [no body]"); |
|
|
|
.isThrownBy(() -> this.errorHandler.handleError(response)) |
|
|
|
|
|
|
|
.withMessage("No matching constant for [596]"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static final class CustomMockClientHttpResponse extends MockHttpInputMessage implements ClientHttpResponse { |
|
|
|
private static final class CustomMockClientHttpResponse extends MockHttpInputMessage implements ClientHttpResponse { |
|
|
|
|