From: Julien Lancelot Date: Fri, 20 Oct 2017 11:34:17 +0000 (+0200) Subject: Add unit tests X-Git-Tag: 6.7-RC1~137 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=40952163a1997e04d1eadef927b0fd17cbd0f81d;p=sonarqube.git Add unit tests --- 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")});