]> WPIA git - gigi.git/blobdiff - tests/org/cacert/gigi/pages/wot/TestAssurance.java
add: external test for password reset
[gigi.git] / tests / org / cacert / gigi / pages / wot / TestAssurance.java
index 134f7427faaf6dd826a4546a6bba0266ee9b5aab..58a791f372fcc0066a83b00244ffd44e0b9e3884 100644 (file)
@@ -12,6 +12,7 @@ import java.net.URLConnection;
 import java.net.URLEncoder;
 import java.sql.SQLException;
 import java.text.SimpleDateFormat;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.regex.Pattern;
 
@@ -140,6 +141,17 @@ public class TestAssurance extends ManagedTest {
         assertTrue(error, !error.startsWith("</div>"));
     }
 
+    @Test
+    public void testAssureFormFutureOK() throws IOException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar c = Calendar.getInstance();
+        c.setTimeInMillis(System.currentTimeMillis());
+        c.add(Calendar.HOUR_OF_DAY, 12);
+
+        String error = getError("date=" + sdf.format(new Date(c.getTimeInMillis())) + "&location=testcase&certify=1&rules=1&CCAAgreed=1&assertion=1&points=10");
+        assertNull(error);
+    }
+
     @Test
     public void testAssureFormNoLoc() throws IOException {
         String error = getError("date=2000-01-01&location=a&certify=1&rules=1&CCAAgreed=1&assertion=1&points=10");
@@ -203,11 +215,15 @@ public class TestAssurance extends ManagedTest {
     }
 
     private URLConnection buildupAssureFormConnection(boolean doCSRF) throws MalformedURLException, IOException {
+        return buildupAssureFormConnection(cookie, assureeM, doCSRF);
+    }
+
+    public static URLConnection buildupAssureFormConnection(String cookie, String email, boolean doCSRF) throws MalformedURLException, IOException {
         URL u = new URL("https://" + getServerName() + AssurePage.PATH);
         URLConnection uc = u.openConnection();
         uc.addRequestProperty("Cookie", cookie);
         uc.setDoOutput(true);
-        uc.getOutputStream().write(("email=" + URLEncoder.encode(assureeM, "UTF-8") + "&day=1&month=1&year=1910&search").getBytes("UTF-8"));
+        uc.getOutputStream().write(("email=" + URLEncoder.encode(email, "UTF-8") + "&day=1&month=1&year=1910&search").getBytes("UTF-8"));
 
         String csrf = getCSRF(uc);
         uc = u.openConnection();