]> WPIA git - gigi.git/commitdiff
fix: Exception when using TestManager functionality
authorFelix Dörre <felix@dogcraft.de>
Thu, 15 Dec 2016 09:20:39 +0000 (10:20 +0100)
committerFelix Dörre <felix@dogcraft.de>
Thu, 15 Dec 2016 09:28:58 +0000 (10:28 +0100)
a constant date gets older than two years at some point in time

Change-Id: I804b06258d27f535a7e9af2dd75223f099170fd0

util-testing/org/cacert/gigi/pages/Manager.java

index e1af384a7485783d512ce8e3f41627a9eeb43821..3244bb42b6649f42fa1d1ed725a948ba42645425 100644 (file)
@@ -7,6 +7,7 @@ import java.security.GeneralSecurityException;
 import java.security.KeyPair;
 import java.security.KeyPairGenerator;
 import java.security.Signature;
+import java.text.SimpleDateFormat;
 import java.util.Base64;
 import java.util.Calendar;
 import java.util.Date;
@@ -61,6 +62,14 @@ import sun.security.x509.X509Key;
 
 public class Manager extends Page {
 
+    public static String validVerificationDateString() {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar c = Calendar.getInstance();
+        c.setTimeInMillis(System.currentTimeMillis());
+        c.add(Calendar.MONTH, -Notary.LIMIT_MAX_MONTHS_VERIFICATION + 1);
+        return sdf.format(new Date(c.getTimeInMillis()));
+    }
+
     public static Country getRandomCountry() {
         List<Country> cc = Country.getCountries();
         int rnd = new Random().nextInt(cc.size());
@@ -354,7 +363,7 @@ public class Manager extends Page {
                     if (vp < 10) {
                         currentVP = vp;
                     }
-                    Notary.assure(getAssurer(agentNumber), byEmail, byEmail.getPreferredName(), byEmail.getDoB(), currentVP, "Testmanager Verify up code", "2014-11-06", AssuranceType.FACE_TO_FACE, getRandomCountry());
+                    Notary.assure(getAssurer(agentNumber), byEmail, byEmail.getPreferredName(), byEmail.getDoB(), currentVP, "Testmanager Verify up code", validVerificationDateString(), AssuranceType.FACE_TO_FACE, getRandomCountry());
                     agentNumber += 1;
                     vp -= currentVP;
                 }
@@ -371,7 +380,7 @@ public class Manager extends Page {
             try {
                 for (int i = 0; i < 25; i++) {
                     User a = getAssurer(i);
-                    Notary.assure(byEmail, a, a.getNames()[0], a.getDoB(), 10, "Testmanager exp up code", "2014-11-06", AssuranceType.FACE_TO_FACE, getRandomCountry());
+                    Notary.assure(byEmail, a, a.getNames()[0], a.getDoB(), 10, "Testmanager exp up code", validVerificationDateString(), AssuranceType.FACE_TO_FACE, getRandomCountry());
                 }
             } catch (GigiApiException e) {
                 throw new Error(e);