From 412719ad8098d38459a3f53165c24dde48d8b7e2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Felix=20D=C3=B6rre?= Date: Wed, 27 Aug 2014 02:59:51 +0200 Subject: [PATCH] Test the logout functionality. --- tests/org/cacert/gigi/LoginTest.java | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/tests/org/cacert/gigi/LoginTest.java b/tests/org/cacert/gigi/LoginTest.java index 940664fa..bb4e4a8e 100644 --- a/tests/org/cacert/gigi/LoginTest.java +++ b/tests/org/cacert/gigi/LoginTest.java @@ -1,7 +1,10 @@ package org.cacert.gigi; import java.io.IOException; +import java.net.URL; + import static org.junit.Assert.*; + import org.cacert.gigi.testUtils.ManagedTest; import org.junit.Test; @@ -9,8 +12,7 @@ public class LoginTest extends ManagedTest { @Test public void testLoginUnverified() throws IOException { - long uniq = System.currentTimeMillis(); - String email = "system" + uniq + "@testmail.org"; + String email = createUniqueName() + "@testmail.org"; registerUser("an", "bn", email, TEST_PASSWORD); waitForMail(); assertFalse(isLoggedin(login(email, TEST_PASSWORD))); @@ -18,10 +20,23 @@ public class LoginTest extends ManagedTest { @Test public void testLoginVerified() throws IOException { - long uniq = System.currentTimeMillis(); - String email = "system2" + uniq + "@testmail.org"; + String email = createUniqueName() + "@testmail.org"; createVerifiedUser("an", "bn", email, TEST_PASSWORD); assertTrue(isLoggedin(login(email, TEST_PASSWORD))); } + @Test + public void testLogoutVerified() throws IOException { + String email = createUniqueName() + "@testmail.org"; + createVerifiedUser("an", "bn", email, TEST_PASSWORD); + String cookie = login(email, TEST_PASSWORD); + assertTrue(isLoggedin(cookie)); + logout(cookie); + assertFalse(isLoggedin(cookie)); + } + + private void logout(String cookie) throws IOException { + cookie(new URL("https://" + getServerName() + "/logout").openConnection(), cookie).getHeaderField("Location"); + } + } -- 2.39.2