- Common ways to obtain AuthenticatedPrincipalServerOAuth2AuthorizedClientRepository
private void myMethod () {AuthenticatedPrincipalServerOAuth2AuthorizedClientRepository a =
ReactiveOAuth2AuthorizedClientService authorizedClientService;new AuthenticatedPrincipalServerOAuth2AuthorizedClientRepository(authorizedClientService)
- Smart code suggestions by Codota
}
@Test public void saveAuthorizedClientWhenAnonymousPrincipalThenSaveToAnonymousRepository() { when(this.anonymousAuthorizedClientRepository.saveAuthorizedClient(any(), any(), any())).thenReturn(Mono.empty()); Authentication authentication = this.createAnonymousPrincipal(); OAuth2AuthorizedClient authorizedClient = mock(OAuth2AuthorizedClient.class); this.authorizedClientRepository.saveAuthorizedClient(authorizedClient, authentication, this.exchange).block(); verify(this.anonymousAuthorizedClientRepository).saveAuthorizedClient(authorizedClient, authentication, this.exchange); }
@Test public void saveAuthorizedClientWhenAuthenticatedPrincipalThenSaveToService() { when(this.authorizedClientService.saveAuthorizedClient(any(), any())).thenReturn(Mono.empty()); Authentication authentication = this.createAuthenticatedPrincipal(); OAuth2AuthorizedClient authorizedClient = mock(OAuth2AuthorizedClient.class); this.authorizedClientRepository.saveAuthorizedClient(authorizedClient, authentication, this.exchange).block(); verify(this.authorizedClientService).saveAuthorizedClient(authorizedClient, authentication); }