From d8d62e3c43cde58c8b1edbd875562ea863cce496 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Felix=20D=C3=B6rre?= Date: Thu, 15 Dec 2016 10:20:39 +0100 Subject: [PATCH] fix: Exception when using TestManager functionality a constant date gets older than two years at some point in time Change-Id: I804b06258d27f535a7e9af2dd75223f099170fd0 --- util-testing/org/cacert/gigi/pages/Manager.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/util-testing/org/cacert/gigi/pages/Manager.java b/util-testing/org/cacert/gigi/pages/Manager.java index e1af384a..3244bb42 100644 --- a/util-testing/org/cacert/gigi/pages/Manager.java +++ b/util-testing/org/cacert/gigi/pages/Manager.java @@ -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 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); -- 2.39.2