use of org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher in project spring-security by spring-projects.
the class ServerWebExchangeDelegatingServerAccessDeniedHandlerTests method handleWhenFirstMatchesThenOnlyFirstInvoked.
@Test
public void handleWhenFirstMatchesThenOnlyFirstInvoked() {
ServerAccessDeniedHandler firstHandler = mock(ServerAccessDeniedHandler.class);
ServerWebExchangeMatcher firstMatcher = mock(ServerWebExchangeMatcher.class);
ServerAccessDeniedHandler secondHandler = mock(ServerAccessDeniedHandler.class);
ServerWebExchangeMatcher secondMatcher = mock(ServerWebExchangeMatcher.class);
given(firstMatcher.matches(this.exchange)).willReturn(MatchResult.match());
given(firstHandler.handle(this.exchange, null)).willReturn(Mono.empty());
given(secondHandler.handle(this.exchange, null)).willReturn(Mono.empty());
this.entries.add(new DelegateEntry(firstMatcher, firstHandler));
this.entries.add(new DelegateEntry(secondMatcher, secondHandler));
this.delegator = new ServerWebExchangeDelegatingServerAccessDeniedHandler(this.entries);
this.delegator.setDefaultAccessDeniedHandler(this.accessDeniedHandler);
this.delegator.handle(this.exchange, null).block();
verify(firstHandler).handle(this.exchange, null);
verify(secondHandler, never()).handle(this.exchange, null);
verify(this.accessDeniedHandler, never()).handle(this.exchange, null);
verify(secondMatcher, never()).matches(this.exchange);
}
use of org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher in project spring-security by spring-projects.
the class WebSessionServerRequestCache method createDefaultRequestMacher.
private static ServerWebExchangeMatcher createDefaultRequestMacher() {
ServerWebExchangeMatcher get = ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, "/**");
ServerWebExchangeMatcher notFavicon = new NegatedServerWebExchangeMatcher(ServerWebExchangeMatchers.pathMatchers("/favicon.*"));
MediaTypeServerWebExchangeMatcher html = new MediaTypeServerWebExchangeMatcher(MediaType.TEXT_HTML);
html.setIgnoredMediaTypes(Collections.singleton(MediaType.ALL));
return new AndServerWebExchangeMatcher(get, notFavicon, html);
}
use of org.springframework.security.web.server.util.matcher.ServerWebExchangeMatcher in project spring-security by spring-projects.
the class WebFilterChainProxyTests method filterWhenNoMatchThenContinuesChainAnd404.
// gh-4668
@Test
public void filterWhenNoMatchThenContinuesChainAnd404() {
List<WebFilter> filters = Arrays.asList(new Http200WebFilter());
ServerWebExchangeMatcher notMatch = (exchange) -> MatchResult.notMatch();
MatcherSecurityWebFilterChain chain = new MatcherSecurityWebFilterChain(notMatch, filters);
WebFilterChainProxy filter = new WebFilterChainProxy(chain);
WebTestClient.bindToController(new Object()).webFilter(filter).build().get().exchange().expectStatus().isNotFound();
}
Aggregations