use of org.springframework.security.web.server.authorization.ServerWebExchangeDelegatingServerAccessDeniedHandler.DelegateEntry in project spring-security by spring-projects.
the class ServerWebExchangeDelegatingServerAccessDeniedHandlerTests method handleWhenNothingMatchesThenOnlyDefaultHandlerInvoked.
@Test
public void handleWhenNothingMatchesThenOnlyDefaultHandlerInvoked() {
ServerAccessDeniedHandler handler = mock(ServerAccessDeniedHandler.class);
ServerWebExchangeMatcher matcher = mock(ServerWebExchangeMatcher.class);
given(matcher.matches(this.exchange)).willReturn(MatchResult.notMatch());
given(handler.handle(this.exchange, null)).willReturn(Mono.empty());
given(this.accessDeniedHandler.handle(this.exchange, null)).willReturn(Mono.empty());
this.entries.add(new DelegateEntry(matcher, handler));
this.delegator = new ServerWebExchangeDelegatingServerAccessDeniedHandler(this.entries);
this.delegator.setDefaultAccessDeniedHandler(this.accessDeniedHandler);
this.delegator.handle(this.exchange, null).block();
verify(this.accessDeniedHandler).handle(this.exchange, null);
verify(handler, never()).handle(this.exchange, null);
}
use of org.springframework.security.web.server.authorization.ServerWebExchangeDelegatingServerAccessDeniedHandler.DelegateEntry in project spring-security by spring-projects.
the class ServerWebExchangeDelegatingServerAccessDeniedHandlerTests method handleWhenSecondMatchesThenOnlySecondInvoked.
@Test
public void handleWhenSecondMatchesThenOnlySecondInvoked() {
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.notMatch());
given(secondMatcher.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.handle(this.exchange, null).block();
verify(secondHandler).handle(this.exchange, null);
verify(firstHandler, never()).handle(this.exchange, null);
verify(this.accessDeniedHandler, never()).handle(this.exchange, null);
}
use of org.springframework.security.web.server.authorization.ServerWebExchangeDelegatingServerAccessDeniedHandler.DelegateEntry 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);
}
Aggregations