Switch to Spring Framework SNAPSHOTs
See gh-30624
This commit is contained in:
@@ -320,7 +320,7 @@ public abstract class AbstractErrorWebExceptionHandler implements ErrorWebExcept
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(request.exchange().getLogPrefix() + formatError(throwable, request));
|
||||
}
|
||||
if (HttpStatus.resolve(response.rawStatusCode()) != null
|
||||
if (HttpStatus.resolve(response.statusCode().value()) != null
|
||||
&& response.statusCode().equals(HttpStatus.INTERNAL_SERVER_ERROR)) {
|
||||
logger.error(LogMessage.of(() -> String.format("%s 500 Server Error for %s",
|
||||
request.exchange().getLogPrefix(), formatRequest(request))), throwable);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.boot.autoconfigure.security.oauth2.resource.reactive;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -83,6 +84,8 @@ class ReactiveOAuth2ResourceServerAutoConfigurationTests {
|
||||
|
||||
private MockWebServer server;
|
||||
|
||||
private static final Duration TIMEOUT = Duration.ofSeconds(5);
|
||||
|
||||
private static final String JWK_SET = "{\"keys\":[{\"kty\":\"RSA\",\"e\":\"AQAB\",\"use\":\"sig\","
|
||||
+ "\"kid\":\"one\",\"n\":\"oXJ8OyOv_eRnce4akdanR4KYRfnC2zLV4uYNQpcFn6oHL0dj7D6kxQmsXoYgJV8ZVDn71KGm"
|
||||
+ "uLvolxsDncc2UrhyMBY6DVQVgMSVYaPCTgW76iYEKGgzTEw5IBRQL9w3SRJWd3VJTZZQjkXef48Ocz06PGF3lhbz4t5UEZtd"
|
||||
@@ -148,7 +151,7 @@ class ReactiveOAuth2ResourceServerAutoConfigurationTests {
|
||||
.getBean(SupplierReactiveJwtDecoder.class);
|
||||
Mono<ReactiveJwtDecoder> reactiveJwtDecoderSupplier = (Mono<ReactiveJwtDecoder>) ReflectionTestUtils
|
||||
.getField(supplierReactiveJwtDecoder, "jwtDecoderMono");
|
||||
ReactiveJwtDecoder reactiveJwtDecoder = reactiveJwtDecoderSupplier.block();
|
||||
ReactiveJwtDecoder reactiveJwtDecoder = reactiveJwtDecoderSupplier.block(TIMEOUT);
|
||||
});
|
||||
// The last request is to the JWK Set endpoint to look up the algorithm
|
||||
assertThat(this.server.getRequestCount()).isEqualTo(1);
|
||||
@@ -171,7 +174,7 @@ class ReactiveOAuth2ResourceServerAutoConfigurationTests {
|
||||
.getBean(SupplierReactiveJwtDecoder.class);
|
||||
Mono<ReactiveJwtDecoder> reactiveJwtDecoderSupplier = (Mono<ReactiveJwtDecoder>) ReflectionTestUtils
|
||||
.getField(supplierReactiveJwtDecoder, "jwtDecoderMono");
|
||||
ReactiveJwtDecoder reactiveJwtDecoder = reactiveJwtDecoderSupplier.block();
|
||||
ReactiveJwtDecoder reactiveJwtDecoder = reactiveJwtDecoderSupplier.block(TIMEOUT);
|
||||
});
|
||||
// The last request is to the JWK Set endpoint to look up the algorithm
|
||||
assertThat(this.server.getRequestCount()).isEqualTo(2);
|
||||
@@ -194,7 +197,7 @@ class ReactiveOAuth2ResourceServerAutoConfigurationTests {
|
||||
.getBean(SupplierReactiveJwtDecoder.class);
|
||||
Mono<ReactiveJwtDecoder> reactiveJwtDecoderSupplier = (Mono<ReactiveJwtDecoder>) ReflectionTestUtils
|
||||
.getField(supplierReactiveJwtDecoder, "jwtDecoderMono");
|
||||
ReactiveJwtDecoder reactiveJwtDecoder = reactiveJwtDecoderSupplier.block();
|
||||
ReactiveJwtDecoder reactiveJwtDecoder = reactiveJwtDecoderSupplier.block(TIMEOUT);
|
||||
});
|
||||
// The last request is to the JWK Set endpoint to look up the algorithm
|
||||
assertThat(this.server.getRequestCount()).isEqualTo(3);
|
||||
@@ -395,7 +398,7 @@ class ReactiveOAuth2ResourceServerAutoConfigurationTests {
|
||||
.filter((f) -> f instanceof AuthenticationWebFilter).findFirst().orElse(null);
|
||||
ReactiveAuthenticationManagerResolver<?> authenticationManagerResolver = (ReactiveAuthenticationManagerResolver<?>) ReflectionTestUtils
|
||||
.getField(webFilter, "authenticationManagerResolver");
|
||||
Object authenticationManager = authenticationManagerResolver.resolve(null).block();
|
||||
Object authenticationManager = authenticationManagerResolver.resolve(null).block(TIMEOUT);
|
||||
assertThat(authenticationManager).isInstanceOf(JwtReactiveAuthenticationManager.class);
|
||||
}
|
||||
|
||||
@@ -408,7 +411,7 @@ class ReactiveOAuth2ResourceServerAutoConfigurationTests {
|
||||
.filter((f) -> f instanceof AuthenticationWebFilter).findFirst().orElse(null);
|
||||
ReactiveAuthenticationManagerResolver<?> authenticationManagerResolver = (ReactiveAuthenticationManagerResolver<?>) ReflectionTestUtils
|
||||
.getField(webFilter, "authenticationManagerResolver");
|
||||
Object authenticationManager = authenticationManagerResolver.resolve(null).block();
|
||||
Object authenticationManager = authenticationManagerResolver.resolve(null).block(TIMEOUT);
|
||||
assertThat(authenticationManager).isInstanceOf(OpaqueTokenReactiveAuthenticationManager.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,12 +16,7 @@
|
||||
|
||||
package org.springframework.boot.autoconfigure.web.reactive.function.client;
|
||||
|
||||
import java.net.URI;
|
||||
import java.time.Duration;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
@@ -29,20 +24,13 @@ import org.springframework.boot.web.codec.CodecCustomizer;
|
||||
import org.springframework.boot.web.reactive.function.client.WebClientCustomizer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.client.reactive.ClientHttpConnector;
|
||||
import org.springframework.http.client.reactive.ClientHttpResponse;
|
||||
import org.springframework.http.codec.CodecConfigurer;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.BDDMockito.then;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
|
||||
/**
|
||||
* Tests for {@link WebClientAutoConfiguration}
|
||||
@@ -88,26 +76,9 @@ class WebClientAutoConfigurationTests {
|
||||
@Test
|
||||
void shouldGetPrototypeScopedBean() {
|
||||
this.contextRunner.withUserConfiguration(WebClientCustomizerConfig.class).run((context) -> {
|
||||
ClientHttpResponse response = mock(ClientHttpResponse.class);
|
||||
given(response.getBody()).willReturn(Flux.empty());
|
||||
given(response.getHeaders()).willReturn(new HttpHeaders());
|
||||
ClientHttpConnector firstConnector = mock(ClientHttpConnector.class);
|
||||
given(firstConnector.connect(any(), any(), any())).willReturn(Mono.just(response));
|
||||
WebClient.Builder firstBuilder = context.getBean(WebClient.Builder.class);
|
||||
firstBuilder.clientConnector(firstConnector).baseUrl("https://first.example.org");
|
||||
ClientHttpConnector secondConnector = mock(ClientHttpConnector.class);
|
||||
given(secondConnector.connect(any(), any(), any())).willReturn(Mono.just(response));
|
||||
WebClient.Builder secondBuilder = context.getBean(WebClient.Builder.class);
|
||||
secondBuilder.clientConnector(secondConnector).baseUrl("https://second.example.org");
|
||||
assertThat(firstBuilder).isNotEqualTo(secondBuilder);
|
||||
firstBuilder.build().get().uri("/foo").retrieve().toBodilessEntity().block(Duration.ofSeconds(30));
|
||||
secondBuilder.build().get().uri("/foo").retrieve().toBodilessEntity().block(Duration.ofSeconds(30));
|
||||
then(firstConnector).should().connect(eq(HttpMethod.GET), eq(URI.create("https://first.example.org/foo")),
|
||||
any());
|
||||
then(secondConnector).should().connect(eq(HttpMethod.GET), eq(URI.create("https://second.example.org/foo")),
|
||||
any());
|
||||
WebClientCustomizer customizer = context.getBean("webClientCustomizer", WebClientCustomizer.class);
|
||||
then(customizer).should(times(2)).customize(any(WebClient.Builder.class));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user