From 40952163a1997e04d1eadef927b0fd17cbd0f81d Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Fri, 20 Oct 2017 13:34:17 +0200 Subject: [PATCH] Add unit tests --- .../authentication/OAuth2RedirectionTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/server/sonar-server/src/test/java/org/sonar/server/authentication/OAuth2RedirectionTest.java b/server/sonar-server/src/test/java/org/sonar/server/authentication/OAuth2RedirectionTest.java index e25bfb2deeb..09d13bd0c94 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/authentication/OAuth2RedirectionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/authentication/OAuth2RedirectionTest.java @@ -99,6 +99,24 @@ public class OAuth2RedirectionTest { assertThat(updatedCookie.getMaxAge()).isEqualTo(0); } + @Test + public void get_and_delete_returns_nothing_when_no_cookie() throws Exception { + when(request.getCookies()).thenReturn(new Cookie[]{}); + + Optional redirection = underTest.getAndDelete(request, response); + + assertThat(redirection).isEmpty(); + } + + @Test + public void get_and_delete_returns_nothing_redirect_value_is_null() throws Exception { + when(request.getCookies()).thenReturn(new Cookie[]{new Cookie("REDIRECT_TO", null)}); + + Optional redirection = underTest.getAndDelete(request, response); + + assertThat(redirection).isEmpty(); + } + @Test public void delete() throws Exception { when(request.getCookies()).thenReturn(new Cookie[]{new Cookie("REDIRECT_TO", "/settings")}); -- 2.39.5