]> WPIA git - gigi.git/commitdiff
fix: assurance form, keep location and date + testCase
authorFelix Dörre <felix@dogcraft.de>
Tue, 10 Nov 2015 22:52:35 +0000 (23:52 +0100)
committerFelix Dörre <felix@dogcraft.de>
Tue, 10 Nov 2015 22:52:35 +0000 (23:52 +0100)
src/org/cacert/gigi/pages/wot/AssuranceForm.java
src/org/cacert/gigi/pages/wot/AssuranceForm.templ
tests/org/cacert/gigi/pages/wot/TestAssurance.java

index 36e5247ca87191281c473d7f07b8c19653d08570..4b6f9232a3f4f16dfdebae65b3518b823ec74212 100644 (file)
@@ -25,6 +25,10 @@ public class AssuranceForm extends Form {
 
     private Date dob;
 
+    private String location = "";
+
+    private String date = "";
+
     private static final Template templ;
     static {
         templ = new Template(AssuranceForm.class.getResource("AssuranceForm.templ"));
@@ -50,11 +54,19 @@ public class AssuranceForm extends Form {
         res.put("maxpoints", assuree.getMaxAssurePoints());
         res.put("dob", sdf.format(assuree.getDoB()));
         res.put("dobFmt2", sdf2.format(assuree.getDoB()));
+        res.put("location", location);
+        res.put("date", date);
         templ.output(out, l, res);
     }
 
     @Override
     public boolean submit(PrintWriter out, HttpServletRequest req) {
+        location = req.getParameter("location");
+        date = req.getParameter("date");
+        if (date == null || location == null) {
+            outputError(out, req, "You need to enter location and date!");
+        }
+
         if ( !"1".equals(req.getParameter("certify")) || !"1".equals(req.getParameter("rules")) || !"1".equals(req.getParameter("CCAAgreed")) || !"1".equals(req.getParameter("assertion"))) {
             outputError(out, req, "You failed to check all boxes to validate" + " your adherence to the rules and policies of CAcert");
 
@@ -75,7 +87,7 @@ public class AssuranceForm extends Form {
             return false;
         }
         try {
-            Notary.assure(Page.getUser(req), assuree, assureeName, dob, pointsI, req.getParameter("location"), req.getParameter("date"));
+            Notary.assure(Page.getUser(req), assuree, assureeName, dob, pointsI, location, req.getParameter("date"));
             return true;
         } catch (GigiApiException e) {
             e.format(out, Page.getLanguage(req));
index 2967515bacaba37083ae6b0d5765273d7895ca9c..1d5e30310371c039fadaf59c8a8dfa277ea73f8b 100644 (file)
        </tr>
        <tr>
                <td><?=_Location?></td>
-               <td><input type="text" name="location"></td>
+               <td><input type="text" name="location" value="<?=$location?>"></td>
        </tr>
        <tr>
                <td><?=_Date?></td>
-               <td><input type="text" name="date"><br/><?=_The date when the assurance took place. Please adjust the date if you assured the person on a different day (YYYY-MM-DD).?></td>
+               <td><input type="text" name="date" value="<?=$date?>"><br/><?=_The date when the assurance took place. Please adjust the date if you assured the person on a different day (YYYY-MM-DD).?></td>
        </tr>
        <tr>
                <td><input type="checkbox" name="assertion" value="1"></td>
index 9fae5ddc95916f254483c3a45bcaf1b49ba4de07..134f7427faaf6dd826a4546a6bba0266ee9b5aab 100644 (file)
@@ -79,6 +79,16 @@ public class TestAssurance extends ManagedTest {
         assertNull(error);
     }
 
+    @Test
+    public void testAssureFormContanisData() throws IOException {
+        URLConnection uc = buildupAssureFormConnection(true);
+        uc.getOutputStream().write(("date=2000-01-01&location=testcase&rules=1&CCAAgreed=1&assertion=1&points=10").getBytes("UTF-8"));
+        uc.getOutputStream().flush();
+        String data = IOUtils.readURL(uc);
+        assertThat(data, containsString("2000-01-01"));
+        assertThat(data, containsString("testcase"));
+    }
+
     @Test
     public void testAssureFormNoCSRF() throws IOException {
         // override csrf