mirror of
				https://github.com/spring-projects/spring-security.git
				synced 2025-10-30 22:28:46 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			28 lines
		
	
	
		
			564 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			564 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| = WebTestClient Security Setup
 | |
| 
 | |
| The basic setup looks like this:
 | |
| 
 | |
| [source,java]
 | |
| ----
 | |
| @ExtendWith(SpringExtension.class)
 | |
| @ContextConfiguration(classes = HelloWebfluxMethodApplication.class)
 | |
| public class HelloWebfluxMethodApplicationTests {
 | |
| 	@Autowired
 | |
| 	ApplicationContext context;
 | |
| 
 | |
| 	WebTestClient rest;
 | |
| 
 | |
| 	@BeforeEach
 | |
| 	public void setup() {
 | |
| 		this.rest = WebTestClient
 | |
| 			.bindToApplicationContext(this.context)
 | |
| 			// add Spring Security test Support
 | |
| 			.apply(springSecurity())
 | |
| 			.configureClient()
 | |
| 			.filter(basicAuthentication())
 | |
| 			.build();
 | |
| 	}
 | |
| 	// ...
 | |
| }
 | |
| ----
 |