|
33 | 33 | import org.springframework.security.web.authentication.AnonymousAuthenticationFilter;
|
34 | 34 | import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
35 | 35 | import org.springframework.security.web.util.matcher.AnyRequestMatcher;
|
| 36 | +import org.springframework.security.web.util.matcher.RequestMatcher; |
| 37 | +import org.springframework.security.web.util.matcher.RequestMatchers; |
36 | 38 |
|
37 | 39 | import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
38 | 40 | import static org.assertj.core.api.Assertions.assertThatNoException;
|
@@ -95,4 +97,23 @@ void validateWhenSameRequestMatchersArePresentThenUnreachableFilterChainExceptio
|
95 | 97 | .isThrownBy(() -> this.validator.validate(proxy));
|
96 | 98 | }
|
97 | 99 |
|
| 100 | + @Test |
| 101 | + void validateWhenSameComposedRequestMatchersArePresentThenUnreachableFilterChainException() { |
| 102 | + RequestMatcher matcher1 = RequestMatchers.anyOf(RequestMatchers.allOf(AntPathRequestMatcher.antMatcher("/api"), |
| 103 | + AntPathRequestMatcher.antMatcher("*.do")), AntPathRequestMatcher.antMatcher("/admin")); |
| 104 | + RequestMatcher matcher2 = RequestMatchers.anyOf(RequestMatchers.allOf(AntPathRequestMatcher.antMatcher("/api"), |
| 105 | + AntPathRequestMatcher.antMatcher("*.do")), AntPathRequestMatcher.antMatcher("/admin")); |
| 106 | + SecurityFilterChain chain1 = new DefaultSecurityFilterChain(matcher1, this.authenticationFilter, |
| 107 | + this.exceptionTranslationFilter, this.authorizationInterceptor); |
| 108 | + SecurityFilterChain chain2 = new DefaultSecurityFilterChain(matcher2, this.authenticationFilter, |
| 109 | + this.exceptionTranslationFilter, this.authorizationInterceptor); |
| 110 | + List<SecurityFilterChain> chains = new ArrayList<>(); |
| 111 | + chains.add(chain2); |
| 112 | + chains.add(chain1); |
| 113 | + FilterChainProxy proxy = new FilterChainProxy(chains); |
| 114 | + |
| 115 | + assertThatExceptionOfType(UnreachableFilterChainException.class) |
| 116 | + .isThrownBy(() -> this.validator.validate(proxy)); |
| 117 | + } |
| 118 | + |
98 | 119 | }
|
0 commit comments