X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=tests%2Forg%2Fcacert%2Fgigi%2FLoginTest.java;h=86e3d7b7e53314a10e9b51c4513400bc4666a304;hp=c0ff71a4a65a6b0ba4c9aa2588edd305304ec2f0;hb=485345c765f3c66751d4aad8d5c935e3cbf58cf1;hpb=744d44637a97bcf226bf574fcf80ad1e688c047e diff --git a/tests/org/cacert/gigi/LoginTest.java b/tests/org/cacert/gigi/LoginTest.java index c0ff71a4..86e3d7b7 100644 --- a/tests/org/cacert/gigi/LoginTest.java +++ b/tests/org/cacert/gigi/LoginTest.java @@ -7,6 +7,7 @@ import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; +import java.net.URLEncoder; import java.security.GeneralSecurityException; import java.security.KeyPair; import java.security.PrivateKey; @@ -38,6 +39,23 @@ public class LoginTest extends ManagedTest { assertTrue(isLoggedin(login(email, TEST_PASSWORD))); } + @Test + public void testLoginRedirectBack() throws IOException { + String email = createUniqueName() + "@testmail.org"; + createVerifiedUser("an", "bn", email, TEST_PASSWORD); + + URL u0 = new URL("https://" + getServerName() + SECURE_REFERENCE); + HttpURLConnection huc0 = (HttpURLConnection) u0.openConnection(); + String headerField = stripCookie(huc0.getHeaderField("Set-Cookie")); + + HttpURLConnection huc = post(headerField, "/login", "username=" + URLEncoder.encode(email, "UTF-8") + "&password=" + URLEncoder.encode(TEST_PASSWORD, "UTF-8"), 0); + + headerField = huc.getHeaderField("Set-Cookie"); + assertNotNull(headerField); + assertEquals(302, huc.getResponseCode()); + assertEquals("https://" + getServerName().replaceFirst(":443$", "") + SECURE_REFERENCE, huc.getHeaderField("Location")); + } + @Test public void testLoginWrongPassword() throws IOException { String email = createUniqueName() + "@testmail.org";