|
@@ -36,9 +36,9 @@ import org.springframework.test.context.ContextConfiguration;
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
|
|
|
+import static org.mockito.BDDMockito.given;
|
|
import static org.mockito.Mockito.mock;
|
|
import static org.mockito.Mockito.mock;
|
|
import static org.mockito.Mockito.reset;
|
|
import static org.mockito.Mockito.reset;
|
|
-import static org.mockito.Mockito.when;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author Rob Winch
|
|
* @author Rob Winch
|
|
@@ -80,7 +80,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void monoWhenPermitAllThenAopDoesNotSubscribe() {
|
|
public void monoWhenPermitAllThenAopDoesNotSubscribe() {
|
|
- when(this.delegate.monoFindById(1L)).thenReturn(Mono.from(this.result));
|
|
|
|
|
|
+ given(this.delegate.monoFindById(1L)).willReturn(Mono.from(this.result));
|
|
|
|
|
|
this.delegate.monoFindById(1L);
|
|
this.delegate.monoFindById(1L);
|
|
|
|
|
|
@@ -89,14 +89,14 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void monoWhenPermitAllThenSuccess() {
|
|
public void monoWhenPermitAllThenSuccess() {
|
|
- when(this.delegate.monoFindById(1L)).thenReturn(Mono.just("success"));
|
|
|
|
|
|
+ given(this.delegate.monoFindById(1L)).willReturn(Mono.just("success"));
|
|
|
|
|
|
StepVerifier.create(this.delegate.monoFindById(1L)).expectNext("success").verifyComplete();
|
|
StepVerifier.create(this.delegate.monoFindById(1L)).expectNext("success").verifyComplete();
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void monoPreAuthorizeHasRoleWhenGrantedThenSuccess() {
|
|
public void monoPreAuthorizeHasRoleWhenGrantedThenSuccess() {
|
|
- when(this.delegate.monoPreAuthorizeHasRoleFindById(1L)).thenReturn(Mono.just("result"));
|
|
|
|
|
|
+ given(this.delegate.monoPreAuthorizeHasRoleFindById(1L)).willReturn(Mono.just("result"));
|
|
|
|
|
|
Mono<String> findById = this.messageService.monoPreAuthorizeHasRoleFindById(1L)
|
|
Mono<String> findById = this.messageService.monoPreAuthorizeHasRoleFindById(1L)
|
|
.subscriberContext(this.withAdmin);
|
|
.subscriberContext(this.withAdmin);
|
|
@@ -105,7 +105,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void monoPreAuthorizeHasRoleWhenNoAuthenticationThenDenied() {
|
|
public void monoPreAuthorizeHasRoleWhenNoAuthenticationThenDenied() {
|
|
- when(this.delegate.monoPreAuthorizeHasRoleFindById(1L)).thenReturn(Mono.from(this.result));
|
|
|
|
|
|
+ given(this.delegate.monoPreAuthorizeHasRoleFindById(1L)).willReturn(Mono.from(this.result));
|
|
|
|
|
|
Mono<String> findById = this.messageService.monoPreAuthorizeHasRoleFindById(1L);
|
|
Mono<String> findById = this.messageService.monoPreAuthorizeHasRoleFindById(1L);
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
@@ -115,7 +115,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void monoPreAuthorizeHasRoleWhenNotAuthorizedThenDenied() {
|
|
public void monoPreAuthorizeHasRoleWhenNotAuthorizedThenDenied() {
|
|
- when(this.delegate.monoPreAuthorizeHasRoleFindById(1L)).thenReturn(Mono.from(this.result));
|
|
|
|
|
|
+ given(this.delegate.monoPreAuthorizeHasRoleFindById(1L)).willReturn(Mono.from(this.result));
|
|
|
|
|
|
Mono<String> findById = this.messageService.monoPreAuthorizeHasRoleFindById(1L)
|
|
Mono<String> findById = this.messageService.monoPreAuthorizeHasRoleFindById(1L)
|
|
.subscriberContext(this.withUser);
|
|
.subscriberContext(this.withUser);
|
|
@@ -126,7 +126,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void monoPreAuthorizeBeanWhenGrantedThenSuccess() {
|
|
public void monoPreAuthorizeBeanWhenGrantedThenSuccess() {
|
|
- when(this.delegate.monoPreAuthorizeBeanFindById(2L)).thenReturn(Mono.just("result"));
|
|
|
|
|
|
+ given(this.delegate.monoPreAuthorizeBeanFindById(2L)).willReturn(Mono.just("result"));
|
|
|
|
|
|
Mono<String> findById = this.messageService.monoPreAuthorizeBeanFindById(2L).subscriberContext(this.withAdmin);
|
|
Mono<String> findById = this.messageService.monoPreAuthorizeBeanFindById(2L).subscriberContext(this.withAdmin);
|
|
StepVerifier.create(findById).expectNext("result").verifyComplete();
|
|
StepVerifier.create(findById).expectNext("result").verifyComplete();
|
|
@@ -134,7 +134,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void monoPreAuthorizeBeanWhenNotAuthenticatedAndGrantedThenSuccess() {
|
|
public void monoPreAuthorizeBeanWhenNotAuthenticatedAndGrantedThenSuccess() {
|
|
- when(this.delegate.monoPreAuthorizeBeanFindById(2L)).thenReturn(Mono.just("result"));
|
|
|
|
|
|
+ given(this.delegate.monoPreAuthorizeBeanFindById(2L)).willReturn(Mono.just("result"));
|
|
|
|
|
|
Mono<String> findById = this.messageService.monoPreAuthorizeBeanFindById(2L);
|
|
Mono<String> findById = this.messageService.monoPreAuthorizeBeanFindById(2L);
|
|
StepVerifier.create(findById).expectNext("result").verifyComplete();
|
|
StepVerifier.create(findById).expectNext("result").verifyComplete();
|
|
@@ -142,7 +142,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void monoPreAuthorizeBeanWhenNoAuthenticationThenDenied() {
|
|
public void monoPreAuthorizeBeanWhenNoAuthenticationThenDenied() {
|
|
- when(this.delegate.monoPreAuthorizeBeanFindById(1L)).thenReturn(Mono.from(this.result));
|
|
|
|
|
|
+ given(this.delegate.monoPreAuthorizeBeanFindById(1L)).willReturn(Mono.from(this.result));
|
|
|
|
|
|
Mono<String> findById = this.messageService.monoPreAuthorizeBeanFindById(1L);
|
|
Mono<String> findById = this.messageService.monoPreAuthorizeBeanFindById(1L);
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
@@ -152,7 +152,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void monoPreAuthorizeBeanWhenNotAuthorizedThenDenied() {
|
|
public void monoPreAuthorizeBeanWhenNotAuthorizedThenDenied() {
|
|
- when(this.delegate.monoPreAuthorizeBeanFindById(1L)).thenReturn(Mono.from(this.result));
|
|
|
|
|
|
+ given(this.delegate.monoPreAuthorizeBeanFindById(1L)).willReturn(Mono.from(this.result));
|
|
|
|
|
|
Mono<String> findById = this.messageService.monoPreAuthorizeBeanFindById(1L).subscriberContext(this.withUser);
|
|
Mono<String> findById = this.messageService.monoPreAuthorizeBeanFindById(1L).subscriberContext(this.withUser);
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
@@ -162,7 +162,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void monoPostAuthorizeWhenAuthorizedThenSuccess() {
|
|
public void monoPostAuthorizeWhenAuthorizedThenSuccess() {
|
|
- when(this.delegate.monoPostAuthorizeFindById(1L)).thenReturn(Mono.just("user"));
|
|
|
|
|
|
+ given(this.delegate.monoPostAuthorizeFindById(1L)).willReturn(Mono.just("user"));
|
|
|
|
|
|
Mono<String> findById = this.messageService.monoPostAuthorizeFindById(1L).subscriberContext(this.withUser);
|
|
Mono<String> findById = this.messageService.monoPostAuthorizeFindById(1L).subscriberContext(this.withUser);
|
|
StepVerifier.create(findById).expectNext("user").verifyComplete();
|
|
StepVerifier.create(findById).expectNext("user").verifyComplete();
|
|
@@ -170,7 +170,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void monoPostAuthorizeWhenNotAuthorizedThenDenied() {
|
|
public void monoPostAuthorizeWhenNotAuthorizedThenDenied() {
|
|
- when(this.delegate.monoPostAuthorizeBeanFindById(1L)).thenReturn(Mono.just("not-authorized"));
|
|
|
|
|
|
+ given(this.delegate.monoPostAuthorizeBeanFindById(1L)).willReturn(Mono.just("not-authorized"));
|
|
|
|
|
|
Mono<String> findById = this.messageService.monoPostAuthorizeBeanFindById(1L).subscriberContext(this.withUser);
|
|
Mono<String> findById = this.messageService.monoPostAuthorizeBeanFindById(1L).subscriberContext(this.withUser);
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
@@ -178,7 +178,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void monoPostAuthorizeWhenBeanAndAuthorizedThenSuccess() {
|
|
public void monoPostAuthorizeWhenBeanAndAuthorizedThenSuccess() {
|
|
- when(this.delegate.monoPostAuthorizeBeanFindById(2L)).thenReturn(Mono.just("user"));
|
|
|
|
|
|
+ given(this.delegate.monoPostAuthorizeBeanFindById(2L)).willReturn(Mono.just("user"));
|
|
|
|
|
|
Mono<String> findById = this.messageService.monoPostAuthorizeBeanFindById(2L).subscriberContext(this.withUser);
|
|
Mono<String> findById = this.messageService.monoPostAuthorizeBeanFindById(2L).subscriberContext(this.withUser);
|
|
StepVerifier.create(findById).expectNext("user").verifyComplete();
|
|
StepVerifier.create(findById).expectNext("user").verifyComplete();
|
|
@@ -186,7 +186,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void monoPostAuthorizeWhenBeanAndNotAuthenticatedAndAuthorizedThenSuccess() {
|
|
public void monoPostAuthorizeWhenBeanAndNotAuthenticatedAndAuthorizedThenSuccess() {
|
|
- when(this.delegate.monoPostAuthorizeBeanFindById(2L)).thenReturn(Mono.just("anonymous"));
|
|
|
|
|
|
+ given(this.delegate.monoPostAuthorizeBeanFindById(2L)).willReturn(Mono.just("anonymous"));
|
|
|
|
|
|
Mono<String> findById = this.messageService.monoPostAuthorizeBeanFindById(2L);
|
|
Mono<String> findById = this.messageService.monoPostAuthorizeBeanFindById(2L);
|
|
StepVerifier.create(findById).expectNext("anonymous").verifyComplete();
|
|
StepVerifier.create(findById).expectNext("anonymous").verifyComplete();
|
|
@@ -194,7 +194,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void monoPostAuthorizeWhenBeanAndNotAuthorizedThenDenied() {
|
|
public void monoPostAuthorizeWhenBeanAndNotAuthorizedThenDenied() {
|
|
- when(this.delegate.monoPostAuthorizeBeanFindById(1L)).thenReturn(Mono.just("not-authorized"));
|
|
|
|
|
|
+ given(this.delegate.monoPostAuthorizeBeanFindById(1L)).willReturn(Mono.just("not-authorized"));
|
|
|
|
|
|
Mono<String> findById = this.messageService.monoPostAuthorizeBeanFindById(1L).subscriberContext(this.withUser);
|
|
Mono<String> findById = this.messageService.monoPostAuthorizeBeanFindById(1L).subscriberContext(this.withUser);
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
@@ -204,7 +204,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void fluxWhenPermitAllThenAopDoesNotSubscribe() {
|
|
public void fluxWhenPermitAllThenAopDoesNotSubscribe() {
|
|
- when(this.delegate.fluxFindById(1L)).thenReturn(Flux.from(this.result));
|
|
|
|
|
|
+ given(this.delegate.fluxFindById(1L)).willReturn(Flux.from(this.result));
|
|
|
|
|
|
this.delegate.fluxFindById(1L);
|
|
this.delegate.fluxFindById(1L);
|
|
|
|
|
|
@@ -213,14 +213,14 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void fluxWhenPermitAllThenSuccess() {
|
|
public void fluxWhenPermitAllThenSuccess() {
|
|
- when(this.delegate.fluxFindById(1L)).thenReturn(Flux.just("success"));
|
|
|
|
|
|
+ given(this.delegate.fluxFindById(1L)).willReturn(Flux.just("success"));
|
|
|
|
|
|
StepVerifier.create(this.delegate.fluxFindById(1L)).expectNext("success").verifyComplete();
|
|
StepVerifier.create(this.delegate.fluxFindById(1L)).expectNext("success").verifyComplete();
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void fluxPreAuthorizeHasRoleWhenGrantedThenSuccess() {
|
|
public void fluxPreAuthorizeHasRoleWhenGrantedThenSuccess() {
|
|
- when(this.delegate.fluxPreAuthorizeHasRoleFindById(1L)).thenReturn(Flux.just("result"));
|
|
|
|
|
|
+ given(this.delegate.fluxPreAuthorizeHasRoleFindById(1L)).willReturn(Flux.just("result"));
|
|
|
|
|
|
Flux<String> findById = this.messageService.fluxPreAuthorizeHasRoleFindById(1L)
|
|
Flux<String> findById = this.messageService.fluxPreAuthorizeHasRoleFindById(1L)
|
|
.subscriberContext(this.withAdmin);
|
|
.subscriberContext(this.withAdmin);
|
|
@@ -230,7 +230,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void fluxPreAuthorizeHasRoleWhenNoAuthenticationThenDenied() {
|
|
public void fluxPreAuthorizeHasRoleWhenNoAuthenticationThenDenied() {
|
|
- when(this.delegate.fluxPreAuthorizeHasRoleFindById(1L)).thenReturn(Flux.from(this.result));
|
|
|
|
|
|
+ given(this.delegate.fluxPreAuthorizeHasRoleFindById(1L)).willReturn(Flux.from(this.result));
|
|
|
|
|
|
Flux<String> findById = this.messageService.fluxPreAuthorizeHasRoleFindById(1L);
|
|
Flux<String> findById = this.messageService.fluxPreAuthorizeHasRoleFindById(1L);
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
@@ -240,7 +240,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void fluxPreAuthorizeHasRoleWhenNotAuthorizedThenDenied() {
|
|
public void fluxPreAuthorizeHasRoleWhenNotAuthorizedThenDenied() {
|
|
- when(this.delegate.fluxPreAuthorizeHasRoleFindById(1L)).thenReturn(Flux.from(this.result));
|
|
|
|
|
|
+ given(this.delegate.fluxPreAuthorizeHasRoleFindById(1L)).willReturn(Flux.from(this.result));
|
|
|
|
|
|
Flux<String> findById = this.messageService.fluxPreAuthorizeHasRoleFindById(1L)
|
|
Flux<String> findById = this.messageService.fluxPreAuthorizeHasRoleFindById(1L)
|
|
.subscriberContext(this.withUser);
|
|
.subscriberContext(this.withUser);
|
|
@@ -251,7 +251,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void fluxPreAuthorizeBeanWhenGrantedThenSuccess() {
|
|
public void fluxPreAuthorizeBeanWhenGrantedThenSuccess() {
|
|
- when(this.delegate.fluxPreAuthorizeBeanFindById(2L)).thenReturn(Flux.just("result"));
|
|
|
|
|
|
+ given(this.delegate.fluxPreAuthorizeBeanFindById(2L)).willReturn(Flux.just("result"));
|
|
|
|
|
|
Flux<String> findById = this.messageService.fluxPreAuthorizeBeanFindById(2L).subscriberContext(this.withAdmin);
|
|
Flux<String> findById = this.messageService.fluxPreAuthorizeBeanFindById(2L).subscriberContext(this.withAdmin);
|
|
StepVerifier.create(findById).expectNext("result").verifyComplete();
|
|
StepVerifier.create(findById).expectNext("result").verifyComplete();
|
|
@@ -259,7 +259,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void fluxPreAuthorizeBeanWhenNotAuthenticatedAndGrantedThenSuccess() {
|
|
public void fluxPreAuthorizeBeanWhenNotAuthenticatedAndGrantedThenSuccess() {
|
|
- when(this.delegate.fluxPreAuthorizeBeanFindById(2L)).thenReturn(Flux.just("result"));
|
|
|
|
|
|
+ given(this.delegate.fluxPreAuthorizeBeanFindById(2L)).willReturn(Flux.just("result"));
|
|
|
|
|
|
Flux<String> findById = this.messageService.fluxPreAuthorizeBeanFindById(2L);
|
|
Flux<String> findById = this.messageService.fluxPreAuthorizeBeanFindById(2L);
|
|
StepVerifier.create(findById).expectNext("result").verifyComplete();
|
|
StepVerifier.create(findById).expectNext("result").verifyComplete();
|
|
@@ -267,7 +267,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void fluxPreAuthorizeBeanWhenNoAuthenticationThenDenied() {
|
|
public void fluxPreAuthorizeBeanWhenNoAuthenticationThenDenied() {
|
|
- when(this.delegate.fluxPreAuthorizeBeanFindById(1L)).thenReturn(Flux.from(this.result));
|
|
|
|
|
|
+ given(this.delegate.fluxPreAuthorizeBeanFindById(1L)).willReturn(Flux.from(this.result));
|
|
|
|
|
|
Flux<String> findById = this.messageService.fluxPreAuthorizeBeanFindById(1L);
|
|
Flux<String> findById = this.messageService.fluxPreAuthorizeBeanFindById(1L);
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
@@ -277,7 +277,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void fluxPreAuthorizeBeanWhenNotAuthorizedThenDenied() {
|
|
public void fluxPreAuthorizeBeanWhenNotAuthorizedThenDenied() {
|
|
- when(this.delegate.fluxPreAuthorizeBeanFindById(1L)).thenReturn(Flux.from(this.result));
|
|
|
|
|
|
+ given(this.delegate.fluxPreAuthorizeBeanFindById(1L)).willReturn(Flux.from(this.result));
|
|
|
|
|
|
Flux<String> findById = this.messageService.fluxPreAuthorizeBeanFindById(1L).subscriberContext(this.withUser);
|
|
Flux<String> findById = this.messageService.fluxPreAuthorizeBeanFindById(1L).subscriberContext(this.withUser);
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
@@ -287,7 +287,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void fluxPostAuthorizeWhenAuthorizedThenSuccess() {
|
|
public void fluxPostAuthorizeWhenAuthorizedThenSuccess() {
|
|
- when(this.delegate.fluxPostAuthorizeFindById(1L)).thenReturn(Flux.just("user"));
|
|
|
|
|
|
+ given(this.delegate.fluxPostAuthorizeFindById(1L)).willReturn(Flux.just("user"));
|
|
|
|
|
|
Flux<String> findById = this.messageService.fluxPostAuthorizeFindById(1L).subscriberContext(this.withUser);
|
|
Flux<String> findById = this.messageService.fluxPostAuthorizeFindById(1L).subscriberContext(this.withUser);
|
|
StepVerifier.create(findById).expectNext("user").verifyComplete();
|
|
StepVerifier.create(findById).expectNext("user").verifyComplete();
|
|
@@ -295,7 +295,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void fluxPostAuthorizeWhenNotAuthorizedThenDenied() {
|
|
public void fluxPostAuthorizeWhenNotAuthorizedThenDenied() {
|
|
- when(this.delegate.fluxPostAuthorizeBeanFindById(1L)).thenReturn(Flux.just("not-authorized"));
|
|
|
|
|
|
+ given(this.delegate.fluxPostAuthorizeBeanFindById(1L)).willReturn(Flux.just("not-authorized"));
|
|
|
|
|
|
Flux<String> findById = this.messageService.fluxPostAuthorizeBeanFindById(1L).subscriberContext(this.withUser);
|
|
Flux<String> findById = this.messageService.fluxPostAuthorizeBeanFindById(1L).subscriberContext(this.withUser);
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
@@ -303,7 +303,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void fluxPostAuthorizeWhenBeanAndAuthorizedThenSuccess() {
|
|
public void fluxPostAuthorizeWhenBeanAndAuthorizedThenSuccess() {
|
|
- when(this.delegate.fluxPostAuthorizeBeanFindById(2L)).thenReturn(Flux.just("user"));
|
|
|
|
|
|
+ given(this.delegate.fluxPostAuthorizeBeanFindById(2L)).willReturn(Flux.just("user"));
|
|
|
|
|
|
Flux<String> findById = this.messageService.fluxPostAuthorizeBeanFindById(2L).subscriberContext(this.withUser);
|
|
Flux<String> findById = this.messageService.fluxPostAuthorizeBeanFindById(2L).subscriberContext(this.withUser);
|
|
StepVerifier.create(findById).expectNext("user").verifyComplete();
|
|
StepVerifier.create(findById).expectNext("user").verifyComplete();
|
|
@@ -311,7 +311,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void fluxPostAuthorizeWhenBeanAndNotAuthenticatedAndAuthorizedThenSuccess() {
|
|
public void fluxPostAuthorizeWhenBeanAndNotAuthenticatedAndAuthorizedThenSuccess() {
|
|
- when(this.delegate.fluxPostAuthorizeBeanFindById(2L)).thenReturn(Flux.just("anonymous"));
|
|
|
|
|
|
+ given(this.delegate.fluxPostAuthorizeBeanFindById(2L)).willReturn(Flux.just("anonymous"));
|
|
|
|
|
|
Flux<String> findById = this.messageService.fluxPostAuthorizeBeanFindById(2L);
|
|
Flux<String> findById = this.messageService.fluxPostAuthorizeBeanFindById(2L);
|
|
StepVerifier.create(findById).expectNext("anonymous").verifyComplete();
|
|
StepVerifier.create(findById).expectNext("anonymous").verifyComplete();
|
|
@@ -319,7 +319,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void fluxPostAuthorizeWhenBeanAndNotAuthorizedThenDenied() {
|
|
public void fluxPostAuthorizeWhenBeanAndNotAuthorizedThenDenied() {
|
|
- when(this.delegate.fluxPostAuthorizeBeanFindById(1L)).thenReturn(Flux.just("not-authorized"));
|
|
|
|
|
|
+ given(this.delegate.fluxPostAuthorizeBeanFindById(1L)).willReturn(Flux.just("not-authorized"));
|
|
|
|
|
|
Flux<String> findById = this.messageService.fluxPostAuthorizeBeanFindById(1L).subscriberContext(this.withUser);
|
|
Flux<String> findById = this.messageService.fluxPostAuthorizeBeanFindById(1L).subscriberContext(this.withUser);
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
@@ -329,7 +329,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void publisherWhenPermitAllThenAopDoesNotSubscribe() {
|
|
public void publisherWhenPermitAllThenAopDoesNotSubscribe() {
|
|
- when(this.delegate.publisherFindById(1L)).thenReturn(this.result);
|
|
|
|
|
|
+ given(this.delegate.publisherFindById(1L)).willReturn(this.result);
|
|
|
|
|
|
this.delegate.publisherFindById(1L);
|
|
this.delegate.publisherFindById(1L);
|
|
|
|
|
|
@@ -338,14 +338,14 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void publisherWhenPermitAllThenSuccess() {
|
|
public void publisherWhenPermitAllThenSuccess() {
|
|
- when(this.delegate.publisherFindById(1L)).thenReturn(publisherJust("success"));
|
|
|
|
|
|
+ given(this.delegate.publisherFindById(1L)).willReturn(publisherJust("success"));
|
|
|
|
|
|
StepVerifier.create(this.delegate.publisherFindById(1L)).expectNext("success").verifyComplete();
|
|
StepVerifier.create(this.delegate.publisherFindById(1L)).expectNext("success").verifyComplete();
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void publisherPreAuthorizeHasRoleWhenGrantedThenSuccess() {
|
|
public void publisherPreAuthorizeHasRoleWhenGrantedThenSuccess() {
|
|
- when(this.delegate.publisherPreAuthorizeHasRoleFindById(1L)).thenReturn(publisherJust("result"));
|
|
|
|
|
|
+ given(this.delegate.publisherPreAuthorizeHasRoleFindById(1L)).willReturn(publisherJust("result"));
|
|
|
|
|
|
Publisher<String> findById = Flux.from(this.messageService.publisherPreAuthorizeHasRoleFindById(1L))
|
|
Publisher<String> findById = Flux.from(this.messageService.publisherPreAuthorizeHasRoleFindById(1L))
|
|
.subscriberContext(this.withAdmin);
|
|
.subscriberContext(this.withAdmin);
|
|
@@ -355,7 +355,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void publisherPreAuthorizeHasRoleWhenNoAuthenticationThenDenied() {
|
|
public void publisherPreAuthorizeHasRoleWhenNoAuthenticationThenDenied() {
|
|
- when(this.delegate.publisherPreAuthorizeHasRoleFindById(1L)).thenReturn(this.result);
|
|
|
|
|
|
+ given(this.delegate.publisherPreAuthorizeHasRoleFindById(1L)).willReturn(this.result);
|
|
|
|
|
|
Publisher<String> findById = this.messageService.publisherPreAuthorizeHasRoleFindById(1L);
|
|
Publisher<String> findById = this.messageService.publisherPreAuthorizeHasRoleFindById(1L);
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
@@ -365,7 +365,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void publisherPreAuthorizeHasRoleWhenNotAuthorizedThenDenied() {
|
|
public void publisherPreAuthorizeHasRoleWhenNotAuthorizedThenDenied() {
|
|
- when(this.delegate.publisherPreAuthorizeHasRoleFindById(1L)).thenReturn(this.result);
|
|
|
|
|
|
+ given(this.delegate.publisherPreAuthorizeHasRoleFindById(1L)).willReturn(this.result);
|
|
|
|
|
|
Publisher<String> findById = Flux.from(this.messageService.publisherPreAuthorizeHasRoleFindById(1L))
|
|
Publisher<String> findById = Flux.from(this.messageService.publisherPreAuthorizeHasRoleFindById(1L))
|
|
.subscriberContext(this.withUser);
|
|
.subscriberContext(this.withUser);
|
|
@@ -376,7 +376,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void publisherPreAuthorizeBeanWhenGrantedThenSuccess() {
|
|
public void publisherPreAuthorizeBeanWhenGrantedThenSuccess() {
|
|
- when(this.delegate.publisherPreAuthorizeBeanFindById(2L)).thenReturn(publisherJust("result"));
|
|
|
|
|
|
+ given(this.delegate.publisherPreAuthorizeBeanFindById(2L)).willReturn(publisherJust("result"));
|
|
|
|
|
|
Publisher<String> findById = Flux.from(this.messageService.publisherPreAuthorizeBeanFindById(2L))
|
|
Publisher<String> findById = Flux.from(this.messageService.publisherPreAuthorizeBeanFindById(2L))
|
|
.subscriberContext(this.withAdmin);
|
|
.subscriberContext(this.withAdmin);
|
|
@@ -385,7 +385,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void publisherPreAuthorizeBeanWhenNotAuthenticatedAndGrantedThenSuccess() {
|
|
public void publisherPreAuthorizeBeanWhenNotAuthenticatedAndGrantedThenSuccess() {
|
|
- when(this.delegate.publisherPreAuthorizeBeanFindById(2L)).thenReturn(publisherJust("result"));
|
|
|
|
|
|
+ given(this.delegate.publisherPreAuthorizeBeanFindById(2L)).willReturn(publisherJust("result"));
|
|
|
|
|
|
Publisher<String> findById = this.messageService.publisherPreAuthorizeBeanFindById(2L);
|
|
Publisher<String> findById = this.messageService.publisherPreAuthorizeBeanFindById(2L);
|
|
StepVerifier.create(findById).expectNext("result").verifyComplete();
|
|
StepVerifier.create(findById).expectNext("result").verifyComplete();
|
|
@@ -393,7 +393,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void publisherPreAuthorizeBeanWhenNoAuthenticationThenDenied() {
|
|
public void publisherPreAuthorizeBeanWhenNoAuthenticationThenDenied() {
|
|
- when(this.delegate.publisherPreAuthorizeBeanFindById(1L)).thenReturn(this.result);
|
|
|
|
|
|
+ given(this.delegate.publisherPreAuthorizeBeanFindById(1L)).willReturn(this.result);
|
|
|
|
|
|
Publisher<String> findById = this.messageService.publisherPreAuthorizeBeanFindById(1L);
|
|
Publisher<String> findById = this.messageService.publisherPreAuthorizeBeanFindById(1L);
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
StepVerifier.create(findById).expectError(AccessDeniedException.class).verify();
|
|
@@ -403,7 +403,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void publisherPreAuthorizeBeanWhenNotAuthorizedThenDenied() {
|
|
public void publisherPreAuthorizeBeanWhenNotAuthorizedThenDenied() {
|
|
- when(this.delegate.publisherPreAuthorizeBeanFindById(1L)).thenReturn(this.result);
|
|
|
|
|
|
+ given(this.delegate.publisherPreAuthorizeBeanFindById(1L)).willReturn(this.result);
|
|
|
|
|
|
Publisher<String> findById = Flux.from(this.messageService.publisherPreAuthorizeBeanFindById(1L))
|
|
Publisher<String> findById = Flux.from(this.messageService.publisherPreAuthorizeBeanFindById(1L))
|
|
.subscriberContext(this.withUser);
|
|
.subscriberContext(this.withUser);
|
|
@@ -414,7 +414,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void publisherPostAuthorizeWhenAuthorizedThenSuccess() {
|
|
public void publisherPostAuthorizeWhenAuthorizedThenSuccess() {
|
|
- when(this.delegate.publisherPostAuthorizeFindById(1L)).thenReturn(publisherJust("user"));
|
|
|
|
|
|
+ given(this.delegate.publisherPostAuthorizeFindById(1L)).willReturn(publisherJust("user"));
|
|
|
|
|
|
Publisher<String> findById = Flux.from(this.messageService.publisherPostAuthorizeFindById(1L))
|
|
Publisher<String> findById = Flux.from(this.messageService.publisherPostAuthorizeFindById(1L))
|
|
.subscriberContext(this.withUser);
|
|
.subscriberContext(this.withUser);
|
|
@@ -423,7 +423,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void publisherPostAuthorizeWhenNotAuthorizedThenDenied() {
|
|
public void publisherPostAuthorizeWhenNotAuthorizedThenDenied() {
|
|
- when(this.delegate.publisherPostAuthorizeBeanFindById(1L)).thenReturn(publisherJust("not-authorized"));
|
|
|
|
|
|
+ given(this.delegate.publisherPostAuthorizeBeanFindById(1L)).willReturn(publisherJust("not-authorized"));
|
|
|
|
|
|
Publisher<String> findById = Flux.from(this.messageService.publisherPostAuthorizeBeanFindById(1L))
|
|
Publisher<String> findById = Flux.from(this.messageService.publisherPostAuthorizeBeanFindById(1L))
|
|
.subscriberContext(this.withUser);
|
|
.subscriberContext(this.withUser);
|
|
@@ -432,7 +432,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void publisherPostAuthorizeWhenBeanAndAuthorizedThenSuccess() {
|
|
public void publisherPostAuthorizeWhenBeanAndAuthorizedThenSuccess() {
|
|
- when(this.delegate.publisherPostAuthorizeBeanFindById(2L)).thenReturn(publisherJust("user"));
|
|
|
|
|
|
+ given(this.delegate.publisherPostAuthorizeBeanFindById(2L)).willReturn(publisherJust("user"));
|
|
|
|
|
|
Publisher<String> findById = Flux.from(this.messageService.publisherPostAuthorizeBeanFindById(2L))
|
|
Publisher<String> findById = Flux.from(this.messageService.publisherPostAuthorizeBeanFindById(2L))
|
|
.subscriberContext(this.withUser);
|
|
.subscriberContext(this.withUser);
|
|
@@ -441,7 +441,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void publisherPostAuthorizeWhenBeanAndNotAuthenticatedAndAuthorizedThenSuccess() {
|
|
public void publisherPostAuthorizeWhenBeanAndNotAuthenticatedAndAuthorizedThenSuccess() {
|
|
- when(this.delegate.publisherPostAuthorizeBeanFindById(2L)).thenReturn(publisherJust("anonymous"));
|
|
|
|
|
|
+ given(this.delegate.publisherPostAuthorizeBeanFindById(2L)).willReturn(publisherJust("anonymous"));
|
|
|
|
|
|
Publisher<String> findById = this.messageService.publisherPostAuthorizeBeanFindById(2L);
|
|
Publisher<String> findById = this.messageService.publisherPostAuthorizeBeanFindById(2L);
|
|
StepVerifier.create(findById).expectNext("anonymous").verifyComplete();
|
|
StepVerifier.create(findById).expectNext("anonymous").verifyComplete();
|
|
@@ -449,7 +449,7 @@ public class EnableReactiveMethodSecurityTests {
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void publisherPostAuthorizeWhenBeanAndNotAuthorizedThenDenied() {
|
|
public void publisherPostAuthorizeWhenBeanAndNotAuthorizedThenDenied() {
|
|
- when(this.delegate.publisherPostAuthorizeBeanFindById(1L)).thenReturn(publisherJust("not-authorized"));
|
|
|
|
|
|
+ given(this.delegate.publisherPostAuthorizeBeanFindById(1L)).willReturn(publisherJust("not-authorized"));
|
|
|
|
|
|
Publisher<String> findById = Flux.from(this.messageService.publisherPostAuthorizeBeanFindById(1L))
|
|
Publisher<String> findById = Flux.from(this.messageService.publisherPostAuthorizeBeanFindById(1L))
|
|
.subscriberContext(this.withUser);
|
|
.subscriberContext(this.withUser);
|