+ @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() + SECURE_REFERENCE, huc.getHeaderField("Location"));
+ }
+