]> source.dussan.org Git - sonarqube.git/commitdiff
Add unit tests
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 20 Oct 2017 11:34:17 +0000 (13:34 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 20 Oct 2017 11:39:25 +0000 (13:39 +0200)
server/sonar-server/src/test/java/org/sonar/server/authentication/OAuth2RedirectionTest.java

index e25bfb2deeb443662589926884e6d74b203c78b9..09d13bd0c94e3cacd18faebebf07974af646a4f2 100644 (file)
@@ -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<String> 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<String> 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")});