@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 removeAuthorizedClientWhenAuthenticatedPrincipalThenRemoveFromService() { when(this.authorizedClientService.removeAuthorizedClient(any(), any())).thenReturn(Mono.empty()); Authentication authentication = this.createAuthenticatedPrincipal(); this.authorizedClientRepository.removeAuthorizedClient(this.registrationId, authentication, this.exchange).block(); verify(this.authorizedClientService).removeAuthorizedClient(this.registrationId, this.principalName); }
@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); }
@Test public void loadAuthorizedClientWhenAnonymousPrincipalThenLoadFromAnonymousRepository() { when(this.anonymousAuthorizedClientRepository.loadAuthorizedClient(any(), any(), any())).thenReturn(Mono.empty()); Authentication authentication = this.createAnonymousPrincipal(); this.authorizedClientRepository.loadAuthorizedClient(this.registrationId, authentication, this.exchange).block(); verify(this.anonymousAuthorizedClientRepository).loadAuthorizedClient(this.registrationId, authentication, this.exchange); }
@Test public void loadAuthorizedClientWhenAuthenticatedPrincipalThenLoadFromService() { when(this.authorizedClientService.loadAuthorizedClient(any(), any())).thenReturn(Mono.empty()); Authentication authentication = this.createAuthenticatedPrincipal(); this.authorizedClientRepository.loadAuthorizedClient(this.registrationId, authentication, this.exchange).block(); verify(this.authorizedClientService).loadAuthorizedClient(this.registrationId, this.principalName); }
@Test public void removeAuthorizedClientWhenAnonymousPrincipalThenRemoveFromAnonymousRepository() { when(this.anonymousAuthorizedClientRepository.removeAuthorizedClient(any(), any(), any())).thenReturn(Mono.empty()); Authentication authentication = this.createAnonymousPrincipal(); this.authorizedClientRepository.removeAuthorizedClient(this.registrationId, authentication, this.exchange).block(); verify(this.anonymousAuthorizedClientRepository).removeAuthorizedClient(this.registrationId, authentication, this.exchange); }