Class UserWebTestClientConfigurer
java.lang.Object
org.springframework.test.web.reactive.server.UserWebTestClientConfigurer
- All Implemented Interfaces:
WebTestClientConfigurer
WebTestClientConfigurer that modifies WebFlux mock server requests
by setting their SslInfo.
You can apply the configurer to a WebTestClient.Builder:
WebTestClient client = webTestClientBuilder
.apply(UserWebTestClientConfigurer.x509(certificate))
.build();
Or mutate an already built WebTestClient:
WebTestClient newClient =
client.mutateWith(UserWebTestClientConfigurer.x509(certificate));
Note: This configurer is applicable only to WebFlux mock
server setup. For a WebTestClient.Builder with a live server setup,
or a non-WebFlux, mock server, an IllegalStateException is raised.
For tests with a MockMvc server, refer to a similar facility to set the
user identity per request through Spring Security's
SecurityMockMvcRequestPostProcessors.
- Since:
- 7.0
- Author:
- Rossen Stoyanchev
-
Method Summary
Modifier and TypeMethodDescriptionvoidafterConfigurerAdded(WebTestClient.Builder builder, @Nullable WebHttpHandlerBuilder httpHandlerBuilder, @Nullable ClientHttpConnector connector) Use methods onWebTestClient.Builderto modify test client settings.static UserWebTestClientConfigurerCreate a configurer with the givenSslInfo.static UserWebTestClientConfigurerx509(X509Certificate... certificates) Create a configurer with the givenX509 certificate(s).
-
Method Details
-
afterConfigurerAdded
public void afterConfigurerAdded(WebTestClient.Builder builder, @Nullable WebHttpHandlerBuilder httpHandlerBuilder, @Nullable ClientHttpConnector connector) Description copied from interface:WebTestClientConfigurerUse methods onWebTestClient.Builderto modify test client settings. For a mock WebFlux server, useWebHttpHandlerBuilderto customize server configuration. For a MockMvc server, mutate theMockMvcHttpConnectorand set it onWebTestClient.Builder.- Specified by:
afterConfigurerAddedin interfaceWebTestClientConfigurer- Parameters:
builder- the WebTestClient builder for test client changeshttpHandlerBuilder- for mock WebFlux server settingsconnector- the connector in use
-
x509
Create a configurer with the givenX509 certificate(s). -
sslInfo
Create a configurer with the givenSslInfo.
-