|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2022 the original author or authors. |
| 2 | + * Copyright 2002-2025 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
17 | 17 | package org.springframework.security.web.authentication;
|
18 | 18 |
|
19 | 19 | import jakarta.servlet.FilterChain;
|
| 20 | +import jakarta.servlet.Servlet; |
20 | 21 | import jakarta.servlet.ServletException;
|
21 | 22 | import jakarta.servlet.ServletRequest;
|
22 | 23 | import jakarta.servlet.ServletResponse;
|
|
57 | 58 |
|
58 | 59 | /**
|
59 | 60 | * @author Sergey Bespalov
|
| 61 | + * @author Andrey Litvitski |
60 | 62 | * @since 5.2.0
|
61 | 63 | */
|
62 | 64 | @ExtendWith(MockitoExtension.class)
|
@@ -318,4 +320,18 @@ public void filterWhenCustomSecurityContextRepositoryAndSuccessfulAuthentication
|
318 | 320 | assertThat(securityContextArg.getValue().getAuthentication()).isEqualTo(authentication);
|
319 | 321 | }
|
320 | 322 |
|
| 323 | + @Test |
| 324 | + public void filterWhenInFilterChainThenBothAreExecuted() throws Exception { |
| 325 | + MockHttpServletRequest request = new MockHttpServletRequest("GET", "/"); |
| 326 | + MockHttpServletResponse response = new MockHttpServletResponse(); |
| 327 | + AuthenticationFilter filter1 = new AuthenticationFilter(this.authenticationManager, |
| 328 | + this.authenticationConverter); |
| 329 | + AuthenticationConverter converter2 = mock(AuthenticationConverter.class); |
| 330 | + AuthenticationFilter filter2 = new AuthenticationFilter(this.authenticationManager, converter2); |
| 331 | + FilterChain chain = new MockFilterChain(mock(Servlet.class), filter1, filter2); |
| 332 | + chain.doFilter(request, response); |
| 333 | + verify(this.authenticationConverter).convert(any()); |
| 334 | + verify(converter2).convert(any()); |
| 335 | + } |
| 336 | + |
321 | 337 | }
|
0 commit comments