2021-10-29 12:09:04 -04:00
|
|
|
= WebTestClient Security Setup
|
|
|
|
|
|
|
|
The basic setup looks like this:
|
|
|
|
|
|
|
|
[source,java]
|
|
|
|
----
|
2022-03-22 15:30:10 -04:00
|
|
|
@ExtendWith(SpringExtension.class)
|
2021-10-29 12:09:04 -04:00
|
|
|
@ContextConfiguration(classes = HelloWebfluxMethodApplication.class)
|
|
|
|
public class HelloWebfluxMethodApplicationTests {
|
|
|
|
@Autowired
|
|
|
|
ApplicationContext context;
|
|
|
|
|
|
|
|
WebTestClient rest;
|
|
|
|
|
2022-03-22 15:30:10 -04:00
|
|
|
@BeforeEach
|
2021-10-29 12:09:04 -04:00
|
|
|
public void setup() {
|
|
|
|
this.rest = WebTestClient
|
|
|
|
.bindToApplicationContext(this.context)
|
|
|
|
// add Spring Security test Support
|
|
|
|
.apply(springSecurity())
|
|
|
|
.configureClient()
|
|
|
|
.filter(basicAuthentication())
|
|
|
|
.build();
|
|
|
|
}
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
----
|