use of org.springframework.security.rsocket.util.matcher.PayloadExchangeMatcherEntry in project spring-security by spring-projects.
the class PayloadExchangeMatcherReactiveAuthorizationManagerTests method checkWhenGrantedThenGranted.
@Test
public void checkWhenGrantedThenGranted() {
AuthorizationDecision expected = new AuthorizationDecision(true);
given(this.authz.check(any(), any())).willReturn(Mono.just(expected));
PayloadExchangeMatcherReactiveAuthorizationManager manager = PayloadExchangeMatcherReactiveAuthorizationManager.builder().add(new PayloadExchangeMatcherEntry<>(PayloadExchangeMatchers.anyExchange(), this.authz)).build();
assertThat(manager.check(Mono.empty(), this.exchange).block()).isEqualTo(expected);
}
use of org.springframework.security.rsocket.util.matcher.PayloadExchangeMatcherEntry in project spring-security by spring-projects.
the class PayloadExchangeMatcherReactiveAuthorizationManagerTests method checkWhenDeniedThenDenied.
@Test
public void checkWhenDeniedThenDenied() {
AuthorizationDecision expected = new AuthorizationDecision(false);
given(this.authz.check(any(), any())).willReturn(Mono.just(expected));
PayloadExchangeMatcherReactiveAuthorizationManager manager = PayloadExchangeMatcherReactiveAuthorizationManager.builder().add(new PayloadExchangeMatcherEntry<>(PayloadExchangeMatchers.anyExchange(), this.authz)).build();
assertThat(manager.check(Mono.empty(), this.exchange).block()).isEqualTo(expected);
}
use of org.springframework.security.rsocket.util.matcher.PayloadExchangeMatcherEntry in project spring-security by spring-projects.
the class PayloadExchangeMatcherReactiveAuthorizationManagerTests method checkWhenFirstMatchThenSecondUsed.
@Test
public void checkWhenFirstMatchThenSecondUsed() {
AuthorizationDecision expected = new AuthorizationDecision(true);
given(this.authz.check(any(), any())).willReturn(Mono.just(expected));
PayloadExchangeMatcherReactiveAuthorizationManager manager = PayloadExchangeMatcherReactiveAuthorizationManager.builder().add(new PayloadExchangeMatcherEntry<>(PayloadExchangeMatchers.anyExchange(), this.authz)).add(new PayloadExchangeMatcherEntry<>((e) -> PayloadExchangeMatcher.MatchResult.notMatch(), this.authz2)).build();
assertThat(manager.check(Mono.empty(), this.exchange).block()).isEqualTo(expected);
}
use of org.springframework.security.rsocket.util.matcher.PayloadExchangeMatcherEntry in project spring-security by spring-projects.
the class PayloadExchangeMatcherReactiveAuthorizationManagerTests method checkWhenSecondMatchThenSecondUsed.
@Test
public void checkWhenSecondMatchThenSecondUsed() {
AuthorizationDecision expected = new AuthorizationDecision(true);
given(this.authz2.check(any(), any())).willReturn(Mono.just(expected));
PayloadExchangeMatcherReactiveAuthorizationManager manager = PayloadExchangeMatcherReactiveAuthorizationManager.builder().add(new PayloadExchangeMatcherEntry<>((e) -> PayloadExchangeMatcher.MatchResult.notMatch(), this.authz)).add(new PayloadExchangeMatcherEntry<>(PayloadExchangeMatchers.anyExchange(), this.authz2)).build();
assertThat(manager.check(Mono.empty(), this.exchange).block()).isEqualTo(expected);
}
Aggregations