@Test public void filterWhenPathMatchesThenRequestSessionAttributeNotSaved() { this.filter.setRequestCache(this.requestCache); this.client.get() .uri("https://example.com/oauth2/authorization/registration-id") .exchange() .expectStatus() .is3xxRedirection() .returnResult(String.class); verifyZeroInteractions(this.requestCache); } }
@Test public void filterWhenExceptionThenSaveRequestSessionAttribute() { this.filter.setRequestCache(this.requestCache); when(this.requestCache.saveRequest(any())).thenReturn(Mono.empty()); FilteringWebHandler webHandler = new FilteringWebHandler( e -> Mono.error(new ClientAuthorizationRequiredException(this.registration.getRegistrationId())), Arrays.asList(this.filter)); this.client = WebTestClient.bindToWebHandler(webHandler).build(); this.client.get() .uri("https://example.com/foo") .exchange() .expectStatus() .is3xxRedirection() .returnResult(String.class); verify(this.requestCache).saveRequest(any()); }