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 TypeMethodDescriptionvoid
afterConfigurerAdded
(WebTestClient.Builder builder, @Nullable WebHttpHandlerBuilder httpHandlerBuilder, @Nullable ClientHttpConnector connector) Use methods onWebTestClient.Builder
to modify test client settings.static UserWebTestClientConfigurer
Create a configurer with the givenSslInfo
.static UserWebTestClientConfigurer
x509
(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:WebTestClientConfigurer
Use methods onWebTestClient.Builder
to modify test client settings. For a mock WebFlux server, useWebHttpHandlerBuilder
to customize server configuration. For a MockMvc server, mutate theMockMvcHttpConnector
and set it onWebTestClient.Builder
.- Specified by:
afterConfigurerAdded
in 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
.
-