]> WPIA git - gigi.git/blobdiff - tests/org/cacert/gigi/pages/wot/TestAssurance.java
FIX: fix some date patterns.... What is a weak year anyway....
[gigi.git] / tests / org / cacert / gigi / pages / wot / TestAssurance.java
index 03e499df6143e903ca0707897b6c295994758338..f519fb4e4744c4cbab15a775200efc3d3228f0d0 100644 (file)
@@ -10,13 +10,12 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
 import java.net.URLEncoder;
-import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.regex.Pattern;
 
-import org.cacert.gigi.database.DatabaseConnection;
+import org.cacert.gigi.pages.account.MyDetails;
 import org.cacert.gigi.testUtils.IOUtils;
 import org.cacert.gigi.testUtils.ManagedTest;
 import org.junit.Before;
@@ -39,7 +38,7 @@ public class TestAssurance extends ManagedTest {
         assurerM = createUniqueName() + "@cacert-test.org";
         assureeM = createUniqueName() + "@cacert-test.org";
         assurer = createAssuranceUser("a", "b", assurerM, TEST_PASSWORD);
-        assuree = createAssuranceUser("a", "c", assureeM, TEST_PASSWORD);
+        assuree = createVerifiedUser("a", "c", assureeM, TEST_PASSWORD);
         cookie = login(assurerM, TEST_PASSWORD);
 
     }
@@ -102,11 +101,24 @@ public class TestAssurance extends ManagedTest {
     }
 
     @Test
-    public void testAssureFormRace() throws IOException, SQLException {
+    public void testAssureFormRaceName() throws IOException, SQLException {
+        testAssureFormRace(true);
+    }
+
+    @Test
+    public void testAssureFormRaceDoB() throws IOException, SQLException {
+        testAssureFormRace(false);
+    }
+
+    public void testAssureFormRace(boolean name) throws IOException, SQLException {
         URLConnection uc = buildupAssureFormConnection(true);
-        PreparedStatement ps = DatabaseConnection.getInstance().prepare("UPDATE `users` SET email='changed' WHERE id=?");
-        ps.setInt(1, assuree);
-        ps.execute();
+
+        String assureeCookie = login(assureeM, TEST_PASSWORD);
+        String newName = "lname=" + (name ? "c" : "a") + "&fname=a&mname=&suffix=";
+        String newDob = "day=1&month=1&year=" + (name ? 1910 : 1911);
+
+        assertNull(executeBasicWebInteraction(assureeCookie, MyDetails.PATH, newName + "&" + newDob + "&processDetails", 0));
+
         uc.getOutputStream().write(("date=2000-01-01&location=testcase&certify=1&rules=1&CCAAgreed=1&assertion=1&points=10").getBytes());
         uc.getOutputStream().flush();
         String error = fetchStartErrorMessage(IOUtils.readURL(uc));
@@ -115,7 +127,7 @@ public class TestAssurance extends ManagedTest {
 
     @Test
     public void testAssureFormFuture() throws IOException {
-        SimpleDateFormat sdf = new SimpleDateFormat("YYYY");
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
         int year = Integer.parseInt(sdf.format(new Date(System.currentTimeMillis()))) + 2;
         String error = getError("date=" + year + "-01-01&location=testcase&certify=1&rules=1&CCAAgreed=1&assertion=1&points=10");
         assertTrue(error, !error.startsWith("</div>"));