]> WPIA git - gigi.git/blobdiff - tests/org/cacert/gigi/pages/account/TestPasswordResetExternal.java
fix: external password-reset-by-assurance-TestCase
[gigi.git] / tests / org / cacert / gigi / pages / account / TestPasswordResetExternal.java
index 8acef6b2d451ea49df3872cc82c1b63216f463e8..04b927a37a38f2e1a291061ef2569b6341315752 100644 (file)
@@ -5,12 +5,14 @@ import static org.junit.Assert.*;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
+import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
 import java.net.URLEncoder;
 
 import org.cacert.gigi.dbObjects.User;
+import org.cacert.gigi.pages.PasswordResetPage;
 import org.cacert.gigi.pages.wot.TestAssurance;
 import org.cacert.gigi.testUtils.ClientTest;
 import org.cacert.gigi.testUtils.IOUtils;
@@ -32,9 +34,9 @@ public class TestPasswordResetExternal extends ClientTest {
         assertNull(error);
 
         TestMail mail = getMailReciever().receive();
-        System.out.println(mail.getMessage());
         String link = mail.extractLink();
         String npw = TEST_PASSWORD + "'";
+        System.out.println(link);
         assertNotNull(toPasswordReset(avalue, link, npw, npw + "'"));
         assertNotNull(toPasswordReset(avalue + "'", link, npw, npw));
         assertNotNull(toPasswordReset(avalue, link, "a", "a"));
@@ -48,11 +50,13 @@ public class TestPasswordResetExternal extends ClientTest {
         String headerField = uc2.getHeaderField("Set-Cookie");
         assertNotNull(headerField);
         String cookie3 = stripCookie(headerField);
-        uc2 = new URL(link).openConnection();
+        uc2 = new URL("https://" + getServerName() + PasswordResetPage.PATH).openConnection();
         cookie(uc2, cookie3);
         uc2.setDoOutput(true);
         OutputStream o = uc2.getOutputStream();
         o.write(("csrf=" + csrf + "&pword1=" + URLEncoder.encode(npw, "UTF-8") + "&pword2=" + URLEncoder.encode(npw2, "UTF-8") + "&private_token=" + URLEncoder.encode(avalue, "UTF-8")).getBytes("UTF-8"));
-        return fetchStartErrorMessage(IOUtils.readURL(uc2));
+        System.out.println(((HttpURLConnection) uc2).getResponseCode());
+        String readURL = IOUtils.readURL(uc2);
+        return fetchStartErrorMessage(readURL);
     }
 }