|
@@ -36,6 +36,7 @@ import org.springframework.security.oauth2.core.TestOAuth2RefreshTokens;
|
|
import org.springframework.security.oauth2.core.endpoint.OAuth2ParameterNames;
|
|
import org.springframework.security.oauth2.core.endpoint.OAuth2ParameterNames;
|
|
import org.springframework.web.server.ServerWebExchange;
|
|
import org.springframework.web.server.ServerWebExchange;
|
|
import reactor.core.publisher.Mono;
|
|
import reactor.core.publisher.Mono;
|
|
|
|
+import reactor.test.publisher.PublisherProbe;
|
|
import reactor.util.context.Context;
|
|
import reactor.util.context.Context;
|
|
|
|
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
@@ -64,6 +65,7 @@ public class DefaultReactiveOAuth2AuthorizedClientManagerTests {
|
|
private MockServerWebExchange serverWebExchange;
|
|
private MockServerWebExchange serverWebExchange;
|
|
private Context context;
|
|
private Context context;
|
|
private ArgumentCaptor<OAuth2AuthorizationContext> authorizationContextCaptor;
|
|
private ArgumentCaptor<OAuth2AuthorizationContext> authorizationContextCaptor;
|
|
|
|
+ private PublisherProbe<Void> saveAuthorizedClientProbe;
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@SuppressWarnings("unchecked")
|
|
@Before
|
|
@Before
|
|
@@ -74,8 +76,9 @@ public class DefaultReactiveOAuth2AuthorizedClientManagerTests {
|
|
this.authorizedClientRepository = mock(ServerOAuth2AuthorizedClientRepository.class);
|
|
this.authorizedClientRepository = mock(ServerOAuth2AuthorizedClientRepository.class);
|
|
when(this.authorizedClientRepository.loadAuthorizedClient(
|
|
when(this.authorizedClientRepository.loadAuthorizedClient(
|
|
anyString(), any(Authentication.class), any(ServerWebExchange.class))).thenReturn(Mono.empty());
|
|
anyString(), any(Authentication.class), any(ServerWebExchange.class))).thenReturn(Mono.empty());
|
|
|
|
+ this.saveAuthorizedClientProbe = PublisherProbe.empty();
|
|
when(this.authorizedClientRepository.saveAuthorizedClient(
|
|
when(this.authorizedClientRepository.saveAuthorizedClient(
|
|
- any(OAuth2AuthorizedClient.class), any(Authentication.class), any(ServerWebExchange.class))).thenReturn(Mono.empty());
|
|
|
|
|
|
+ any(OAuth2AuthorizedClient.class), any(Authentication.class), any(ServerWebExchange.class))).thenReturn(this.saveAuthorizedClientProbe.mono());
|
|
this.authorizedClientProvider = mock(ReactiveOAuth2AuthorizedClientProvider.class);
|
|
this.authorizedClientProvider = mock(ReactiveOAuth2AuthorizedClientProvider.class);
|
|
when(this.authorizedClientProvider.authorize(any(OAuth2AuthorizationContext.class))).thenReturn(Mono.empty());
|
|
when(this.authorizedClientProvider.authorize(any(OAuth2AuthorizationContext.class))).thenReturn(Mono.empty());
|
|
this.contextAttributesMapper = mock(Function.class);
|
|
this.contextAttributesMapper = mock(Function.class);
|
|
@@ -187,6 +190,7 @@ public class DefaultReactiveOAuth2AuthorizedClientManagerTests {
|
|
assertThat(authorizedClient).isSameAs(this.authorizedClient);
|
|
assertThat(authorizedClient).isSameAs(this.authorizedClient);
|
|
verify(this.authorizedClientRepository).saveAuthorizedClient(
|
|
verify(this.authorizedClientRepository).saveAuthorizedClient(
|
|
eq(this.authorizedClient), eq(this.principal), eq(this.serverWebExchange));
|
|
eq(this.authorizedClient), eq(this.principal), eq(this.serverWebExchange));
|
|
|
|
+ this.saveAuthorizedClientProbe.assertWasSubscribed();
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -245,6 +249,7 @@ public class DefaultReactiveOAuth2AuthorizedClientManagerTests {
|
|
assertThat(authorizedClient).isSameAs(reauthorizedClient);
|
|
assertThat(authorizedClient).isSameAs(reauthorizedClient);
|
|
verify(this.authorizedClientRepository).saveAuthorizedClient(
|
|
verify(this.authorizedClientRepository).saveAuthorizedClient(
|
|
eq(reauthorizedClient), eq(this.principal), eq(this.serverWebExchange));
|
|
eq(reauthorizedClient), eq(this.principal), eq(this.serverWebExchange));
|
|
|
|
+ this.saveAuthorizedClientProbe.assertWasSubscribed();
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -337,6 +342,7 @@ public class DefaultReactiveOAuth2AuthorizedClientManagerTests {
|
|
assertThat(authorizedClient).isSameAs(reauthorizedClient);
|
|
assertThat(authorizedClient).isSameAs(reauthorizedClient);
|
|
verify(this.authorizedClientRepository).saveAuthorizedClient(
|
|
verify(this.authorizedClientRepository).saveAuthorizedClient(
|
|
eq(reauthorizedClient), eq(this.principal), eq(this.serverWebExchange));
|
|
eq(reauthorizedClient), eq(this.principal), eq(this.serverWebExchange));
|
|
|
|
+ this.saveAuthorizedClientProbe.assertWasSubscribed();
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|