@Test public void removeAuthorizedClientWhenClientRegistrationIdIsNullThenThrowIllegalArgumentException() { assertThatThrownBy(() -> this.authorizedClientRepository.removeAuthorizedClient( null, null, this.exchange)).isInstanceOf(IllegalArgumentException.class); }
@Test public void removeAuthorizedClientWhenRequestIsNullThenThrowIllegalArgumentException() { assertThatThrownBy(() -> this.authorizedClientRepository.removeAuthorizedClient( this.registrationId1, null, null)).isInstanceOf(IllegalArgumentException.class); }
@Test public void removeAuthorizedClientWhenPrincipalNameIsNullThenExceptionNotThrown() { this.authorizedClientRepository.removeAuthorizedClient(this.registrationId1, null, this.exchange); }
@Test public void removeAuthorizedClientWhenNotSavedThenSessionNotCreated() { this.authorizedClientRepository.removeAuthorizedClient( this.registrationId2, null, this.exchange); assertThat(this.exchange.getSession().block().isStarted()).isFalse(); }
@Test public void removeAuthorizedClientWhenClient1SavedAndClient2RemovedThenClient1NotRemoved() { OAuth2AuthorizedClient authorizedClient1 = new OAuth2AuthorizedClient( this.registration1, this.principalName1, mock(OAuth2AccessToken.class)); this.authorizedClientRepository.saveAuthorizedClient(authorizedClient1, null, this.exchange).block(); // Remove registrationId2 (never added so is not removed either) this.authorizedClientRepository.removeAuthorizedClient( this.registrationId2, null, this.exchange); OAuth2AuthorizedClient loadedAuthorizedClient1 = this.authorizedClientRepository.loadAuthorizedClient( this.registrationId1, null, this.exchange).block(); assertThat(loadedAuthorizedClient1).isNotNull(); assertThat(loadedAuthorizedClient1).isSameAs(authorizedClient1); }
@Test public void removeAuthorizedClientWhenSavedThenRemovedFromSession() { OAuth2AuthorizedClient authorizedClient = new OAuth2AuthorizedClient( this.registration1, this.principalName1, mock(OAuth2AccessToken.class)); this.authorizedClientRepository.saveAuthorizedClient(authorizedClient, null, this.exchange).block(); OAuth2AuthorizedClient loadedAuthorizedClient = this.authorizedClientRepository.loadAuthorizedClient( this.registrationId1, null, this.exchange).block(); assertThat(loadedAuthorizedClient).isSameAs(authorizedClient); this.authorizedClientRepository.removeAuthorizedClient( this.registrationId1, null, this.exchange).block(); WebSession session = this.exchange.getSession().block(); assertThat(session).isNotNull(); assertThat(session.getAttributes()).isEmpty(); }
@Test public void removeAuthorizedClientWhenClient1Client2SavedAndClient1RemovedThenClient2NotRemoved() { OAuth2AuthorizedClient authorizedClient1 = new OAuth2AuthorizedClient( this.registration1, this.principalName1, mock(OAuth2AccessToken.class)); this.authorizedClientRepository.saveAuthorizedClient(authorizedClient1, null, this.exchange).block(); OAuth2AuthorizedClient authorizedClient2 = new OAuth2AuthorizedClient( this.registration2, this.principalName1, mock(OAuth2AccessToken.class)); this.authorizedClientRepository.saveAuthorizedClient(authorizedClient2, null, this.exchange).block(); this.authorizedClientRepository.removeAuthorizedClient( this.registrationId1, null, this.exchange).block(); OAuth2AuthorizedClient loadedAuthorizedClient2 = this.authorizedClientRepository.loadAuthorizedClient( this.registrationId2, null, this.exchange).block(); assertThat(loadedAuthorizedClient2).isNotNull(); assertThat(loadedAuthorizedClient2).isSameAs(authorizedClient2); } }
@Test public void removeAuthorizedClientWhenSavedThenRemoved() { OAuth2AuthorizedClient authorizedClient = new OAuth2AuthorizedClient( this.registration2, this.principalName1, mock(OAuth2AccessToken.class)); this.authorizedClientRepository.saveAuthorizedClient(authorizedClient, null, this.exchange).block(); OAuth2AuthorizedClient loadedAuthorizedClient = this.authorizedClientRepository.loadAuthorizedClient( this.registrationId2, null, this.exchange).block(); assertThat(loadedAuthorizedClient).isSameAs(authorizedClient); this.authorizedClientRepository.removeAuthorizedClient( this.registrationId2, null, this.exchange).block(); loadedAuthorizedClient = this.authorizedClientRepository.loadAuthorizedClient( this.registrationId2, null, this.exchange).block(); assertThat(loadedAuthorizedClient).isNull(); }