From 08c941629aea14473e5c42ab6f5d590be4af4bf8 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Wed, 22 Feb 2017 21:37:38 +0100 Subject: [PATCH] upd: terminology in code Renames Java types and members and form fields. Anything facing the database is not touched by this change. Also fixes a handful of typos. Change-Id: Id19c3af4627b56ee90a85fe887bd5bcdb6c9f385 --- src/club/wpia/gigi/Gigi.java | 8 +- src/club/wpia/gigi/api/FindAgent.java | 2 +- src/club/wpia/gigi/dbObjects/CATS.java | 2 +- .../gigi/dbObjects/CertificateProfile.java | 4 +- src/club/wpia/gigi/dbObjects/Name.java | 2 +- .../wpia/gigi/dbObjects/Organisation.java | 2 +- src/club/wpia/gigi/dbObjects/User.java | 64 +++---- .../{Assurance.java => Verification.java} | 8 +- ...Display.java => VerificationsDisplay.java} | 48 +++--- ...splay.templ => VerificationsDisplay.templ} | 2 +- .../gigi/pages/account/MyDetailsForm.java | 8 +- ...ured.templ => MyDetailsFormVerified.templ} | 0 .../account/certs/CertificateRequest.java | 4 +- .../admin/support/SupportUserDetailsForm.java | 6 +- .../support/SupportUserDetailsForm.templ | 4 +- .../wpia/gigi/pages/orga/AffiliationForm.java | 2 +- .../wpia/gigi/pages/orga/CreateOrgPage.java | 4 +- .../wpia/gigi/pages/orga/ViewOrgPage.java | 8 +- ...ureeSearch.templ => ApplicantSearch.templ} | 0 src/club/wpia/gigi/pages/wot/Points.java | 20 +-- .../wpia/gigi/pages/wot/RequestTTPPage.java | 8 +- ...suranceForm.java => VerificationForm.java} | 76 ++++----- ...ranceForm.templ => VerificationForm.templ} | 4 +- .../wot/{AssurePage.java => VerifyPage.java} | 18 +- .../wpia/gigi/util/AuthorizationContext.java | 4 +- src/club/wpia/gigi/util/Notary.java | 148 ++++++++-------- tests/club/wpia/gigi/TestOrga.java | 8 +- .../wpia/gigi/TestSeparateSessionScope.java | 4 +- tests/club/wpia/gigi/TestUser.java | 28 +-- .../club/wpia/gigi/api/ImportCATSResult.java | 2 +- tests/club/wpia/gigi/api/IssueCert.java | 6 +- .../wpia/gigi/dbObjects/TestAssureName.java | 38 ----- tests/club/wpia/gigi/dbObjects/TestCATS.java | 8 +- ...stAssurance.java => TestVerification.java} | 74 ++++---- ...nceMail.java => TestVerificationMail.java} | 34 ++-- .../wpia/gigi/dbObjects/TestVerifyName.java | 38 +++++ .../pages/account/TestCertificateRequest.java | 2 +- .../account/TestPasswordResetExternal.java | 10 +- .../gigi/pages/account/TestTrainings.java | 4 +- .../pages/admin/TestSEAdminPageDetails.java | 2 +- .../gigi/pages/orga/TestOrgManagement.java | 10 +- tests/club/wpia/gigi/pages/wot/TestTTP.java | 2 +- ...stAssurance.java => TestVerification.java} | 160 +++++++++--------- .../wpia/gigi/testUtils/BusinessTest.java | 4 +- .../wpia/gigi/testUtils/ConfiguredTest.java | 4 +- .../club/wpia/gigi/testUtils/ManagedTest.java | 4 +- tests/club/wpia/gigi/testUtils/OrgTest.java | 2 +- .../gigi/testUtils/RestrictedApiTest.java | 4 +- tests/club/wpia/gigi/util/TestNotary.java | 131 +++++++------- .../club/wpia/gigi/pages/Manager.java | 42 ++--- .../club/wpia/gigi/pages/Manager.templ | 8 +- 51 files changed, 541 insertions(+), 544 deletions(-) rename src/club/wpia/gigi/dbObjects/{Assurance.java => Verification.java} (87%) rename src/club/wpia/gigi/output/{AssurancesDisplay.java => VerificationsDisplay.java} (52%) rename src/club/wpia/gigi/output/{AssurancesDisplay.templ => VerificationsDisplay.templ} (93%) rename src/club/wpia/gigi/pages/account/{MyDetailsFormAssured.templ => MyDetailsFormVerified.templ} (100%) rename src/club/wpia/gigi/pages/wot/{AssureeSearch.templ => ApplicantSearch.templ} (100%) rename src/club/wpia/gigi/pages/wot/{AssuranceForm.java => VerificationForm.java} (74%) rename src/club/wpia/gigi/pages/wot/{AssuranceForm.templ => VerificationForm.templ} (91%) rename src/club/wpia/gigi/pages/wot/{AssurePage.java => VerifyPage.java} (84%) delete mode 100644 tests/club/wpia/gigi/dbObjects/TestAssureName.java rename tests/club/wpia/gigi/dbObjects/{TestAssurance.java => TestVerification.java} (67%) rename tests/club/wpia/gigi/dbObjects/{TestAssuranceMail.java => TestVerificationMail.java} (85%) create mode 100644 tests/club/wpia/gigi/dbObjects/TestVerifyName.java rename tests/club/wpia/gigi/pages/wot/{TestAssurance.java => TestVerification.java} (67%) diff --git a/src/club/wpia/gigi/Gigi.java b/src/club/wpia/gigi/Gigi.java index 33db52ad..ebd6471f 100644 --- a/src/club/wpia/gigi/Gigi.java +++ b/src/club/wpia/gigi/Gigi.java @@ -69,7 +69,7 @@ import club.wpia.gigi.pages.main.RegisterPage; import club.wpia.gigi.pages.orga.CreateOrgPage; import club.wpia.gigi.pages.orga.ViewOrgPage; import club.wpia.gigi.pages.statistics.StatisticsRoles; -import club.wpia.gigi.pages.wot.AssurePage; +import club.wpia.gigi.pages.wot.VerifyPage; import club.wpia.gigi.pages.wot.Points; import club.wpia.gigi.pages.wot.RequestTTPPage; import club.wpia.gigi.ping.PingerDaemon; @@ -151,7 +151,7 @@ public final class Gigi extends HttpServlet { putPage(DomainOverview.PATH, new DomainOverview(), "Certificates"); putPage(EditDomain.PATH + "*", new EditDomain(), null); - putPage(AssurePage.PATH + "/*", new AssurePage(), "Web of Trust"); + putPage(VerifyPage.PATH + "/*", new VerifyPage(), "Web of Trust"); putPage(Points.PATH, new Points(false), "Web of Trust"); putPage(RequestTTPPage.PATH, new RequestTTPPage(), "Web of Trust"); @@ -190,7 +190,7 @@ public final class Gigi extends HttpServlet { } try { - putPage("/wot/rules", new StaticPage("Web of Trust Rules", AssurePage.class.getResourceAsStream("Rules.templ")), "Web of Trust"); + putPage("/wot/rules", new StaticPage("Web of Trust Rules", VerifyPage.class.getResourceAsStream("Rules.templ")), "Web of Trust"); } catch (UnsupportedEncodingException e) { throw new ServletException(e); } @@ -274,7 +274,7 @@ public final class Gigi extends HttpServlet { try (Link l = DatabaseConnection.newLink(false)) { CACertificate.getById(1); CertificateProfile.getById(1); - CATSType.ASSURER_CHALLENGE.getDisplayName(); + CATSType.AGENT_CHALLENGE.getDisplayName(); } catch (InterruptedException e) { throw new Error(e); } diff --git a/src/club/wpia/gigi/api/FindAgent.java b/src/club/wpia/gigi/api/FindAgent.java index 9f00181a..9be80abb 100644 --- a/src/club/wpia/gigi/api/FindAgent.java +++ b/src/club/wpia/gigi/api/FindAgent.java @@ -89,7 +89,7 @@ public class FindAgent extends APIPoint { jw.value(u1.getId()); jw.key("canAssure"); - jw.value(u1.canAssure()); + jw.value(u1.canVerify()); jw.key("name"); jw.value(u1.getPreferredName().toAbbreviatedString()); diff --git a/src/club/wpia/gigi/dbObjects/CATS.java b/src/club/wpia/gigi/dbObjects/CATS.java index 3ed2c923..c9f96d11 100644 --- a/src/club/wpia/gigi/dbObjects/CATS.java +++ b/src/club/wpia/gigi/dbObjects/CATS.java @@ -11,7 +11,7 @@ import club.wpia.gigi.util.TimeConditions; public class CATS { public enum CATSType { - ASSURER_CHALLENGE("Agent Qualifying Challenge"), + AGENT_CHALLENGE("Agent Qualifying Challenge"), ORG_AGENT_CHALLENGE("Organisation Agent Qualifying Challenge"), diff --git a/src/club/wpia/gigi/dbObjects/CertificateProfile.java b/src/club/wpia/gigi/dbObjects/CertificateProfile.java index 8940da38..168744c9 100644 --- a/src/club/wpia/gigi/dbObjects/CertificateProfile.java +++ b/src/club/wpia/gigi/dbObjects/CertificateProfile.java @@ -258,11 +258,11 @@ public class CertificateProfile implements IdCachable { } for (String s : req) { if (s.equals("points>=50")) { - if (actor.getAssurancePoints() < 50) { + if (actor.getVerificationPoints() < 50) { return false; } } else if (s.equals("points>=100")) { - if (actor.getAssurancePoints() < 100) { + if (actor.getVerificationPoints() < 100) { return false; } } else if (s.equals("codesign")) { diff --git a/src/club/wpia/gigi/dbObjects/Name.java b/src/club/wpia/gigi/dbObjects/Name.java index f4d002ec..40343718 100644 --- a/src/club/wpia/gigi/dbObjects/Name.java +++ b/src/club/wpia/gigi/dbObjects/Name.java @@ -384,7 +384,7 @@ public class Name implements Outputable, IdCachable { return scheme.toAbbreviatedString(); } - public int getAssurancePoints() { + public int getVerificationPoints() { try (GigiPreparedStatement query = new GigiPreparedStatement("SELECT SUM(`points`) FROM (SELECT DISTINCT ON (`from`, `method`) `points` FROM `notary` WHERE `to`=? AND `deleted` IS NULL AND (`expire` IS NULL OR `expire` > CURRENT_TIMESTAMP) ORDER BY `from`, `method`, `when` DESC) AS p")) { query.setInt(1, getId()); diff --git a/src/club/wpia/gigi/dbObjects/Organisation.java b/src/club/wpia/gigi/dbObjects/Organisation.java index 6e481855..1e8a38d4 100644 --- a/src/club/wpia/gigi/dbObjects/Organisation.java +++ b/src/club/wpia/gigi/dbObjects/Organisation.java @@ -145,7 +145,7 @@ public class Organisation extends CertificateOwner { } public synchronized void addAdmin(User admin, User actor, boolean master) throws GigiApiException { - if ( !admin.canAssure()) { + if ( !admin.canVerify()) { throw new GigiApiException("Cannot add person who is not RA Agent."); } if ( !actor.isInGroup(Group.ORGASSURER) && !isMaster(actor)) { diff --git a/src/club/wpia/gigi/dbObjects/User.java b/src/club/wpia/gigi/dbObjects/User.java index 1172c7e4..9703fa8f 100644 --- a/src/club/wpia/gigi/dbObjects/User.java +++ b/src/club/wpia/gigi/dbObjects/User.java @@ -14,9 +14,9 @@ import java.util.Set; import club.wpia.gigi.GigiApiException; import club.wpia.gigi.database.GigiPreparedStatement; import club.wpia.gigi.database.GigiResultSet; -import club.wpia.gigi.dbObjects.Assurance.AssuranceType; import club.wpia.gigi.dbObjects.CATS.CATSType; import club.wpia.gigi.dbObjects.Country.CountryCodeType; +import club.wpia.gigi.dbObjects.Verification.VerificationType; import club.wpia.gigi.localisation.Language; import club.wpia.gigi.output.DateSelector; import club.wpia.gigi.pages.PasswordResetPage; @@ -28,8 +28,8 @@ import club.wpia.gigi.util.PasswordStrengthChecker; import club.wpia.gigi.util.TimeConditions; /** - * Represents an acting, assurable, user. Synchronizing on user means: no - * name-change and no assurance. + * Represents an acting, verifiable user. Synchronizing on user means: no + * name-change and no verification. */ public class User extends CertificateOwner { @@ -39,9 +39,9 @@ public class User extends CertificateOwner { private String email; - private Assurance[] receivedAssurances; + private Verification[] receivedVerifications; - private Assurance[] madeAssurances; + private Verification[] madeVerifications; private Locale locale; @@ -152,7 +152,7 @@ public class User extends CertificateOwner { public void setDoB(DayDate dob) throws GigiApiException { synchronized (Notary.class) { - if (getReceivedAssurances().length != 0) { + if (getReceivedVerifications().length != 0) { throw new GigiApiException("No change after verification allowed."); } @@ -205,7 +205,7 @@ public class User extends CertificateOwner { } } - public boolean canAssure() { + public boolean canVerify() { if (POJAM_ENABLED) { if ( !CalendarUtil.isOfAge(dob, POJAM_AGE)) { // PoJAM return false; @@ -215,7 +215,7 @@ public class User extends CertificateOwner { return false; } } - if (getAssurancePoints() < 100) { + if (getVerificationPoints() < 100) { return false; } @@ -226,7 +226,7 @@ public class User extends CertificateOwner { public boolean hasPassedCATS() { try (GigiPreparedStatement query = new GigiPreparedStatement("SELECT 1 FROM `cats_passed` where `user_id`=? AND `variant_id`=?")) { query.setInt(1, getId()); - query.setInt(2, CATSType.ASSURER_CHALLENGE.getId()); + query.setInt(2, CATSType.AGENT_CHALLENGE.getId()); try (GigiResultSet rs = query.executeQuery()) { if (rs.next()) { return true; @@ -237,7 +237,7 @@ public class User extends CertificateOwner { } } - public int getAssurancePoints() { + public int getVerificationPoints() { try (GigiPreparedStatement query = new GigiPreparedStatement("SELECT SUM(lastpoints) FROM ( SELECT DISTINCT ON (`from`, `method`) `from`, `points` as lastpoints FROM `notary` INNER JOIN `names` ON `names`.`id`=`to` WHERE `notary`.`deleted` is NULL AND (`expire` IS NULL OR `expire` > CURRENT_TIMESTAMP) AND `names`.`uid` = ? ORDER BY `from`, `method`, `when` DESC) as p")) { query.setInt(1, getId()); @@ -255,7 +255,7 @@ public class User extends CertificateOwner { public int getExperiencePoints() { try (GigiPreparedStatement query = new GigiPreparedStatement("SELECT count(*) FROM ( SELECT `names`.`uid` FROM `notary` INNER JOIN `names` ON `names`.`id` = `to` WHERE `from`=? AND `notary`.`deleted` IS NULL AND `method` = ? ::`notaryType` GROUP BY `names`.`uid`) as p")) { query.setInt(1, getId()); - query.setEnum(2, AssuranceType.FACE_TO_FACE); + query.setEnum(2, VerificationType.FACE_TO_FACE); GigiResultSet rs = query.executeQuery(); int points = 0; @@ -269,13 +269,13 @@ public class User extends CertificateOwner { } /** - * Gets the maximum allowed points NOW. Note that an assurance needs to + * Gets the maximum allowed points NOW. Note that a verification needs to * re-check PoJam as it has taken place in the past. * * @return the maximal points @ */ @SuppressWarnings("unused") - public int getMaxAssurePoints() { + public int getMaxVerifyPoints() { if ( !CalendarUtil.isOfAge(dob, ADULT_AGE) && POJAM_ENABLED) { return 10; // PoJAM } @@ -304,7 +304,7 @@ public class User extends CertificateOwner { public boolean isValidName(String name) { for (Name n : getNames()) { - if (n.matches(name) && n.getAssurancePoints() >= 50) { + if (n.matches(name) && n.getVerificationPoints() >= 50) { return true; } } @@ -349,51 +349,51 @@ public class User extends CertificateOwner { throw new GigiApiException("Email not one of user's email addresses."); } - public synchronized Assurance[] getReceivedAssurances() { - if (receivedAssurances == null) { + public synchronized Verification[] getReceivedVerifications() { + if (receivedVerifications == null) { try (GigiPreparedStatement query = new GigiPreparedStatement("SELECT * FROM `notary` INNER JOIN `names` ON `names`.`id` = `notary`.`to` WHERE `names`.`uid`=? AND `notary`.`deleted` IS NULL ORDER BY `when` DESC")) { query.setInt(1, getId()); GigiResultSet res = query.executeQuery(); - List assurances = new LinkedList(); + List verifications = new LinkedList(); while (res.next()) { - assurances.add(assuranceByRes(res)); + verifications.add(verificationByRes(res)); } - this.receivedAssurances = assurances.toArray(new Assurance[0]); + this.receivedVerifications = verifications.toArray(new Verification[0]); } } - return receivedAssurances; + return receivedVerifications; } - public synchronized Assurance[] getMadeAssurances() { - if (madeAssurances == null) { + public synchronized Verification[] getMadeVerifications() { + if (madeVerifications == null) { try (GigiPreparedStatement query = new GigiPreparedStatement("SELECT * FROM notary WHERE `from`=? AND deleted is NULL ORDER BY `when` DESC")) { query.setInt(1, getId()); try (GigiResultSet res = query.executeQuery()) { - List assurances = new LinkedList(); + List verifications = new LinkedList(); while (res.next()) { - assurances.add(assuranceByRes(res)); + verifications.add(verificationByRes(res)); } - this.madeAssurances = assurances.toArray(new Assurance[0]); + this.madeVerifications = verifications.toArray(new Verification[0]); } } } - return madeAssurances; + return madeVerifications; } - public synchronized void invalidateMadeAssurances() { - madeAssurances = null; + public synchronized void invalidateMadeVerifications() { + madeVerifications = null; } - public synchronized void invalidateReceivedAssurances() { - receivedAssurances = null; + public synchronized void invalidateReceivedVerifications() { + receivedVerifications = null; } private void rawUpdateUserData() { @@ -615,9 +615,9 @@ public class User extends CertificateOwner { } } - private Assurance assuranceByRes(GigiResultSet res) { + private Verification verificationByRes(GigiResultSet res) { try { - return new Assurance(res.getInt("id"), User.getById(res.getInt("from")), Name.getById(res.getInt("to")), res.getString("location"), res.getString("method"), res.getInt("points"), res.getString("date"), res.getString("country") == null ? null : Country.getCountryByCode(res.getString("country"), CountryCodeType.CODE_2_CHARS), res.getTimestamp("expire")); + return new Verification(res.getInt("id"), User.getById(res.getInt("from")), Name.getById(res.getInt("to")), res.getString("location"), res.getString("method"), res.getInt("points"), res.getString("date"), res.getString("country") == null ? null : Country.getCountryByCode(res.getString("country"), CountryCodeType.CODE_2_CHARS), res.getTimestamp("expire")); } catch (GigiApiException e) { throw new Error(e); } diff --git a/src/club/wpia/gigi/dbObjects/Assurance.java b/src/club/wpia/gigi/dbObjects/Verification.java similarity index 87% rename from src/club/wpia/gigi/dbObjects/Assurance.java rename to src/club/wpia/gigi/dbObjects/Verification.java index 77d8098b..3edaa570 100644 --- a/src/club/wpia/gigi/dbObjects/Assurance.java +++ b/src/club/wpia/gigi/dbObjects/Verification.java @@ -6,14 +6,14 @@ import club.wpia.gigi.database.DBEnum; import club.wpia.gigi.dbObjects.wrappers.DataContainer; @DataContainer -public class Assurance { +public class Verification { - public enum AssuranceType implements DBEnum { + public enum VerificationType implements DBEnum { FACE_TO_FACE("Face to Face Meeting"), TOPUP("TOPUP"), TTP_ASSISTED("TTP-Assisted"), NUCLEUS("Nucleus Bonus"); private final String description; - private AssuranceType(String description) { + private VerificationType(String description) { this.description = description; } @@ -45,7 +45,7 @@ public class Assurance { private Date expireDate; - public Assurance(int id, User from, Name to, String location, String method, int points, String date, Country country, Date expireDate) { + public Verification(int id, User from, Name to, String location, String method, int points, String date, Country country, Date expireDate) { this.id = id; this.from = from; this.to = to; diff --git a/src/club/wpia/gigi/output/AssurancesDisplay.java b/src/club/wpia/gigi/output/VerificationsDisplay.java similarity index 52% rename from src/club/wpia/gigi/output/AssurancesDisplay.java rename to src/club/wpia/gigi/output/VerificationsDisplay.java index 84822dd6..f3b80448 100644 --- a/src/club/wpia/gigi/output/AssurancesDisplay.java +++ b/src/club/wpia/gigi/output/VerificationsDisplay.java @@ -3,33 +3,33 @@ package club.wpia.gigi.output; import java.io.PrintWriter; import java.util.Map; -import club.wpia.gigi.dbObjects.Assurance; import club.wpia.gigi.dbObjects.Name; +import club.wpia.gigi.dbObjects.Verification; import club.wpia.gigi.localisation.Language; import club.wpia.gigi.output.template.IterableDataset; import club.wpia.gigi.output.template.Outputable; import club.wpia.gigi.output.template.Template; -public class AssurancesDisplay implements Outputable { +public class VerificationsDisplay implements Outputable { - private static final Template template = new Template(AssurancesDisplay.class.getResource("AssurancesDisplay.templ")); + private static final Template template = new Template(VerificationsDisplay.class.getResource("VerificationsDisplay.templ")); - private boolean assurer; + private boolean agent; - public String assuranceArray; + public String verificationArray; private boolean support; - public AssurancesDisplay(String assuranceArray, boolean assurer, boolean support) { - this.assuranceArray = assuranceArray; - this.assurer = assurer; + public VerificationsDisplay(String verificationArray, boolean agent, boolean support) { + this.verificationArray = verificationArray; + this.agent = agent; this.support = support; } @Override public void output(PrintWriter out, Language l, Map vars) { - final Assurance[] assurances = (Assurance[]) vars.get(assuranceArray); - if (assurer) { + final Verification[] verifications = (Verification[]) vars.get(verificationArray); + if (agent) { vars.put("verb", l.getTranslation("To (User Id)")); vars.put("info", ""); } else { @@ -38,39 +38,39 @@ public class AssurancesDisplay implements Outputable { vars.put("info", l.getTranslation("Coloured rows show expired nucleus bonus verifications which are not counted to the total of verification points.")); } - IterableDataset assuranceGroup = new IterableDataset() { + IterableDataset verificationsGroup = new IterableDataset() { private int i = 0; @Override public boolean next(Language l, Map vars) { - if (i >= assurances.length) { + if (i >= verifications.length) { return false; } else { - Assurance assurance = assurances[i]; + Verification verification = verifications[i]; vars.put("support", support); - vars.put("id", assurance.getId()); - vars.put("method", assurance.getMethod()); - Name to = assurance.getTo(); - if (assurer) { + vars.put("id", verification.getId()); + vars.put("method", verification.getMethod()); + Name to = verification.getTo(); + if (agent) { vars.put("linkId", to == null ? "" : to.getOwner().getId()); vars.put("verbVal", to == null ? l.getTranslation("applicant's name removed") : to.getOwner().getId()); vars.put("myName", to == null ? l.getTranslation("applicant's name removed") : to); } else { - vars.put("linkId", assurance.getFrom().getId()); - vars.put("verbVal", assurance.getFrom().getPreferredName()); + vars.put("linkId", verification.getFrom().getId()); + vars.put("verbVal", verification.getFrom().getPreferredName()); vars.put("myName", to == null ? l.getTranslation("own name removed") : to); } - vars.put("date", assurance.getDate()); - vars.put("location", assurance.getLocation() + " (" + (assurance.getCountry() == null ? l.getTranslation("not given") : assurance.getCountry().getName()) + ")"); - vars.put("points", assurance.getPoints()); - vars.put("expired", assurance.isExpired()); + vars.put("date", verification.getDate()); + vars.put("location", verification.getLocation() + " (" + (verification.getCountry() == null ? l.getTranslation("not given") : verification.getCountry().getName()) + ")"); + vars.put("points", verification.getPoints()); + vars.put("expired", verification.isExpired()); i++; return true; } } }; - vars.put("assurances", assuranceGroup); + vars.put("verifications", verificationsGroup); template.output(out, l, vars); } diff --git a/src/club/wpia/gigi/output/AssurancesDisplay.templ b/src/club/wpia/gigi/output/VerificationsDisplay.templ similarity index 93% rename from src/club/wpia/gigi/output/AssurancesDisplay.templ rename to src/club/wpia/gigi/output/VerificationsDisplay.templ index 41f9fd87..5ab44532 100644 --- a/src/club/wpia/gigi/output/AssurancesDisplay.templ +++ b/src/club/wpia/gigi/output/VerificationsDisplay.templ @@ -11,7 +11,7 @@ - + class="info" > diff --git a/src/club/wpia/gigi/pages/account/MyDetailsForm.java b/src/club/wpia/gigi/pages/account/MyDetailsForm.java index 4af7c94a..e4834a15 100644 --- a/src/club/wpia/gigi/pages/account/MyDetailsForm.java +++ b/src/club/wpia/gigi/pages/account/MyDetailsForm.java @@ -22,7 +22,7 @@ import club.wpia.gigi.output.template.Template; public class MyDetailsForm extends Form { - private static final Template assured = new Template(MyDetails.class.getResource("MyDetailsFormAssured.templ")); + private static final Template verified = new Template(MyDetails.class.getResource("MyDetailsFormVerified.templ")); private static final Template templ = new Template(MyDetailsForm.class.getResource("MyDetailsForm.templ")); @@ -140,7 +140,7 @@ public class MyDetailsForm extends Form { } vars.put("name", t); vars.put("id", t.getId()); - vars.put("npoints", Integer.toString(t.getAssurancePoints())); + vars.put("npoints", Integer.toString(t.getVerificationPoints())); } }); @@ -148,12 +148,12 @@ public class MyDetailsForm extends Form { names.output(out, l, vars); vars.put("residenceCountry", cs); - if (target.getReceivedAssurances().length == 0) { + if (target.getReceivedVerifications().length == 0) { vars.put("DoB", ds); templ.output(out, l, vars); } else { vars.put("DoB", target.getDoB()); - assured.output(out, l, vars); + verified.output(out, l, vars); } final Set gr = target.getGroups(); diff --git a/src/club/wpia/gigi/pages/account/MyDetailsFormAssured.templ b/src/club/wpia/gigi/pages/account/MyDetailsFormVerified.templ similarity index 100% rename from src/club/wpia/gigi/pages/account/MyDetailsFormAssured.templ rename to src/club/wpia/gigi/pages/account/MyDetailsFormVerified.templ diff --git a/src/club/wpia/gigi/pages/account/certs/CertificateRequest.java b/src/club/wpia/gigi/pages/account/certs/CertificateRequest.java index 2755b18f..912f316e 100644 --- a/src/club/wpia/gigi/pages/account/certs/CertificateRequest.java +++ b/src/club/wpia/gigi/pages/account/certs/CertificateRequest.java @@ -111,7 +111,7 @@ public class CertificateRequest { this.ctx = ctx; if (cp != null) { profile = cp; - } else if (ctx.getActor().getAssurancePoints() > 50) { + } else if (ctx.getActor().getVerificationPoints() > 50) { profile = CertificateProfile.getByName("client-a"); } byte[] data = PEM.decode("(NEW )?CERTIFICATE REQUEST", csr); @@ -160,7 +160,7 @@ public class CertificateRequest { } else if (c instanceof ExtendedKeyUsageExtension) { ExtendedKeyUsageExtension ekue = (ExtendedKeyUsageExtension) c; String appendix = ""; - if (ctx.getActor().getAssurancePoints() >= 50) { + if (ctx.getActor().getVerificationPoints() >= 50) { appendix = "-a"; } for (String s : ekue.getExtendedKeyUsage()) { diff --git a/src/club/wpia/gigi/pages/admin/support/SupportUserDetailsForm.java b/src/club/wpia/gigi/pages/admin/support/SupportUserDetailsForm.java index 7439ae67..a7b1be77 100644 --- a/src/club/wpia/gigi/pages/admin/support/SupportUserDetailsForm.java +++ b/src/club/wpia/gigi/pages/admin/support/SupportUserDetailsForm.java @@ -84,13 +84,13 @@ public class SupportUserDetailsForm extends Form { @Override public void apply(Name t, Language l, Map vars) { vars.put("name", t); - vars.put("points", Integer.toString(t.getAssurancePoints())); + vars.put("points", Integer.toString(t.getVerificationPoints())); } }); - vars.put("assurer", user.canAssure()); + vars.put("agent", user.canVerify()); vars.put("dob", dobSelector); - vars.put("assurancepoints", user.getAssurancePoints()); + vars.put("verificationPoints", user.getVerificationPoints()); vars.put("exppoints", user.getExperiencePoints()); final Set gr = user.getGroups(); vars.put("support-groups", new GroupIterator(gr.iterator(), true)); diff --git a/src/club/wpia/gigi/pages/admin/support/SupportUserDetailsForm.templ b/src/club/wpia/gigi/pages/admin/support/SupportUserDetailsForm.templ index 03be88e7..1a75afd7 100644 --- a/src/club/wpia/gigi/pages/admin/support/SupportUserDetailsForm.templ +++ b/src/club/wpia/gigi/pages/admin/support/SupportUserDetailsForm.templ @@ -25,7 +25,7 @@ : - + @@ -34,7 +34,7 @@ : - () + () : diff --git a/src/club/wpia/gigi/pages/orga/AffiliationForm.java b/src/club/wpia/gigi/pages/orga/AffiliationForm.java index 5ac52404..58ab93bf 100644 --- a/src/club/wpia/gigi/pages/orga/AffiliationForm.java +++ b/src/club/wpia/gigi/pages/orga/AffiliationForm.java @@ -38,7 +38,7 @@ public class AffiliationForm extends Form { } } else if (req.getParameter("do_affiliate") != null) { User byEmail = User.getByEmail(req.getParameter("email")); - if (byEmail != null && byEmail.canAssure()) { + if (byEmail != null && byEmail.canVerify()) { o.addAdmin(byEmail, LoginPage.getUser(req), req.getParameter("master") != null); return new RedirectResult(ViewOrgPage.DEFAULT_PATH + "/" + o.getId()); } else { diff --git a/src/club/wpia/gigi/pages/orga/CreateOrgPage.java b/src/club/wpia/gigi/pages/orga/CreateOrgPage.java index 8c45fef5..a4f129a2 100644 --- a/src/club/wpia/gigi/pages/orga/CreateOrgPage.java +++ b/src/club/wpia/gigi/pages/orga/CreateOrgPage.java @@ -12,7 +12,7 @@ import club.wpia.gigi.util.AuthorizationContext; public class CreateOrgPage extends ManagedFormPage { - public static final Group ORG_ASSURER = Group.ORGASSURER; + public static final Group ORG_AGENT = Group.ORGASSURER; public static final String DEFAULT_PATH = "/orga/new"; @@ -22,7 +22,7 @@ public class CreateOrgPage extends ManagedFormPage { @Override public boolean isPermitted(AuthorizationContext ac) { - return ac != null && ac.isInGroup(ORG_ASSURER); + return ac != null && ac.isInGroup(ORG_AGENT); } @Override diff --git a/src/club/wpia/gigi/pages/orga/ViewOrgPage.java b/src/club/wpia/gigi/pages/orga/ViewOrgPage.java index ec4fb365..d676c1de 100644 --- a/src/club/wpia/gigi/pages/orga/ViewOrgPage.java +++ b/src/club/wpia/gigi/pages/orga/ViewOrgPage.java @@ -35,7 +35,7 @@ public class ViewOrgPage extends ManagedMultiFormPage { @Override public boolean isPermitted(AuthorizationContext ac) { - return ac != null && (ac.isInGroup(CreateOrgPage.ORG_ASSURER) || ac.getActor().getOrganisations(true).size() != 0); + return ac != null && (ac.isInGroup(CreateOrgPage.ORG_AGENT) || ac.getActor().getOrganisations(true).size() != 0); } @Override @@ -43,7 +43,7 @@ public class ViewOrgPage extends ManagedMultiFormPage { if (req.getParameter("do_affiliate") != null || req.getParameter("del") != null) { return Form.getForm(req, AffiliationForm.class); } else { - if ( !getUser(req).isInGroup(CreateOrgPage.ORG_ASSURER)) { + if ( !getUser(req).isInGroup(CreateOrgPage.ORG_AGENT)) { return null; } @@ -67,7 +67,7 @@ public class ViewOrgPage extends ManagedMultiFormPage { final Organisation[] orgList = Organisation.getOrganisations(0, 30); HashMap map = new HashMap<>(); final List myOrgs = u.getOrganisations(true); - final boolean orgAss = u.isInGroup(CreateOrgPage.ORG_ASSURER); + final boolean orgAss = u.isInGroup(CreateOrgPage.ORG_AGENT); if (orgAss) { map.put("orgas", makeOrgDataset(orgList)); } else { @@ -86,7 +86,7 @@ public class ViewOrgPage extends ManagedMultiFormPage { return; } final List myOrgs = u.getOrganisations(); - final boolean orgAss = u.isInGroup(CreateOrgPage.ORG_ASSURER); + final boolean orgAss = u.isInGroup(CreateOrgPage.ORG_AGENT); if ( !orgAss && !myOrgs.contains(o)) { resp.sendError(404); return; diff --git a/src/club/wpia/gigi/pages/wot/AssureeSearch.templ b/src/club/wpia/gigi/pages/wot/ApplicantSearch.templ similarity index 100% rename from src/club/wpia/gigi/pages/wot/AssureeSearch.templ rename to src/club/wpia/gigi/pages/wot/ApplicantSearch.templ diff --git a/src/club/wpia/gigi/pages/wot/Points.java b/src/club/wpia/gigi/pages/wot/Points.java index 039d39d9..c6802cac 100644 --- a/src/club/wpia/gigi/pages/wot/Points.java +++ b/src/club/wpia/gigi/pages/wot/Points.java @@ -7,7 +7,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import club.wpia.gigi.dbObjects.User; -import club.wpia.gigi.output.AssurancesDisplay; +import club.wpia.gigi.output.VerificationsDisplay; import club.wpia.gigi.pages.Page; import club.wpia.gigi.util.AuthorizationContext; @@ -21,15 +21,15 @@ public class Points extends Page { private boolean support; - private AssurancesDisplay myDisplay; + private VerificationsDisplay myDisplay; - private AssurancesDisplay toOtherDisplay; + private VerificationsDisplay toOtherDisplay; public Points(boolean support) { super(support ? "Support User Points" : "Points"); this.support = support; - myDisplay = new AssurancesDisplay("asArr", false, support); - toOtherDisplay = new AssurancesDisplay("otherAsArr", true, support); + myDisplay = new VerificationsDisplay("asArr", false, support); + toOtherDisplay = new VerificationsDisplay("otherAsArr", true, support); } @Override @@ -52,12 +52,12 @@ public class Points extends Page { vars.put("username", user.getPreferredName().toString()); vars.put("pointlist", myDisplay); vars.put("madelist", toOtherDisplay); - vars.put("asArr", user.getReceivedAssurances()); - vars.put("otherAsArr", user.getMadeAssurances()); - vars.put("assP", user.getAssurancePoints()); - if (user.canAssure()) { + vars.put("asArr", user.getReceivedVerifications()); + vars.put("otherAsArr", user.getMadeVerifications()); + vars.put("assP", user.getVerificationPoints()); + if (user.canVerify()) { vars.put("expP", user.getExperiencePoints()); - vars.put("maxP", user.getMaxAssurePoints()); + vars.put("maxP", user.getMaxVerifyPoints()); } getDefaultTemplate().output(resp.getWriter(), getLanguage(req), vars); } diff --git a/src/club/wpia/gigi/pages/wot/RequestTTPPage.java b/src/club/wpia/gigi/pages/wot/RequestTTPPage.java index cdabde5e..558ba3a5 100644 --- a/src/club/wpia/gigi/pages/wot/RequestTTPPage.java +++ b/src/club/wpia/gigi/pages/wot/RequestTTPPage.java @@ -6,7 +6,7 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import club.wpia.gigi.dbObjects.Assurance; +import club.wpia.gigi.dbObjects.Verification; import club.wpia.gigi.dbObjects.User; import club.wpia.gigi.output.template.Form; import club.wpia.gigi.pages.LoginPage; @@ -40,10 +40,10 @@ public class RequestTTPPage extends Page { if (u.isInGroup(RequestTTPForm.TTP_APPLICANT)) { map.put("inProgress", true); } else { - if (u.getAssurancePoints() < 100) { + if (u.getVerificationPoints() < 100) { int ttpCount = 0; - for (Assurance a : u.getReceivedAssurances()) { - if (a.getMethod().equals(Assurance.AssuranceType.TTP_ASSISTED.getDescription())) { + for (Verification a : u.getReceivedVerifications()) { + if (a.getMethod().equals(Verification.VerificationType.TTP_ASSISTED.getDescription())) { ttpCount++; } } diff --git a/src/club/wpia/gigi/pages/wot/AssuranceForm.java b/src/club/wpia/gigi/pages/wot/VerificationForm.java similarity index 74% rename from src/club/wpia/gigi/pages/wot/AssuranceForm.java rename to src/club/wpia/gigi/pages/wot/VerificationForm.java index 7df71a78..7a8a558c 100644 --- a/src/club/wpia/gigi/pages/wot/AssuranceForm.java +++ b/src/club/wpia/gigi/pages/wot/VerificationForm.java @@ -12,9 +12,9 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; import club.wpia.gigi.GigiApiException; -import club.wpia.gigi.dbObjects.Assurance.AssuranceType; import club.wpia.gigi.dbObjects.Name; import club.wpia.gigi.dbObjects.User; +import club.wpia.gigi.dbObjects.Verification.VerificationType; import club.wpia.gigi.localisation.Language; import club.wpia.gigi.output.ArrayIterable; import club.wpia.gigi.output.CountrySelector; @@ -29,7 +29,7 @@ import club.wpia.gigi.pages.PasswordResetPage; import club.wpia.gigi.util.DayDate; import club.wpia.gigi.util.Notary; -public class AssuranceForm extends Form { +public class VerificationForm extends Form { public static class ConcatOutputable implements Outputable { @@ -50,9 +50,9 @@ public class AssuranceForm extends Form { } } - private User assuree; + private User applicant; - private Name[] assureeNames; + private Name[] applicantNames; private boolean[] selected; @@ -64,39 +64,39 @@ public class AssuranceForm extends Form { private String aword; - private User assurer; + private User agent; - private AssuranceType type = AssuranceType.FACE_TO_FACE; + private VerificationType type = VerificationType.FACE_TO_FACE; - private static final Template templ = new Template(AssuranceForm.class.getResource("AssuranceForm.templ")); + private static final Template templ = new Template(VerificationForm.class.getResource("VerificationForm.templ")); private CountrySelector cs; - public AssuranceForm(HttpServletRequest hsr, User assuree) throws GigiApiException { + public VerificationForm(HttpServletRequest hsr, User applicant) throws GigiApiException { super(hsr); - assurer = Page.getUser(hsr); - this.assuree = assuree; + agent = Page.getUser(hsr); + this.applicant = applicant; - if (assurer.getId() == assuree.getId()) { + if (agent.getId() == applicant.getId()) { throw new GigiApiException("You cannot verify yourself."); } - if ( !assurer.canAssure()) { + if ( !agent.canVerify()) { throw new GigiApiException("You are not a RA-Agent."); } - Name[] initialNames = this.assuree.getNonDeprecatedNames(); + Name[] initialNames = this.applicant.getNonDeprecatedNames(); LinkedList names = new LinkedList<>(); for (Name name : initialNames) { - if (Notary.checkAssuranceIsPossible(assurer, name)) { + if (Notary.checkVerificationIsPossible(agent, name)) { names.add(name); } } if (names.size() == 0) { throw new GigiApiException(SprintfCommand.createSimple("You have already verified all names of this applicant within the last {0} days.", Notary.LIMIT_DAYS_VERIFICATION)); } - assureeNames = names.toArray(new Name[names.size()]); - dob = this.assuree.getDoB(); - selected = new boolean[assureeNames.length]; + applicantNames = names.toArray(new Name[names.size()]); + dob = this.applicant.getDoB(); + selected = new boolean[applicantNames.length]; cs = new CountrySelector("countryCode", false); } @@ -108,7 +108,7 @@ public class AssuranceForm extends Form { public void outputContent(PrintWriter out, Language l, Map vars) { HashMap res = new HashMap(vars); res.putAll(vars); - res.put("names", new ArrayIterable(assureeNames) { + res.put("names", new ArrayIterable(applicantNames) { @Override public void apply(Name t, Language l, Map vars) { @@ -118,33 +118,33 @@ public class AssuranceForm extends Form { } }); - res.put("name", assuree.getPreferredName().toString()); - res.put("maxpoints", assurer.getMaxAssurePoints()); - res.put("dob", sdf.format(assuree.getDoB().toDate())); - res.put("dobFmt2", sdf2.format(assuree.getDoB().toDate())); + res.put("name", applicant.getPreferredName().toString()); + res.put("maxpoints", agent.getMaxVerifyPoints()); + res.put("dob", sdf.format(applicant.getDoB().toDate())); + res.put("dobFmt2", sdf2.format(applicant.getDoB().toDate())); res.put("location", location); res.put("date", date); res.put("aword", aword); res.put("countryCode", cs); - final LinkedList ats = new LinkedList<>(); - for (AssuranceType at : AssuranceType.values()) { + final LinkedList ats = new LinkedList<>(); + for (VerificationType at : VerificationType.values()) { try { - Notary.may(assurer, assuree, at); + Notary.may(agent, applicant, at); ats.add(at); } catch (GigiApiException e) { } } res.put("ats", new IterableDataset() { - Iterator t = ats.iterator(); + Iterator t = ats.iterator(); @Override public boolean next(Language l, Map vars) { if ( !t.hasNext()) { return false; } - AssuranceType t1 = t.next(); + VerificationType t1 = t.next(); vars.put("type", t1.getDescription()); vars.put("id", t1.toString()); vars.put("sel", t1 == type ? " selected" : ""); @@ -175,10 +175,10 @@ public class AssuranceForm extends Form { } else { aword = null; } - String val = req.getParameter("assuranceType"); + String val = req.getParameter("verificationType"); if (val != null) { try { - type = AssuranceType.valueOf(val); + type = VerificationType.valueOf(val); } catch (IllegalArgumentException e) { gae.mergeInto(new GigiApiException("Verification Type wrong.")); } @@ -195,10 +195,10 @@ public class AssuranceForm extends Form { gae.mergeInto(new GigiApiException("The points entered were not a number.")); } } - String[] parameterValues = req.getParameterValues("assuredName"); + String[] parameterValues = req.getParameterValues("verifiedName"); HashSet data = new HashSet<>(Arrays.asList(parameterValues == null ? new String[0] : parameterValues)); - for (int i = 0; i < assureeNames.length; i++) { - selected[i] = data.contains(Integer.toString(assureeNames[i].getId())); + for (int i = 0; i < applicantNames.length; i++) { + selected[i] = data.contains(Integer.toString(applicantNames[i].getId())); } if ( !gae.isEmpty()) { @@ -208,20 +208,20 @@ public class AssuranceForm extends Form { LinkedList toAssure = new LinkedList(); for (int i = 0; i < selected.length; i++) { if (selected[i]) { - toAssure.add(assureeNames[i]); + toAssure.add(applicantNames[i]); } } if (toAssure.size() == 0) { throw new GigiApiException("You must confirm at least one name to verify an account."); } - Notary.assureAll(assurer, assuree, dob, pointsI, location, req.getParameter("date"), type, toAssure.toArray(new Name[toAssure.size()]), cs.getCountry()); + Notary.verifyAll(agent, applicant, dob, pointsI, location, req.getParameter("date"), type, toAssure.toArray(new Name[toAssure.size()]), cs.getCountry()); Outputable result = new TranslateCommand("Verification complete."); if (isWithPasswordReset()) { - Language langApplicant = Language.getInstance(assuree.getPreferredLocale()); + Language langApplicant = Language.getInstance(applicant.getPreferredLocale()); String method = langApplicant.getTranslation("A password reset was triggered. If you did a password reset by verification, please enter your secret password using this form:"); String subject = langApplicant.getTranslation("Password reset by verification"); - PasswordResetPage.initPasswordResetProcess(assuree, req, aword, langApplicant, method, subject); + PasswordResetPage.initPasswordResetProcess(applicant, req, aword, langApplicant, method, subject); result = new ConcatOutputable(result, new TranslateCommand("Password reset successful.")); } return new SuccessMessageResult(result); @@ -231,8 +231,8 @@ public class AssuranceForm extends Form { return aword != null && !aword.equals(""); } - public User getAssuree() { - return assuree; + public User getApplicant() { + return applicant; } } diff --git a/src/club/wpia/gigi/pages/wot/AssuranceForm.templ b/src/club/wpia/gigi/pages/wot/VerificationForm.templ similarity index 91% rename from src/club/wpia/gigi/pages/wot/AssuranceForm.templ rename to src/club/wpia/gigi/pages/wot/VerificationForm.templ index a4580c6e..540faaae 100644 --- a/src/club/wpia/gigi/pages/wot/AssuranceForm.templ +++ b/src/club/wpia/gigi/pages/wot/VerificationForm.templ @@ -8,7 +8,7 @@ : - > + > @@ -55,7 +55,7 @@ - + checked> diff --git a/src/club/wpia/gigi/pages/wot/AssurePage.java b/src/club/wpia/gigi/pages/wot/VerifyPage.java similarity index 84% rename from src/club/wpia/gigi/pages/wot/AssurePage.java rename to src/club/wpia/gigi/pages/wot/VerifyPage.java index f17aad64..e3fdf534 100644 --- a/src/club/wpia/gigi/pages/wot/AssurePage.java +++ b/src/club/wpia/gigi/pages/wot/VerifyPage.java @@ -17,15 +17,15 @@ import club.wpia.gigi.output.template.Template; import club.wpia.gigi.pages.Page; import club.wpia.gigi.util.AuthorizationContext; -public class AssurePage extends Page { +public class VerifyPage extends Page { - public static final String PATH = "/wot/assure"; + public static final String PATH = "/wot/verify"; DateSelector ds = new DateSelector("day", "month", "year"); - private static final Template t = new Template(AssuranceForm.class.getResource("AssureeSearch.templ")); + private static final Template t = new Template(VerificationForm.class.getResource("ApplicantSearch.templ")); - public AssurePage() { + public VerifyPage() { super("Verify someone"); } @@ -41,13 +41,13 @@ public class AssurePage extends Page { @Override public boolean isPermitted(AuthorizationContext ac) { - return ac != null && ac.canAssure(); + return ac != null && ac.canVerify(); } @Override public boolean beforePost(HttpServletRequest req, HttpServletResponse resp) throws IOException { if (req.getParameter("search") == null) { - AssuranceForm form = Form.getForm(req, AssuranceForm.class); + VerificationForm form = Form.getForm(req, VerificationForm.class); return form.submitExceptionProtected(req, resp); } return super.beforePost(req, resp); @@ -58,7 +58,7 @@ public class AssurePage extends Page { PrintWriter out = resp.getWriter(); if (req.getParameter("search") == null) { if (Form.printFormErrors(req, out)) { - AssuranceForm form = Form.getForm(req, AssuranceForm.class); + VerificationForm form = Form.getForm(req, VerificationForm.class); form.output(out, getLanguage(req), getDefaultVars(req)); } return; @@ -82,9 +82,9 @@ public class AssurePage extends Page { } else if (getUser(req).getId() == id) { } else { - User assuree = User.getById(id); + User applicant = User.getById(id); try { - new AssuranceForm(req, assuree).output(out, getLanguage(req), getDefaultVars(req)); + new VerificationForm(req, applicant).output(out, getLanguage(req), getDefaultVars(req)); } catch (GigiApiException e) { e.format(out, Page.getLanguage(req)); } diff --git a/src/club/wpia/gigi/util/AuthorizationContext.java b/src/club/wpia/gigi/util/AuthorizationContext.java index 84f10f74..40a63335 100644 --- a/src/club/wpia/gigi/util/AuthorizationContext.java +++ b/src/club/wpia/gigi/util/AuthorizationContext.java @@ -95,7 +95,7 @@ public class AuthorizationContext implements Outputable, Serializable { } } - public boolean canAssure() { - return target instanceof User && ((User) target).canAssure(); + public boolean canVerify() { + return target instanceof User && ((User) target).canVerify(); } } diff --git a/src/club/wpia/gigi/util/Notary.java b/src/club/wpia/gigi/util/Notary.java index 3df11763..a619da53 100644 --- a/src/club/wpia/gigi/util/Notary.java +++ b/src/club/wpia/gigi/util/Notary.java @@ -15,7 +15,7 @@ import club.wpia.gigi.dbObjects.Country; import club.wpia.gigi.dbObjects.Group; import club.wpia.gigi.dbObjects.Name; import club.wpia.gigi.dbObjects.User; -import club.wpia.gigi.dbObjects.Assurance.AssuranceType; +import club.wpia.gigi.dbObjects.Verification.VerificationType; import club.wpia.gigi.localisation.Language; import club.wpia.gigi.output.ArrayIterable; import club.wpia.gigi.output.DateSelector; @@ -44,47 +44,47 @@ public class Notary { } } - public static boolean checkAssuranceIsPossible(User assurer, Name target) { + public static boolean checkVerificationIsPossible(User agent, Name target) { try (GigiPreparedStatement ps = new GigiPreparedStatement("SELECT 1 FROM `notary` where `to`=? and `from`=? and `method` = ? ::`notaryType` AND `deleted` IS NULL AND `when` > (now() - interval '1 days' * ?)")) { ps.setInt(1, target.getId()); - ps.setInt(2, assurer.getId()); - ps.setEnum(3, AssuranceType.FACE_TO_FACE); + ps.setInt(2, agent.getId()); + ps.setEnum(3, VerificationType.FACE_TO_FACE); ps.setInt(4, LIMIT_DAYS_VERIFICATION); GigiResultSet rs = ps.executeQuery(); return !rs.next(); } } - public static final Group ASSURER_BLOCKED = Group.BLOCKEDASSURER; + public static final Group AGENT_BLOCKED = Group.BLOCKEDASSURER; - public static final Group ASSUREE_BLOCKED = Group.BLOCKEDASSUREE; + public static final Group APPLICANT_BLOCKED = Group.BLOCKEDASSUREE; public static final Group VERIFY_NOTIFICATION = Group.VERIFY_NOTIFICATION; /** - * This method assures another user. + * This method verifies another user. * - * @see User#canAssure() (for assurer) - * @see #checkAssuranceIsPossible(User, User) (for assurer or assuree) - * @param assurer - * the person that wants to assure - * @param assuree - * the person that should be assured - * @param assureeName + * @see User#canVerify() (for agent) + * @see #checkVerificationIsPossible(User, User) (for agent or applicant) + * @param agent + * the person that wants to verify + * @param applicant + * the person that should be verified + * @param applicantName * the Name that was personally verified * @param dob - * the Date of birth that the assurer verified + * the Date of birth that the agent verified * @param awarded * the points that should be awarded in total * @param location - * the location where the assurance took place + * the location where the verification took place * @param date - * the date when the assurance took place + * the date when the verification took place * @throws GigiApiException - * if the assurance fails (for various reasons) + * if the verification fails (for various reasons) */ - public synchronized static void assure(User assurer, User assuree, Name assureeName, DayDate dob, int awarded, String location, String date, AssuranceType type, Country country) throws GigiApiException { - may(assurer, assuree, AssuranceType.FACE_TO_FACE); + public synchronized static void verify(User agent, User applicant, Name applicantName, DayDate dob, int awarded, String location, String date, VerificationType type, Country country) throws GigiApiException { + may(agent, applicant, VerificationType.FACE_TO_FACE); GigiApiException gae = new GigiApiException(); if ( !gae.isEmpty()) { throw gae; @@ -120,34 +120,34 @@ public class Notary { gae.mergeInto(new GigiApiException("You failed to enter the country of your meeting.")); } - synchronized (assuree) { - if (assurer.getId() == assuree.getId()) { + synchronized (applicant) { + if (agent.getId() == applicant.getId()) { throw new GigiApiException("You cannot verify yourself."); } - if (assureeName.getOwner() != assuree) { + if (applicantName.getOwner() != applicant) { throw new GigiApiException("Internal error, name does not belong to applicant."); } - if ( !assurer.canAssure()) { + if ( !agent.canVerify()) { throw new GigiApiException("You are not an RA-Agent."); } - if ( !checkAssuranceIsPossible(assurer, assureeName)) { + if ( !checkVerificationIsPossible(agent, applicantName)) { gae.mergeInto(new GigiApiException(SprintfCommand.createSimple("You have already verified this applicant within the last {0} days.", LIMIT_DAYS_VERIFICATION))); } - if ( !assuree.getDoB().equals(dob)) { + if ( !applicant.getDoB().equals(dob)) { gae.mergeInto(new GigiApiException("The person you are verifying changed his personal details.")); } if (awarded < 0) { gae.mergeInto(new GigiApiException("The points you are trying to award are out of range.")); } else { - if (type == AssuranceType.NUCLEUS) { + if (type == VerificationType.NUCLEUS) { if (awarded > 50) { gae.mergeInto(new GigiApiException("The points you are trying to award are out of range.")); } } else { - if (awarded > assurer.getMaxAssurePoints()) { + if (awarded > agent.getMaxVerifyPoints()) { gae.mergeInto(new GigiApiException("The points you are trying to award are out of range.")); } } @@ -157,24 +157,24 @@ public class Notary { throw gae; } - if (type == AssuranceType.FACE_TO_FACE) { - assureF2F(assurer, assuree, assureeName, awarded, location, date, country); - } else if (type == AssuranceType.NUCLEUS) { - assureNucleus(assurer, assuree, assureeName, awarded, location, date, country); - } else if (type == AssuranceType.TTP_ASSISTED) { - assureTTP(assurer, assuree, assureeName, awarded, location, date, country); + if (type == VerificationType.FACE_TO_FACE) { + verifyF2F(agent, applicant, applicantName, awarded, location, date, country); + } else if (type == VerificationType.NUCLEUS) { + verifyNucleus(agent, applicant, applicantName, awarded, location, date, country); + } else if (type == VerificationType.TTP_ASSISTED) { + verifyTTP(agent, applicant, applicantName, awarded, location, date, country); } else { throw new GigiApiException(SprintfCommand.createSimple("Unknown Verification type: {0}", type.toString())); } - assurer.invalidateMadeAssurances(); - assuree.invalidateReceivedAssurances(); + agent.invalidateMadeVerifications(); + applicant.invalidateReceivedVerifications(); } } - private static void assureF2F(User assurer, User assuree, Name name, int awarded, String location, String date, Country country) throws GigiApiException { - may(assurer, assuree, AssuranceType.FACE_TO_FACE); + private static void verifyF2F(User agent, User applicant, Name name, int awarded, String location, String date, Country country) throws GigiApiException { + may(agent, applicant, VerificationType.FACE_TO_FACE); try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?, `country`=?")) { - ps.setInt(1, assurer.getId()); + ps.setInt(1, agent.getId()); ps.setInt(2, name.getId()); ps.setInt(3, awarded); ps.setString(4, location); @@ -184,62 +184,62 @@ public class Notary { } } - private static void assureTTP(User assurer, User assuree, Name name, int awarded, String location, String date, Country country) throws GigiApiException { - may(assurer, assuree, AssuranceType.TTP_ASSISTED); + private static void verifyTTP(User agent, User applicant, Name name, int awarded, String location, String date, Country country) throws GigiApiException { + may(agent, applicant, VerificationType.TTP_ASSISTED); try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?, `country`=?, `method`='TTP-Assisted'")) { - ps.setInt(1, assurer.getId()); + ps.setInt(1, agent.getId()); ps.setInt(2, name.getId()); ps.setInt(3, awarded); ps.setString(4, location); ps.setString(5, date); ps.setString(6, country.getCode()); ps.execute(); - assuree.revokeGroup(assurer, Group.TTP_APPLICANT); + applicant.revokeGroup(agent, Group.TTP_APPLICANT); } } - public static void may(User assurer, User assuree, AssuranceType t) throws GigiApiException { - if (assuree.isInGroup(ASSUREE_BLOCKED)) { + public static void may(User agent, User applicant, VerificationType t) throws GigiApiException { + if (applicant.isInGroup(APPLICANT_BLOCKED)) { throw new GigiApiException("The applicant is blocked."); } - if (assurer.isInGroup(ASSURER_BLOCKED)) { + if (agent.isInGroup(AGENT_BLOCKED)) { throw new GigiApiException("The RA Agent is blocked."); } - if (t == AssuranceType.NUCLEUS) { - if ( !assurer.isInGroup(Group.NUCLEUS_ASSURER)) { + if (t == VerificationType.NUCLEUS) { + if ( !agent.isInGroup(Group.NUCLEUS_ASSURER)) { throw new GigiApiException("RA Agent needs to be Nucleus RA Agent."); } return; - } else if (t == AssuranceType.TTP_ASSISTED) { - if ( !assurer.isInGroup(Group.TTP_ASSURER)) { + } else if (t == VerificationType.TTP_ASSISTED) { + if ( !agent.isInGroup(Group.TTP_ASSURER)) { throw new GigiApiException("RA Agent needs to be TTP RA Agent."); } - if ( !assuree.isInGroup(Group.TTP_APPLICANT)) { + if ( !applicant.isInGroup(Group.TTP_APPLICANT)) { throw new GigiApiException("Applicant needs to be TTP Applicant."); } return; - } else if (t == AssuranceType.FACE_TO_FACE) { + } else if (t == VerificationType.FACE_TO_FACE) { return; } throw new GigiApiException("Verification type not possible."); } - private static void assureNucleus(User assurer, User assuree, Name name, int awarded, String location, String date, Country country) throws GigiApiException { - may(assurer, assuree, AssuranceType.NUCLEUS); + private static void verifyNucleus(User agent, User applicant, Name name, int awarded, String location, String date, Country country) throws GigiApiException { + may(agent, applicant, VerificationType.NUCLEUS); // Do up to 35 points as f2f - int f2fPoints = Math.min(assurer.getMaxAssurePoints(), awarded); - assureF2F(assurer, assuree, name, f2fPoints, location, date, country); + int f2fPoints = Math.min(agent.getMaxVerifyPoints(), awarded); + verifyF2F(agent, applicant, name, f2fPoints, location, date, country); awarded -= f2fPoints; if (awarded <= 0) { return; } - // Assure remaining points as "Nucleus Bonus" + // Verify remaining points as "Nucleus Bonus" // Valid for 4 Weeks = 28 days try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?, `country`=?, `method`='Nucleus Bonus', `expire` = CURRENT_TIMESTAMP + interval '28 days'")) { - ps.setInt(1, assurer.getId()); + ps.setInt(1, agent.getId()); ps.setInt(2, name.getId()); ps.setInt(3, awarded); ps.setString(4, location); @@ -249,20 +249,20 @@ public class Notary { } } - public synchronized static void assureAll(User assurer, User assuree, DayDate dob, int awarded, String location, String date, AssuranceType type, Name[] toAssure, Country country) throws GigiApiException { - if (toAssure.length == 0) { + public synchronized static void verifyAll(User agent, User applicant, DayDate dob, int awarded, String location, String date, VerificationType type, Name[] toVerify, Country country) throws GigiApiException { + if (toVerify.length == 0) { throw new GigiApiException("You must confirm at least one name to verify an account."); } - boolean[] hadLessThan50Points = new boolean[toAssure.length]; - boolean hadTotalLessThan100 = assuree.getAssurancePoints() < 100; - for (int i = 0; i < toAssure.length; i++) { - hadLessThan50Points[i] = toAssure[i].getAssurancePoints() < 50; + boolean[] hadLessThan50Points = new boolean[toVerify.length]; + boolean hadTotalLessThan100 = applicant.getVerificationPoints() < 100; + for (int i = 0; i < toVerify.length; i++) { + hadLessThan50Points[i] = toVerify[i].getVerificationPoints() < 50; - assure(assurer, assuree, toAssure[i], dob, awarded, location, date, type, country); + verify(agent, applicant, toVerify[i], dob, awarded, location, date, type, country); } - sendVerificationNotificationApplicant(assurer, assuree, toAssure, awarded, hadLessThan50Points, hadTotalLessThan100); - if (assurer.isInGroup(VERIFY_NOTIFICATION)) { - sendVerificationNotificationAgent(assurer, assuree, toAssure, awarded, location, date, country); + sendVerificationNotificationApplicant(agent, applicant, toVerify, awarded, hadLessThan50Points, hadTotalLessThan100); + if (agent.isInGroup(VERIFY_NOTIFICATION)) { + sendVerificationNotificationAgent(agent, applicant, toVerify, awarded, location, date, country); } } @@ -270,14 +270,14 @@ public class Notary { private static final MailTemplate verificationAgentEntered = new MailTemplate(Notary.class.getResource("VerificationAgentEntered.templ")); - private static void sendVerificationNotificationApplicant(User assurer, User assuree, Name[] toAssure, final int awarded, final boolean[] hadLessThan50Points, boolean hadTotalLessThan100) { + private static void sendVerificationNotificationApplicant(User agent, User applicant, Name[] toVerify, final int awarded, final boolean[] hadLessThan50Points, boolean hadTotalLessThan100) { HashMap mailVars = new HashMap<>(); - mailVars.put("agent", assurer.getPreferredName().toString()); - mailVars.put("names", new ArrayIterable(toAssure) { + mailVars.put("agent", agent.getPreferredName().toString()); + mailVars.put("names", new ArrayIterable(toVerify) { @Override public void apply(Name t, Language l, Map vars) { - int totalVP = t.getAssurancePoints(); + int totalVP = t.getVerificationPoints(); vars.put("name", t.toString()); vars.put("points", Integer.toString(awarded)); vars.put("total", totalVP); @@ -292,7 +292,7 @@ public class Notary { }); - int grandTotalVP = assuree.getAssurancePoints(); + int grandTotalVP = applicant.getVerificationPoints(); if (grandTotalVP >= 50 && grandTotalVP < 100) { mailVars.put("remAll", (100 - grandTotalVP)); mailVars.remove("gotGreaterAll"); @@ -301,7 +301,7 @@ public class Notary { mailVars.remove("remAll"); } try { - verificationEntered.sendMail(Language.getInstance(assuree.getPreferredLocale()), mailVars, assuree.getEmail()); + verificationEntered.sendMail(Language.getInstance(applicant.getPreferredLocale()), mailVars, applicant.getEmail()); } catch (IOException e) { e.printStackTrace(); } diff --git a/tests/club/wpia/gigi/TestOrga.java b/tests/club/wpia/gigi/TestOrga.java index 8a7f7a52..2c08c309 100644 --- a/tests/club/wpia/gigi/TestOrga.java +++ b/tests/club/wpia/gigi/TestOrga.java @@ -17,13 +17,13 @@ public class TestOrga extends BusinessTest { @Test public void testAddRm() throws GigiApiException, IOException { - User u1 = User.getById(createAssuranceUser("fn", "ln", createUniqueName() + "@email.org", TEST_PASSWORD)); + User u1 = User.getById(createVerificationUser("fn", "ln", createUniqueName() + "@email.org", TEST_PASSWORD)); u1.grantGroup(getSupporter(), Group.ORGASSURER); - User u2 = User.getById(createAssuranceUser("fn", "ln", createUniqueName() + "@email.org", TEST_PASSWORD)); + User u2 = User.getById(createVerificationUser("fn", "ln", createUniqueName() + "@email.org", TEST_PASSWORD)); u2.grantGroup(getSupporter(), Group.ORGASSURER); - User u3 = User.getById(createAssuranceUser("fn", "ln", createUniqueName() + "@email.org", TEST_PASSWORD)); + User u3 = User.getById(createVerificationUser("fn", "ln", createUniqueName() + "@email.org", TEST_PASSWORD)); u3.grantGroup(getSupporter(), Group.ORGASSURER); - User u4 = User.getById(createAssuranceUser("fn", "ln", createUniqueName() + "@email.org", TEST_PASSWORD)); + User u4 = User.getById(createVerificationUser("fn", "ln", createUniqueName() + "@email.org", TEST_PASSWORD)); u4.grantGroup(getSupporter(), Group.ORGASSURER); Organisation o1 = new Organisation("name", Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS), "prov", "city", "email", "optional name", "postal address", u1); assertEquals(0, o1.getAllAdmins().size()); diff --git a/tests/club/wpia/gigi/TestSeparateSessionScope.java b/tests/club/wpia/gigi/TestSeparateSessionScope.java index c5bb9dce..e3ad9286 100644 --- a/tests/club/wpia/gigi/TestSeparateSessionScope.java +++ b/tests/club/wpia/gigi/TestSeparateSessionScope.java @@ -27,7 +27,7 @@ public class TestSeparateSessionScope extends ManagedTest { @Test public void testSeparateScope() throws IOException, GeneralSecurityException, SQLException, InterruptedException, GigiApiException { String mail = "thisgo" + createUniqueName() + "@example.com"; - int user = createAssuranceUser("test", "tugo", mail, TEST_PASSWORD); + int user = createVerificationUser("test", "tugo", mail, TEST_PASSWORD); String cookie = login(mail, TEST_PASSWORD); KeyPair kp = generateKeypair(); String csr = generatePEMCSR(kp, "CN=hans"); @@ -49,7 +49,7 @@ public class TestSeparateSessionScope extends ManagedTest { @Test public void testSerialSteal() throws IOException, GeneralSecurityException, SQLException, InterruptedException, GigiApiException { String mail = "thisgo" + createUniqueName() + "@example.com"; - int user = createAssuranceUser("test", "tugo", mail, TEST_PASSWORD); + int user = createVerificationUser("test", "tugo", mail, TEST_PASSWORD); KeyPair kp = generateKeypair(); String csr = generatePEMCSR(kp, "CN=hans"); User u = User.getById(user); diff --git a/tests/club/wpia/gigi/TestUser.java b/tests/club/wpia/gigi/TestUser.java index 8f5dbd33..7ad3f49d 100644 --- a/tests/club/wpia/gigi/TestUser.java +++ b/tests/club/wpia/gigi/TestUser.java @@ -10,8 +10,8 @@ import java.util.Locale; import org.hamcrest.CoreMatchers; import org.junit.Test; -import club.wpia.gigi.dbObjects.Assurance; -import club.wpia.gigi.dbObjects.Assurance.AssuranceType; +import club.wpia.gigi.dbObjects.Verification; +import club.wpia.gigi.dbObjects.Verification.VerificationType; import club.wpia.gigi.dbObjects.Country; import club.wpia.gigi.dbObjects.Country.CountryCodeType; import club.wpia.gigi.dbObjects.Domain; @@ -50,17 +50,17 @@ public class TestUser extends BusinessTest { } @Test - public void testAssurerUtilMethods() throws SQLException, GigiApiException { - int id = createAssuranceUser("aä", "b", createUniqueName() + "a@email.org", TEST_PASSWORD); + public void testAgentUtilMethods() throws SQLException, GigiApiException { + int id = createVerificationUser("aä", "b", createUniqueName() + "a@email.org", TEST_PASSWORD); User u = User.getById(id); - assertTrue(u.canAssure()); - int assurancePoints = u.getAssurancePoints(); + assertTrue(u.canVerify()); + int verificationPoints = u.getVerificationPoints(); int expPoints = u.getExperiencePoints(); - assertEquals(100, assurancePoints); + assertEquals(100, verificationPoints); assertEquals(User.EXPERIENCE_POINTS, expPoints); assertTrue(u.hasPassedCATS()); - assertEquals(10, u.getMaxAssurePoints()); + assertEquals(10, u.getMaxVerifyPoints()); } @Test @@ -111,8 +111,8 @@ public class TestUser extends BusinessTest { User[] us = new User[5]; for (int i = 0; i < us.length; i++) { - us[i] = User.getById(createAssuranceUser("f", "l", createUniqueName() + "@email.com", TEST_PASSWORD)); - Notary.assure(us[i], u, u.getPreferredName(), u.getDoB(), 10, "here", validVerificationDateString(), AssuranceType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); + us[i] = User.getById(createVerificationUser("f", "l", createUniqueName() + "@email.com", TEST_PASSWORD)); + Notary.verify(us[i], u, u.getPreferredName(), u.getDoB(), 10, "here", validVerificationDateString(), VerificationType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); } assertTrue(u.isValidName("aä b")); @@ -126,10 +126,10 @@ public class TestUser extends BusinessTest { long d = System.currentTimeMillis(); d -= d % DayDate.MILLI_DAY; User u = createUser("f", "l", createUniqueName() + "@example.org", TEST_PASSWORD); - Assurance[] ma = u.getMadeAssurances(); - Assurance[] ma2 = u.getMadeAssurances(); - Assurance[] ra = u.getReceivedAssurances(); - Assurance[] ra2 = u.getReceivedAssurances(); + Verification[] ma = u.getMadeVerifications(); + Verification[] ma2 = u.getMadeVerifications(); + Verification[] ra = u.getReceivedVerifications(); + Verification[] ra2 = u.getReceivedVerifications(); assertEquals(0, u.getCertificates(false).length); assertEquals(0, ma.length); assertEquals(0, ma2.length); diff --git a/tests/club/wpia/gigi/api/ImportCATSResult.java b/tests/club/wpia/gigi/api/ImportCATSResult.java index 1d392500..18f1ae90 100644 --- a/tests/club/wpia/gigi/api/ImportCATSResult.java +++ b/tests/club/wpia/gigi/api/ImportCATSResult.java @@ -57,7 +57,7 @@ public class ImportCATSResult extends RestrictedApiTest { apiImport(u2, "Test Training"); assertEquals(1, u2.getTrainings().length); assertFalse(u2.hasPassedCATS()); - apiImport(u2, CATSType.ASSURER_CHALLENGE.getDisplayName()); + apiImport(u2, CATSType.AGENT_CHALLENGE.getDisplayName()); assertEquals(2, u2.getTrainings().length); assertTrue(u2.hasPassedCATS()); diff --git a/tests/club/wpia/gigi/api/IssueCert.java b/tests/club/wpia/gigi/api/IssueCert.java index d5302f92..757e50a7 100644 --- a/tests/club/wpia/gigi/api/IssueCert.java +++ b/tests/club/wpia/gigi/api/IssueCert.java @@ -73,8 +73,8 @@ public class IssueCert extends ClientTest { } @Test - public void testIssueCertAssured() throws Exception { - makeAssurer(id); + public void testIssueCertVerified() throws Exception { + makeAgent(id); String intendedName = "a b"; String cert = issueCert(generatePEMCSR(kp, "EMAIL=" + email + ",CN=" + intendedName), "profile=client-a"); @@ -87,7 +87,7 @@ public class IssueCert extends ClientTest { @Test public void testIssueOrgCert() throws Exception { - makeAssurer(id); + makeAgent(id); u.grantGroup(getSupporter(), Group.ORGASSURER); Organisation o1 = new Organisation("name", Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS), "pr", "st", "test@mail", "", "", u); diff --git a/tests/club/wpia/gigi/dbObjects/TestAssureName.java b/tests/club/wpia/gigi/dbObjects/TestAssureName.java deleted file mode 100644 index 4d902509..00000000 --- a/tests/club/wpia/gigi/dbObjects/TestAssureName.java +++ /dev/null @@ -1,38 +0,0 @@ -package club.wpia.gigi.dbObjects; - -import static org.junit.Assert.*; - -import org.junit.Test; - -import club.wpia.gigi.GigiApiException; -import club.wpia.gigi.dbObjects.Country; -import club.wpia.gigi.dbObjects.Name; -import club.wpia.gigi.dbObjects.NamePart; -import club.wpia.gigi.dbObjects.User; -import club.wpia.gigi.dbObjects.Assurance.AssuranceType; -import club.wpia.gigi.dbObjects.Country.CountryCodeType; -import club.wpia.gigi.dbObjects.NamePart.NamePartType; -import club.wpia.gigi.testUtils.ClientBusinessTest; -import club.wpia.gigi.util.Notary; - -public class TestAssureName extends ClientBusinessTest { - - @Test - public void testIt() throws GigiApiException { - User u0 = User.getById(createAssuranceUser("f", "l", createUniqueName() + "@email.com", TEST_PASSWORD)); - Name n2 = new Name(u, new NamePart(NamePartType.SINGLE_NAME, "Testiaa")); - Name n3 = new Name(u, new NamePart(NamePartType.SINGLE_NAME, "Testiaa")); - Name n4 = new Name(u, new NamePart(NamePartType.SINGLE_NAME, "Testiaac")); - - assertEquals(0, n0.getAssurancePoints()); - Notary.assure(u0, u, n0, u.getDoB(), 10, "test mgr", validVerificationDateString(), AssuranceType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); - assertEquals(10, n0.getAssurancePoints()); - Notary.assure(u0, u, n2, u.getDoB(), 10, "test mgr", validVerificationDateString(), AssuranceType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); - assertEquals(10, n2.getAssurancePoints()); - Notary.assure(u0, u, n3, u.getDoB(), 10, "test mgr", validVerificationDateString(), AssuranceType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); - assertEquals(10, n3.getAssurancePoints()); - Notary.assure(u0, u, n4, u.getDoB(), 10, "test mgr", validVerificationDateString(), AssuranceType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); - assertEquals(10, n4.getAssurancePoints()); - assertEquals(10, u.getMaxAssurePoints()); - } -} diff --git a/tests/club/wpia/gigi/dbObjects/TestCATS.java b/tests/club/wpia/gigi/dbObjects/TestCATS.java index 87513e14..404618ae 100644 --- a/tests/club/wpia/gigi/dbObjects/TestCATS.java +++ b/tests/club/wpia/gigi/dbObjects/TestCATS.java @@ -30,10 +30,10 @@ public class TestCATS extends ClientBusinessTest { @Test public void testRAChallenge() throws IOException, GeneralSecurityException { - CATS.enterResult(u, CATSType.ASSURER_CHALLENGE, min12month, "en_US", "1"); - assertFalse(CATS.isInCatsLimit(id, CATSType.ASSURER_CHALLENGE.getId())); - CATS.enterResult(u, CATSType.ASSURER_CHALLENGE, min11month, "en_US", "1"); - assertTrue(CATS.isInCatsLimit(id, CATSType.ASSURER_CHALLENGE.getId())); + CATS.enterResult(u, CATSType.AGENT_CHALLENGE, min12month, "en_US", "1"); + assertFalse(CATS.isInCatsLimit(id, CATSType.AGENT_CHALLENGE.getId())); + CATS.enterResult(u, CATSType.AGENT_CHALLENGE, min11month, "en_US", "1"); + assertTrue(CATS.isInCatsLimit(id, CATSType.AGENT_CHALLENGE.getId())); } @Test diff --git a/tests/club/wpia/gigi/dbObjects/TestAssurance.java b/tests/club/wpia/gigi/dbObjects/TestVerification.java similarity index 67% rename from tests/club/wpia/gigi/dbObjects/TestAssurance.java rename to tests/club/wpia/gigi/dbObjects/TestVerification.java index 3906e601..a20f4cef 100644 --- a/tests/club/wpia/gigi/dbObjects/TestAssurance.java +++ b/tests/club/wpia/gigi/dbObjects/TestVerification.java @@ -15,7 +15,7 @@ import club.wpia.gigi.testUtils.BusinessTest; import club.wpia.gigi.util.DayDate; import club.wpia.gigi.util.Notary; -public class TestAssurance extends BusinessTest { +public class TestVerification extends BusinessTest { private final Timestamp yesterday = new Timestamp(System.currentTimeMillis() - DayDate.MILLI_DAY); @@ -45,12 +45,12 @@ public class TestAssurance extends BusinessTest { private int applicantMultID; - public TestAssurance() throws GigiApiException { + public TestVerification() throws GigiApiException { } // test for verification in 39 month period - private void enterAssurance(int agentID, int applicantID) { + private void enterVerification(int agentID, int applicantID) { try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?")) { ps.setInt(1, agentID); ps.setInt(2, applicantID); @@ -62,7 +62,7 @@ public class TestAssurance extends BusinessTest { } } - private void enterAssuranceExpired(int agentID, int applicantID, Timestamp expired) { + private void enterVerificationExpired(int agentID, int applicantID, Timestamp expired) { try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?, `expire`=? ")) { ps.setInt(1, agentID); ps.setInt(2, applicantID); @@ -74,7 +74,7 @@ public class TestAssurance extends BusinessTest { } } - private void enterAssuranceWhen(int agentID, int applicantID, Timestamp when) { + private void enterVerificationWhen(int agentID, int applicantID, Timestamp when) { try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?, `when`=? ")) { ps.setInt(1, agentID); ps.setInt(2, applicantID); @@ -86,7 +86,7 @@ public class TestAssurance extends BusinessTest { } } - private void enterAssuranceWhen(int agentID, int applicantID, Timestamp when, int points) { + private void enterVericationWhen(int agentID, int applicantID, Timestamp when, int points) { try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?, `when`=? ")) { ps.setInt(1, agentID); ps.setInt(2, applicantID); @@ -98,7 +98,7 @@ public class TestAssurance extends BusinessTest { } } - private void enterAssuranceDeleted(int agentID, int applicantID, Timestamp deleted) { + private void enterVerificationDeleted(int agentID, int applicantID, Timestamp deleted) { try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?, `deleted`=? ")) { ps.setInt(1, agentID); ps.setInt(2, applicantID); @@ -112,8 +112,8 @@ public class TestAssurance extends BusinessTest { @Before public void initTest() throws GigiApiException { - agentID = createAssuranceUser("a", "b", createUniqueName() + "@example.com", TEST_PASSWORD); - agent2ID = createAssuranceUser("a", "d", createUniqueName() + "@example.com", TEST_PASSWORD); + agentID = createVerificationUser("a", "b", createUniqueName() + "@example.com", TEST_PASSWORD); + agent2ID = createVerificationUser("a", "d", createUniqueName() + "@example.com", TEST_PASSWORD); applicantID = createVerifiedUser("a", "c", createUniqueName() + "@example.com", TEST_PASSWORD); applicant = User.getById(applicantID); applicantNameID = User.getById(applicantID).getPreferredName().getId(); @@ -122,112 +122,112 @@ public class TestAssurance extends BusinessTest { @Test public void testVerificationYesterday() throws IOException { - enterAssuranceWhen(agentID, applicantNameID, yesterday); + enterVerificationWhen(agentID, applicantNameID, yesterday); assertTrue(applicant.isInVerificationLimit()); } @Test public void testApprox24MonthAgo() throws IOException { - enterAssuranceWhen(agentID, applicantNameID, min24month); + enterVerificationWhen(agentID, applicantNameID, min24month); assertTrue(applicant.isInVerificationLimit()); } @Test public void testApprox39MonthAgo() throws IOException { - enterAssuranceWhen(agentID, applicantNameID, min39month); + enterVerificationWhen(agentID, applicantNameID, min39month); assertFalse(applicant.isInVerificationLimit()); } @Test public void testTomorrowExpired() throws IOException { - enterAssuranceExpired(agentID, applicantNameID, tomorrow); + enterVerificationExpired(agentID, applicantNameID, tomorrow); assertTrue(applicant.isInVerificationLimit()); } @Test public void testYesterdayExpired() throws IOException { - enterAssuranceExpired(agentID, applicantNameID, yesterday); + enterVerificationExpired(agentID, applicantNameID, yesterday); assertFalse(applicant.isInVerificationLimit()); } @Test public void testNormal() throws IOException { - enterAssurance(agentID, applicantNameID); + enterVerification(agentID, applicantNameID); assertTrue(applicant.isInVerificationLimit()); } @Test public void testDeletedYesterday() throws IOException { - enterAssuranceDeleted(agentID, applicantNameID, yesterday); + enterVerificationDeleted(agentID, applicantNameID, yesterday); assertFalse(applicant.isInVerificationLimit()); } @Test - public void testMultipleAssurancePossible() throws IOException { + public void testMultipleVerificationPossible() throws IOException { User agent = User.getById(agentID); User applicantMult = User.getById(applicantMultID); - enterAssuranceWhen(agentID, applicantMult.getPreferredName().getId(), min39month); + enterVerificationWhen(agentID, applicantMult.getPreferredName().getId(), min39month); // test that new entry would be possible - assertTrue(Notary.checkAssuranceIsPossible(agent, applicantMult.getPreferredName())); + assertTrue(Notary.checkVerificationIsPossible(agent, applicantMult.getPreferredName())); // enter new entry - enterAssuranceWhen(agentID, applicantMult.getPreferredName().getId(), yesterday); + enterVerificationWhen(agentID, applicantMult.getPreferredName().getId(), yesterday); // test that new entry is not possible - assertFalse(Notary.checkAssuranceIsPossible(agent, applicantMult.getPreferredName())); + assertFalse(Notary.checkVerificationIsPossible(agent, applicantMult.getPreferredName())); } @Test - public void testMultipleAssurancePointsCalculation() throws IOException { + public void testMultipleVerificationPointsCalculation() throws IOException { User agent = User.getById(agentID); User applicantMult = User.getById(applicantMultID); - enterAssuranceWhen(agentID, applicantMult.getPreferredName().getId(), min39month); + enterVerificationWhen(agentID, applicantMult.getPreferredName().getId(), min39month); int xPoints = agent.getExperiencePoints(); // test that VP after first entry - assertEquals(applicantMult.getAssurancePoints(), 10); + assertEquals(applicantMult.getVerificationPoints(), 10); // enter second entry to check correct calculation with larger points - enterAssuranceWhen(agentID, applicantMult.getPreferredName().getId(), min24month, 20); - assertEquals(applicantMult.getAssurancePoints(), 20); + enterVericationWhen(agentID, applicantMult.getPreferredName().getId(), min24month, 20); + assertEquals(applicantMult.getVerificationPoints(), 20); // test correct XP calculation assertEquals(agent.getExperiencePoints(), xPoints); // enter third entry to check correct calculation with less points - enterAssuranceWhen(agentID, applicantMult.getPreferredName().getId(), yesterday, 15); - assertEquals(applicantMult.getAssurancePoints(), 15); + enterVericationWhen(agentID, applicantMult.getPreferredName().getId(), yesterday, 15); + assertEquals(applicantMult.getVerificationPoints(), 15); // test correct XP calculation assertEquals(agent.getExperiencePoints(), xPoints); // enter expired entry - enterAssuranceExpired(agentID, applicantMult.getPreferredName().getId(), yesterday); - assertEquals(applicantMult.getAssurancePoints(), 15); + enterVerificationExpired(agentID, applicantMult.getPreferredName().getId(), yesterday); + assertEquals(applicantMult.getVerificationPoints(), 15); // enter deleted entry same agent - enterAssuranceDeleted(agentID, applicantMult.getPreferredName().getId(), yesterday); - assertEquals(applicantMult.getAssurancePoints(), 15); + enterVerificationDeleted(agentID, applicantMult.getPreferredName().getId(), yesterday); + assertEquals(applicantMult.getVerificationPoints(), 15); // enter expired entry future - enterAssuranceExpired(agentID, applicantMult.getPreferredName().getId(), tomorrow); - assertEquals(applicantMult.getAssurancePoints(), 10); + enterVerificationExpired(agentID, applicantMult.getPreferredName().getId(), tomorrow); + assertEquals(applicantMult.getVerificationPoints(), 10); // test correct XP calculation assertEquals(agent.getExperiencePoints(), xPoints); // enter entry from different agent - enterAssuranceWhen(agent2ID, applicantMult.getPreferredName().getId(), yesterday); - assertEquals(applicantMult.getAssurancePoints(), 20); + enterVerificationWhen(agent2ID, applicantMult.getPreferredName().getId(), yesterday); + assertEquals(applicantMult.getVerificationPoints(), 20); // enter entry for second applicant - enterAssuranceWhen(agentID, applicant.getPreferredName().getId(), yesterday); + enterVerificationWhen(agentID, applicant.getPreferredName().getId(), yesterday); assertEquals(agent.getExperiencePoints(), xPoints + User.EXPERIENCE_POINTS); } diff --git a/tests/club/wpia/gigi/dbObjects/TestAssuranceMail.java b/tests/club/wpia/gigi/dbObjects/TestVerificationMail.java similarity index 85% rename from tests/club/wpia/gigi/dbObjects/TestAssuranceMail.java rename to tests/club/wpia/gigi/dbObjects/TestVerificationMail.java index 5efc69e8..43efda4a 100644 --- a/tests/club/wpia/gigi/dbObjects/TestAssuranceMail.java +++ b/tests/club/wpia/gigi/dbObjects/TestVerificationMail.java @@ -13,14 +13,14 @@ import club.wpia.gigi.dbObjects.Country; import club.wpia.gigi.dbObjects.Name; import club.wpia.gigi.dbObjects.NamePart; import club.wpia.gigi.dbObjects.User; -import club.wpia.gigi.dbObjects.Assurance.AssuranceType; +import club.wpia.gigi.dbObjects.Verification.VerificationType; import club.wpia.gigi.dbObjects.Country.CountryCodeType; import club.wpia.gigi.dbObjects.NamePart.NamePartType; import club.wpia.gigi.testUtils.BusinessTest; import club.wpia.gigi.util.DayDate; import club.wpia.gigi.util.Notary; -public class TestAssuranceMail extends BusinessTest { +public class TestVerificationMail extends BusinessTest { private User agent; @@ -35,7 +35,7 @@ public class TestAssuranceMail extends BusinessTest { private String message; private void newAgent() throws GigiApiException { - agent = User.getById(createAssuranceUser("Marianne", "Mustermann", createUniqueName() + "@example.com", TEST_PASSWORD)); + agent = User.getById(createVerificationUser("Marianne", "Mustermann", createUniqueName() + "@example.com", TEST_PASSWORD)); } private void newApplicant() throws GigiApiException { @@ -51,7 +51,7 @@ public class TestAssuranceMail extends BusinessTest { int applicantId = createVerifiedUser("John", "Doe", applicantT, TEST_PASSWORD); User applicantXP = User.getById(applicantId); applicantXP = User.getById(applicantId); - Notary.assure(agentXP, applicantXP, applicantXP.getNames()[0], applicantXP.getDoB(), 10, "Test location", validVerificationDateString(), AssuranceType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); + Notary.verify(agentXP, applicantXP, applicantXP.getNames()[0], applicantXP.getDoB(), 10, "Test location", validVerificationDateString(), VerificationType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); } } @@ -60,7 +60,7 @@ public class TestAssuranceMail extends BusinessTest { } private void enterVerification(int points, Name... names) throws GigiApiException { - Notary.assureAll(agent, applicant, applicant.getDoB(), points, createUniqueName(), validVerificationDateString(), AssuranceType.FACE_TO_FACE, names, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); + Notary.verifyAll(agent, applicant, applicant.getDoB(), points, createUniqueName(), validVerificationDateString(), VerificationType.FACE_TO_FACE, names, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); } private void enterVerificationInPast(int points, Name name) { @@ -278,20 +278,20 @@ public class TestAssuranceMail extends BusinessTest { // verify with 35 VP newAgent(); - Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", validVerificationDateString(), AssuranceType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); - Notary.assure(agent, applicant, applicant.getNames()[1], applicant.getDoB(), 10, "Test location", validVerificationDateString(), AssuranceType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); + Notary.verify(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", validVerificationDateString(), VerificationType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); + Notary.verify(agent, applicant, applicant.getNames()[1], applicant.getDoB(), 10, "Test location", validVerificationDateString(), VerificationType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); newAgent(); - Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", validVerificationDateString(), AssuranceType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); - Notary.assure(agent, applicant, applicant.getNames()[1], applicant.getDoB(), 10, "Test location", validVerificationDateString(), AssuranceType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); + Notary.verify(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", validVerificationDateString(), VerificationType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); + Notary.verify(agent, applicant, applicant.getNames()[1], applicant.getDoB(), 10, "Test location", validVerificationDateString(), VerificationType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); newAgent(); - Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", validVerificationDateString(), AssuranceType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); - Notary.assure(agent, applicant, applicant.getNames()[1], applicant.getDoB(), 10, "Test location", validVerificationDateString(), AssuranceType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); + Notary.verify(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", validVerificationDateString(), VerificationType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); + Notary.verify(agent, applicant, applicant.getNames()[1], applicant.getDoB(), 10, "Test location", validVerificationDateString(), VerificationType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); newAgent(); - Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 5, "Test location", validVerificationDateString(), AssuranceType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); - Notary.assure(agent, applicant, applicant.getNames()[1], applicant.getDoB(), 5, "Test location", validVerificationDateString(), AssuranceType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); + Notary.verify(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 5, "Test location", validVerificationDateString(), VerificationType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); + Notary.verify(agent, applicant, applicant.getNames()[1], applicant.getDoB(), 5, "Test location", validVerificationDateString(), VerificationType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); // add first Verification in the past result first name 45 VP newAgent(); @@ -307,16 +307,16 @@ public class TestAssuranceMail extends BusinessTest { // verify first name to 85 VP newAgent(); - Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", validVerificationDateString(), AssuranceType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); + Notary.verify(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", validVerificationDateString(), VerificationType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); newAgent(); - Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", validVerificationDateString(), AssuranceType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); + Notary.verify(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", validVerificationDateString(), VerificationType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); newAgent(); - Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", validVerificationDateString(), AssuranceType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); + Notary.verify(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 10, "Test location", validVerificationDateString(), VerificationType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); newAgent(); - Notary.assure(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 5, "Test location", validVerificationDateString(), AssuranceType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); + Notary.verify(agent, applicant, applicant.getNames()[0], applicant.getDoB(), 5, "Test location", validVerificationDateString(), VerificationType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); // add first Verification in the past result first name 95 VP newAgent(); diff --git a/tests/club/wpia/gigi/dbObjects/TestVerifyName.java b/tests/club/wpia/gigi/dbObjects/TestVerifyName.java new file mode 100644 index 00000000..7f3af269 --- /dev/null +++ b/tests/club/wpia/gigi/dbObjects/TestVerifyName.java @@ -0,0 +1,38 @@ +package club.wpia.gigi.dbObjects; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import club.wpia.gigi.GigiApiException; +import club.wpia.gigi.dbObjects.Country; +import club.wpia.gigi.dbObjects.Name; +import club.wpia.gigi.dbObjects.NamePart; +import club.wpia.gigi.dbObjects.User; +import club.wpia.gigi.dbObjects.Verification.VerificationType; +import club.wpia.gigi.dbObjects.Country.CountryCodeType; +import club.wpia.gigi.dbObjects.NamePart.NamePartType; +import club.wpia.gigi.testUtils.ClientBusinessTest; +import club.wpia.gigi.util.Notary; + +public class TestVerifyName extends ClientBusinessTest { + + @Test + public void testIt() throws GigiApiException { + User u0 = User.getById(createVerificationUser("f", "l", createUniqueName() + "@email.com", TEST_PASSWORD)); + Name n2 = new Name(u, new NamePart(NamePartType.SINGLE_NAME, "Testiaa")); + Name n3 = new Name(u, new NamePart(NamePartType.SINGLE_NAME, "Testiaa")); + Name n4 = new Name(u, new NamePart(NamePartType.SINGLE_NAME, "Testiaac")); + + assertEquals(0, n0.getVerificationPoints()); + Notary.verify(u0, u, n0, u.getDoB(), 10, "test mgr", validVerificationDateString(), VerificationType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); + assertEquals(10, n0.getVerificationPoints()); + Notary.verify(u0, u, n2, u.getDoB(), 10, "test mgr", validVerificationDateString(), VerificationType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); + assertEquals(10, n2.getVerificationPoints()); + Notary.verify(u0, u, n3, u.getDoB(), 10, "test mgr", validVerificationDateString(), VerificationType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); + assertEquals(10, n3.getVerificationPoints()); + Notary.verify(u0, u, n4, u.getDoB(), 10, "test mgr", validVerificationDateString(), VerificationType.FACE_TO_FACE, Country.getCountryByCode("DE", CountryCodeType.CODE_2_CHARS)); + assertEquals(10, n4.getVerificationPoints()); + assertEquals(10, u.getMaxVerifyPoints()); + } +} diff --git a/tests/club/wpia/gigi/pages/account/TestCertificateRequest.java b/tests/club/wpia/gigi/pages/account/TestCertificateRequest.java index 52938183..79edd932 100644 --- a/tests/club/wpia/gigi/pages/account/TestCertificateRequest.java +++ b/tests/club/wpia/gigi/pages/account/TestCertificateRequest.java @@ -23,7 +23,7 @@ public class TestCertificateRequest extends ClientTest { public TestCertificateRequest() throws GeneralSecurityException, IOException, GigiApiException { ac = new AuthorizationContext(u, u); - makeAssurer(u.getId()); + makeAgent(u.getId()); } @Test diff --git a/tests/club/wpia/gigi/pages/account/TestPasswordResetExternal.java b/tests/club/wpia/gigi/pages/account/TestPasswordResetExternal.java index 872fc746..35c482d8 100644 --- a/tests/club/wpia/gigi/pages/account/TestPasswordResetExternal.java +++ b/tests/club/wpia/gigi/pages/account/TestPasswordResetExternal.java @@ -16,7 +16,7 @@ import org.junit.Test; import club.wpia.gigi.dbObjects.User; import club.wpia.gigi.pages.PasswordResetPage; -import club.wpia.gigi.pages.wot.TestAssurance; +import club.wpia.gigi.pages.wot.TestVerification; import club.wpia.gigi.testUtils.ClientTest; import club.wpia.gigi.testUtils.IOUtils; import club.wpia.gigi.testUtils.TestEmailReceiver.TestMail; @@ -25,12 +25,12 @@ import club.wpia.gigi.util.RandomToken; public class TestPasswordResetExternal extends ClientTest { @Test - public void testByAssurance() throws IOException { - User u = User.getById(createAssuranceUser("fn", "ln", createUniqueName() + "@example.com", TEST_PASSWORD)); + public void testByVerification() throws IOException { + User u = User.getById(createVerificationUser("fn", "ln", createUniqueName() + "@example.com", TEST_PASSWORD)); String cookie2 = login(u.getEmail(), TEST_PASSWORD); - URLConnection uc = TestAssurance.buildupAssureFormConnection(cookie2, email, true); + URLConnection uc = TestVerification.buildupVerifyFormConnection(cookie2, email, true); String avalue = RandomToken.generateToken(32); - uc.getOutputStream().write(("assuredName=" + this.u.getPreferredName().getId() + "&date=" + TestAssurance.validVerificationDateString() + "&location=testcase&countryCode=DE&certify=1&rules=1&assertion=1&points=10&passwordReset=1&passwordResetValue=" + URLEncoder.encode(avalue, "UTF-8")).getBytes("UTF-8")); + uc.getOutputStream().write(("verifiedName=" + this.u.getPreferredName().getId() + "&date=" + TestVerification.validVerificationDateString() + "&location=testcase&countryCode=DE&certify=1&rules=1&assertion=1&points=10&passwordReset=1&passwordResetValue=" + URLEncoder.encode(avalue, "UTF-8")).getBytes("UTF-8")); uc.getOutputStream().flush(); String error = fetchStartErrorMessage(IOUtils.readURL(uc)); assertNull(error); diff --git a/tests/club/wpia/gigi/pages/account/TestTrainings.java b/tests/club/wpia/gigi/pages/account/TestTrainings.java index 1c559574..f5b81797 100644 --- a/tests/club/wpia/gigi/pages/account/TestTrainings.java +++ b/tests/club/wpia/gigi/pages/account/TestTrainings.java @@ -22,11 +22,11 @@ public class TestTrainings extends ClientTest { @Test public void testShow() throws IOException, GeneralSecurityException { - CATS.enterResult(u, CATSType.ASSURER_CHALLENGE, new Date(System.currentTimeMillis()), "en_US", "1"); + CATS.enterResult(u, CATSType.AGENT_CHALLENGE, new Date(System.currentTimeMillis()), "en_US", "1"); CATS.enterResult(u, "Special Case Test", new Date(System.currentTimeMillis()), "spLan", "v23"); String res = IOUtils.readURL(get(UserTrainings.PATH)); assertThat(res, containsString("Special Case Test")); - assertThat(res, containsString(HTMLEncoder.encodeHTML(CATSType.ASSURER_CHALLENGE.getDisplayName()))); + assertThat(res, containsString(HTMLEncoder.encodeHTML(CATSType.AGENT_CHALLENGE.getDisplayName()))); assertThat(res, containsString("en_US, 1")); assertThat(res, containsString("v23")); assertThat(res, containsString("spLan")); diff --git a/tests/club/wpia/gigi/pages/admin/TestSEAdminPageDetails.java b/tests/club/wpia/gigi/pages/admin/TestSEAdminPageDetails.java index 5a458a28..909dd038 100644 --- a/tests/club/wpia/gigi/pages/admin/TestSEAdminPageDetails.java +++ b/tests/club/wpia/gigi/pages/admin/TestSEAdminPageDetails.java @@ -125,7 +125,7 @@ public class TestSEAdminPageDetails extends ClientTest { // enter verification and open mypoints as supporter - makeAssurer(this.id); + makeAgent(this.id); String location = createUniqueName(); try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?, `when`=? ")) { ps.setInt(1, this.id); diff --git a/tests/club/wpia/gigi/pages/orga/TestOrgManagement.java b/tests/club/wpia/gigi/pages/orga/TestOrgManagement.java index a6cd5754..8837abc6 100644 --- a/tests/club/wpia/gigi/pages/orga/TestOrgManagement.java +++ b/tests/club/wpia/gigi/pages/orga/TestOrgManagement.java @@ -53,7 +53,7 @@ public class TestOrgManagement extends OrgTest { assertEquals("opname", orgs[0].getOptionalName()); assertEquals("postaladdress", orgs[0].getPostalAddress()); - User u2 = User.getById(createAssuranceUser("testworker", "testname", createUniqueName() + "@testdom.com", TEST_PASSWORD)); + User u2 = User.getById(createVerificationUser("testworker", "testname", createUniqueName() + "@testdom.com", TEST_PASSWORD)); assertNull(executeBasicWebInteraction(cookie, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "email=" + URLEncoder.encode(u2.getEmail(), "UTF-8") + "&do_affiliate=y&master=y", 1)); List allAdmins = orgs[0].getAllAdmins(); assertEquals(1, allAdmins.size()); @@ -84,8 +84,8 @@ public class TestOrgManagement extends OrgTest { } @Test - public void testNonAssurerSeeOnlyOwn() throws IOException, GigiApiException { - User u2 = User.getById(createAssuranceUser("testworker", "testname", createUniqueName() + "@testdom.com", TEST_PASSWORD)); + public void testNonAgentSeeOnlyOwn() throws IOException, GigiApiException { + User u2 = User.getById(createVerificationUser("testworker", "testname", createUniqueName() + "@testdom.com", TEST_PASSWORD)); Organisation o1 = createUniqueOrg(); Organisation o2 = createUniqueOrg(); o1.addAdmin(u2, u, false); @@ -117,8 +117,8 @@ public class TestOrgManagement extends OrgTest { @Test public void testAffiliationRights() throws IOException, GigiApiException { - User u2 = User.getById(createAssuranceUser("testworker", "testname", createUniqueName() + "@testdom.com", TEST_PASSWORD)); - User u3 = User.getById(createAssuranceUser("testmaster", "testname", createUniqueName() + "@testdom.com", TEST_PASSWORD)); + User u2 = User.getById(createVerificationUser("testworker", "testname", createUniqueName() + "@testdom.com", TEST_PASSWORD)); + User u3 = User.getById(createVerificationUser("testmaster", "testname", createUniqueName() + "@testdom.com", TEST_PASSWORD)); User u4_dummy = User.getById(createVerifiedUser("testmaster", "testname", createUniqueName() + "@testdom.com", TEST_PASSWORD)); Organisation o1 = createUniqueOrg(); o1.addAdmin(u3, u, true); diff --git a/tests/club/wpia/gigi/pages/wot/TestTTP.java b/tests/club/wpia/gigi/pages/wot/TestTTP.java index c0a966fc..b694db76 100644 --- a/tests/club/wpia/gigi/pages/wot/TestTTP.java +++ b/tests/club/wpia/gigi/pages/wot/TestTTP.java @@ -34,7 +34,7 @@ public class TestTTP extends ClientTest { @Test public void testTTPEnoughPoints() throws IOException, GigiApiException { - User u = User.getById(createAssuranceUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD)); + User u = User.getById(createVerificationUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD)); cookie = login(u.getEmail(), TEST_PASSWORD); String ttp = IOUtils.readURL(get(RequestTTPPage.PATH)); diff --git a/tests/club/wpia/gigi/pages/wot/TestAssurance.java b/tests/club/wpia/gigi/pages/wot/TestVerification.java similarity index 67% rename from tests/club/wpia/gigi/pages/wot/TestAssurance.java rename to tests/club/wpia/gigi/pages/wot/TestVerification.java index 20ebe100..ef37f598 100644 --- a/tests/club/wpia/gigi/pages/wot/TestAssurance.java +++ b/tests/club/wpia/gigi/pages/wot/TestVerification.java @@ -26,71 +26,69 @@ import club.wpia.gigi.dbObjects.Country; import club.wpia.gigi.dbObjects.Group; import club.wpia.gigi.dbObjects.User; import club.wpia.gigi.pages.account.MyDetails; -import club.wpia.gigi.pages.wot.AssurePage; -import club.wpia.gigi.pages.wot.Points; import club.wpia.gigi.testUtils.IOUtils; import club.wpia.gigi.testUtils.ManagedTest; import club.wpia.gigi.testUtils.TestEmailReceiver.TestMail; import club.wpia.gigi.util.DayDate; import club.wpia.gigi.util.Notary; -public class TestAssurance extends ManagedTest { +public class TestVerification extends ManagedTest { - private String assurerM; + private String agentM; - private String assureeM; + private String applicantM; - private int assureeName; + private int applicantName; private String cookie; @Before public void setup() throws IOException { clearCaches(); - assurerM = createUniqueName() + "@example.org"; - assureeM = createUniqueName() + "@example.org"; + agentM = createUniqueName() + "@example.org"; + applicantM = createUniqueName() + "@example.org"; - createAssuranceUser("a", "b", assurerM, TEST_PASSWORD); - int assureeId = createVerifiedUser("a", "c", assureeM, TEST_PASSWORD); - assureeName = User.getById(assureeId).getPreferredName().getId(); + createVerificationUser("a", "b", agentM, TEST_PASSWORD); + int applicantId = createVerifiedUser("a", "c", applicantM, TEST_PASSWORD); + applicantName = User.getById(applicantId).getPreferredName().getId(); - cookie = login(assurerM, TEST_PASSWORD); + cookie = login(agentM, TEST_PASSWORD); } - private Matcher isAssuranceForm() { - return containsString(""); } @Test - public void testAssureSearch() throws IOException { - String loc = search("email=" + URLEncoder.encode(assureeM, "UTF-8") + "&day=1&month=1&year=1910"); - assertThat(loc, isAssuranceForm()); + public void testVerifySearch() throws IOException { + String loc = search("email=" + URLEncoder.encode(applicantM, "UTF-8") + "&day=1&month=1&year=1910"); + assertThat(loc, isVerificationForm()); } @Test - public void testAssureSearchEmail() throws IOException { - String loc = search("email=1" + URLEncoder.encode(assureeM, "UTF-8") + "&day=1&month=1&year=1910"); - assertThat(loc, not(isAssuranceForm())); + public void testVerifySearchEmail() throws IOException { + String loc = search("email=1" + URLEncoder.encode(applicantM, "UTF-8") + "&day=1&month=1&year=1910"); + assertThat(loc, not(isVerificationForm())); } @Test - public void testAssureSearchDobInvalid() throws IOException { - String loc = search("email=" + URLEncoder.encode(assureeM, "UTF-8") + "&day=1&month=1&year=mal"); - assertThat(loc, not(isAssuranceForm())); + public void testVerifySearchDobInvalid() throws IOException { + String loc = search("email=" + URLEncoder.encode(applicantM, "UTF-8") + "&day=1&month=1&year=mal"); + assertThat(loc, not(isVerificationForm())); } @Test - public void testAssureSearchDob() throws IOException { - String loc = search("email=" + URLEncoder.encode(assureeM, "UTF-8") + "&day=2&month=1&year=1910"); - assertThat(loc, not(isAssuranceForm())); - loc = search("email=" + URLEncoder.encode(assureeM, "UTF-8") + "&day=1&month=2&year=1910"); - assertThat(loc, not(isAssuranceForm())); - loc = search("email=" + URLEncoder.encode(assureeM, "UTF-8") + "&day=1&month=1&year=1911"); - assertThat(loc, not(isAssuranceForm())); + public void testVerifySearchDob() throws IOException { + String loc = search("email=" + URLEncoder.encode(applicantM, "UTF-8") + "&day=2&month=1&year=1910"); + assertThat(loc, not(isVerificationForm())); + loc = search("email=" + URLEncoder.encode(applicantM, "UTF-8") + "&day=1&month=2&year=1910"); + assertThat(loc, not(isVerificationForm())); + loc = search("email=" + URLEncoder.encode(applicantM, "UTF-8") + "&day=1&month=1&year=1911"); + assertThat(loc, not(isVerificationForm())); } private String search(String query) throws MalformedURLException, IOException, UnsupportedEncodingException { - URLConnection uc = get(cookie, AssurePage.PATH); + URLConnection uc = get(cookie, VerifyPage.PATH); uc.setDoOutput(true); uc.getOutputStream().write(("search&" + query).getBytes("UTF-8")); uc.getOutputStream().flush(); @@ -99,13 +97,13 @@ public class TestAssurance extends ManagedTest { } @Test - public void testAssureForm() throws IOException { + public void testVerifyForm() throws IOException { executeSuccess("date=" + validVerificationDateString() + "&location=testcase&countryCode=DE&certify=1&rules=1&assertion=1&points=10"); } @Test - public void testAssureFormEmpty() throws IOException { - URLConnection uc = buildupAssureFormConnection(true); + public void testVerifyFormEmpty() throws IOException { + URLConnection uc = buildupVerifyFormConnection(true); uc.getOutputStream().write(("date=" + validVerificationDateString() + "&location=testcase&countryCode=DE&rules=1&assertion=1&points=10").getBytes("UTF-8")); uc.getOutputStream().flush(); String data = IOUtils.readURL(uc); @@ -113,9 +111,9 @@ public class TestAssurance extends ManagedTest { } @Test - public void testAssureFormContanisData() throws IOException { - URLConnection uc = buildupAssureFormConnection(true); - uc.getOutputStream().write(("assuredName=" + assureeName + "&date=" + validVerificationDateString() + "&location=testcase&countryCode=DE&rules=1&assertion=1&points=10").getBytes("UTF-8")); + public void testVerifyFormContainsData() throws IOException { + URLConnection uc = buildupVerifyFormConnection(true); + uc.getOutputStream().write(("verifiedName=" + applicantName + "&date=" + validVerificationDateString() + "&location=testcase&countryCode=DE&rules=1&assertion=1&points=10").getBytes("UTF-8")); uc.getOutputStream().flush(); String data = IOUtils.readURL(uc); assertThat(data, containsString(validVerificationDateString())); @@ -123,42 +121,42 @@ public class TestAssurance extends ManagedTest { } @Test - public void testAssureFormNoCSRF() throws IOException { + public void testVerifyFormNoCSRF() throws IOException { // override csrf - HttpURLConnection uc = (HttpURLConnection) buildupAssureFormConnection(false); + HttpURLConnection uc = (HttpURLConnection) buildupVerifyFormConnection(false); uc.getOutputStream().write(("date=" + validVerificationDateString() + "&location=testcase&countryCode=DE&certify=1&rules=1&assertion=1&points=10").getBytes("UTF-8")); uc.getOutputStream().flush(); assertEquals(500, uc.getResponseCode()); } @Test - public void testAssureFormWrongCSRF() throws IOException { + public void testVerifyFormWrongCSRF() throws IOException { // override csrf - HttpURLConnection uc = (HttpURLConnection) buildupAssureFormConnection(false); + HttpURLConnection uc = (HttpURLConnection) buildupVerifyFormConnection(false); uc.getOutputStream().write(("date=" + validVerificationDateString() + "&location=testcase&countryCode=DE&certify=1&rules=1&assertion=1&points=10&csrf=aragc").getBytes("UTF-8")); uc.getOutputStream().flush(); assertEquals(500, uc.getResponseCode()); } @Test - public void testAssureFormRaceDoB() throws IOException, SQLException { - testAssureFormRace(false); + public void testVerifyFormRaceDoB() throws IOException, SQLException { + testVerifyFormRace(false); } @Test - public void testAssureFormRaceDoBBlind() throws IOException, SQLException { - testAssureFormRace(true); + public void testVerifyFormRaceDoBBlind() throws IOException, SQLException { + testVerifyFormRace(true); } - public void testAssureFormRace(boolean succeed) throws IOException, SQLException { - URLConnection uc = buildupAssureFormConnection(true); + public void testVerifyFormRace(boolean succeed) throws IOException, SQLException { + URLConnection uc = buildupVerifyFormConnection(true); - String assureeCookie = login(assureeM, TEST_PASSWORD); + String applicantCookie = login(applicantM, TEST_PASSWORD); String newDob = "day=1&month=1&year=" + ( !succeed ? 1911 : 1910); - assertNull(executeBasicWebInteraction(assureeCookie, MyDetails.PATH, newDob + "&action=updateDoB", 0)); + assertNull(executeBasicWebInteraction(applicantCookie, MyDetails.PATH, newDob + "&action=updateDoB", 0)); - uc.getOutputStream().write(("assuredName=" + assureeName + "&date=" + validVerificationDateString() + "&location=testcase&countryCode=DE&certify=1&rules=1&assertion=1&points=10").getBytes("UTF-8")); + uc.getOutputStream().write(("verifiedName=" + applicantName + "&date=" + validVerificationDateString() + "&location=testcase&countryCode=DE&certify=1&rules=1&assertion=1&points=10").getBytes("UTF-8")); uc.getOutputStream().flush(); String error = fetchStartErrorMessage(IOUtils.readURL(uc)); if (succeed) { @@ -170,14 +168,14 @@ public class TestAssurance extends ManagedTest { } @Test - public void testAssureFormFuture() throws IOException { + public void testVerifyFormFuture() throws IOException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); int year = Integer.parseInt(sdf.format(new Date(System.currentTimeMillis()))) + 2; executeFails("date=" + year + "-01-01&location=testcase&countryCode=DE&certify=1&rules=1&assertion=1&points=10"); } @Test - public void testAssureFormFutureOK() throws IOException { + public void testVerifyFormFutureOK() throws IOException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar c = Calendar.getInstance(); c.setTimeInMillis(System.currentTimeMillis()); @@ -187,12 +185,12 @@ public class TestAssurance extends ManagedTest { } @Test - public void testAssureFormPastInRange() throws IOException { + public void testVerifyFormPastInRange() throws IOException { executeSuccess("date=" + validVerificationDateString() + "&location=testcase&countryCode=DE&certify=1&rules=1&assertion=1&points=10"); } @Test - public void testAssureFormPastOnLimit() throws IOException { + public void testVerifyFormPastOnLimit() throws IOException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar c = Calendar.getInstance(); c.setTimeInMillis(System.currentTimeMillis()); @@ -203,7 +201,7 @@ public class TestAssurance extends ManagedTest { } @Test - public void testAssureFormPastOutOfRange() throws IOException { + public void testVerifyFormPastOutOfRange() throws IOException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar c = Calendar.getInstance(); c.setTimeInMillis(System.currentTimeMillis()); @@ -213,30 +211,30 @@ public class TestAssurance extends ManagedTest { } @Test - public void testAssureFormNoLoc() throws IOException { + public void testVerifyFormNoLoc() throws IOException { executeFails("date=" + validVerificationDateString() + "&location=a&countryCode=DE&certify=1&rules=1&assertion=1&points=10"); executeFails("date=" + validVerificationDateString() + "&location=&countryCode=DE&certify=1&rules=1&assertion=1&points=10"); } @Test - public void testAssureFormInvalDate() throws IOException { + public void testVerifyFormInvalDate() throws IOException { executeFails("date=20000101&location=testcase&countryCode=DE&certify=1&rules=1&assertion=1&points=10"); executeFails("date=&location=testcase&countryCode=DE&certify=1&rules=1&assertion=1&points=10"); } @Test - public void testAssureFormBoxes() throws IOException { + public void testVerifyFormBoxes() throws IOException { executeFails("date=" + validVerificationDateString() + "&location=testcase&countryCode=DE&certify=0&rules=1&assertion=1&points=10"); executeFails("date=" + validVerificationDateString() + "&location=testcase&countryCode=DE&certify=1&rules=&assertion=1&points=10"); executeFails("date=" + validVerificationDateString() + "&location=testcase&countryCode=DE&certify=1&rules=1&assertion=z&points=10"); } @Test - public void testAssureListingValid() throws IOException, GigiApiException { + public void testVerifyListingValid() throws IOException, GigiApiException { String uniqueLoc = createUniqueName(); execute("date=" + validVerificationDateString() + "&location=" + uniqueLoc + "&countryCode=DE&certify=1&rules=1&assertion=1&points=10"); - String cookie = login(assureeM, TEST_PASSWORD); + String cookie = login(applicantM, TEST_PASSWORD); URLConnection url = get(cookie, Points.PATH); String resp = IOUtils.readURL(url); resp = resp.split(Pattern.quote(""))[1]; @@ -245,10 +243,10 @@ public class TestAssurance extends ManagedTest { } @Test - public void testAssurerListingValid() throws IOException, GigiApiException { + public void testAgentListingValid() throws IOException, GigiApiException { String uniqueLoc = createUniqueName(); executeSuccess("date=" + validVerificationDateString() + "&location=" + uniqueLoc + "&countryCode=DE&certify=1&rules=1&assertion=1&points=10"); - String cookie = login(assurerM, TEST_PASSWORD); + String cookie = login(agentM, TEST_PASSWORD); URLConnection url = get(cookie, Points.PATH); String resp = IOUtils.readURL(url); resp = resp.split(Pattern.quote(""))[2]; @@ -267,23 +265,23 @@ public class TestAssurance extends ManagedTest { } private String execute(String query) throws MalformedURLException, IOException { - URLConnection uc = buildupAssureFormConnection(true); - uc.getOutputStream().write(("assuredName=" + assureeName + "&" + query).getBytes("UTF-8")); + URLConnection uc = buildupVerifyFormConnection(true); + uc.getOutputStream().write(("verifiedName=" + applicantName + "&" + query).getBytes("UTF-8")); uc.getOutputStream().flush(); return IOUtils.readURL(uc); } - private URLConnection buildupAssureFormConnection(boolean doCSRF) throws MalformedURLException, IOException { - return buildupAssureFormConnection(cookie, assureeM, doCSRF); + private URLConnection buildupVerifyFormConnection(boolean doCSRF) throws MalformedURLException, IOException { + return buildupVerifyFormConnection(cookie, applicantM, doCSRF); } - public static URLConnection buildupAssureFormConnection(String cookie, String email, boolean doCSRF) throws MalformedURLException, IOException { - URLConnection uc = get(cookie, AssurePage.PATH); + public static URLConnection buildupVerifyFormConnection(String cookie, String email, boolean doCSRF) throws MalformedURLException, IOException { + URLConnection uc = get(cookie, VerifyPage.PATH); uc.setDoOutput(true); uc.getOutputStream().write(("email=" + URLEncoder.encode(email, "UTF-8") + "&day=1&month=1&year=1910&search").getBytes("UTF-8")); String csrf = getCSRF(uc); - uc = get(cookie, AssurePage.PATH); + uc = get(cookie, VerifyPage.PATH); uc.setDoOutput(true); if (doCSRF) { uc.getOutputStream().write(("csrf=" + csrf + "&").getBytes("UTF-8")); @@ -292,12 +290,12 @@ public class TestAssurance extends ManagedTest { } @Test - public void testMultipleAssurance() throws IOException { + public void testMultipleVerification() throws IOException { - User users[] = User.findByEmail(assurerM); + User users[] = User.findByEmail(agentM); int agentID = users[0].getId(); - users = User.findByEmail(assureeM); + users = User.findByEmail(applicantM); int applicantID = users[0].getId(); // enter first entry 200 days in the past @@ -316,15 +314,15 @@ public class TestAssurance extends ManagedTest { executeSuccess("date=" + validVerificationDateString() + "&location=" + uniqueLoc + "&countryCode=DE&certify=1&rules=1&assertion=1&points=10"); // enter third entry on the same day - URLConnection uc = get(cookie, AssurePage.PATH); + URLConnection uc = get(cookie, VerifyPage.PATH); 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(applicantM, "UTF-8") + "&day=1&month=1&year=1910&search").getBytes("UTF-8")); assertThat(IOUtils.readURL(uc), hasError()); } @Test - public void testAssureFormNoCountry() throws IOException { + public void testVerifyFormNoCountry() throws IOException { executeFails("date=" + validVerificationDateString() + "&location=testcase&countryCode=&certify=1&rules=1&assertion=1&points=10"); } @@ -332,13 +330,13 @@ public class TestAssurance extends ManagedTest { public void testRANotificationSet() throws IOException, GigiApiException { getMailReceiver().clearMails(); - User users[] = User.findByEmail(assurerM); + User users[] = User.findByEmail(agentM); assertTrue("user RA Agent not found", users != null && users.length > 0); User u = users[0]; u.grantGroup(u, Group.VERIFY_NOTIFICATION); clearCaches(); - cookie = login(assurerM, TEST_PASSWORD); + cookie = login(agentM, TEST_PASSWORD); String targetMail = u.getEmail(); @@ -350,7 +348,7 @@ public class TestAssurance extends ManagedTest { do { tm = getMailReceiver().receive(); } while ( !tm.getTo().equals(targetMail)); - assertThat(tm.getMessage(), containsString("You entered a verification for the account with email address " + assureeM)); + assertThat(tm.getMessage(), containsString("You entered a verification for the account with email address " + applicantM)); } @@ -358,13 +356,13 @@ public class TestAssurance extends ManagedTest { public void testRANotificationNotSet() throws IOException, GigiApiException { getMailReceiver().clearMails(); - User users[] = User.findByEmail(assurerM); + User users[] = User.findByEmail(agentM); assertTrue("user RA Agent not found", users != null && users.length > 0); User u = users[0]; u.revokeGroup(u, Group.VERIFY_NOTIFICATION); clearCaches(); - cookie = login(assurerM, TEST_PASSWORD); + cookie = login(agentM, TEST_PASSWORD); // enter verification String uniqueLoc = createUniqueName(); @@ -373,7 +371,7 @@ public class TestAssurance extends ManagedTest { TestMail tm; tm = getMailReceiver().receive(); - assertThat(tm.getMessage(), not(containsString("You entered a verification for the account with email address " + assureeM))); + assertThat(tm.getMessage(), not(containsString("You entered a verification for the account with email address " + applicantM))); } } diff --git a/tests/club/wpia/gigi/testUtils/BusinessTest.java b/tests/club/wpia/gigi/testUtils/BusinessTest.java index d62713a6..31d3b094 100644 --- a/tests/club/wpia/gigi/testUtils/BusinessTest.java +++ b/tests/club/wpia/gigi/testUtils/BusinessTest.java @@ -148,9 +148,9 @@ public abstract class BusinessTest extends ConfiguredTest { return u; } - public static int createAssuranceUser(String f, String l, String mail, String pw) throws GigiApiException { + public static int createVerificationUser(String f, String l, String mail, String pw) throws GigiApiException { int u = createVerifiedUser(f, l, mail, pw); - makeAssurer(u); + makeAgent(u); return u; } diff --git a/tests/club/wpia/gigi/testUtils/ConfiguredTest.java b/tests/club/wpia/gigi/testUtils/ConfiguredTest.java index bf50d611..e4c41b67 100644 --- a/tests/club/wpia/gigi/testUtils/ConfiguredTest.java +++ b/tests/club/wpia/gigi/testUtils/ConfiguredTest.java @@ -209,10 +209,10 @@ public abstract class ConfiguredTest { return i; } - public static void makeAssurer(int uid) { + public static void makeAgent(int uid) { try (GigiPreparedStatement ps1 = new GigiPreparedStatement("INSERT INTO cats_passed SET user_id=?, variant_id=?, language='en_EN', version='1'")) { ps1.setInt(1, uid); - ps1.setInt(2, CATSType.ASSURER_CHALLENGE.getId()); + ps1.setInt(2, CATSType.AGENT_CHALLENGE.getId()); ps1.execute(); } diff --git a/tests/club/wpia/gigi/testUtils/ManagedTest.java b/tests/club/wpia/gigi/testUtils/ManagedTest.java index 25749221..f4ad8522 100644 --- a/tests/club/wpia/gigi/testUtils/ManagedTest.java +++ b/tests/club/wpia/gigi/testUtils/ManagedTest.java @@ -315,10 +315,10 @@ public class ManagedTest extends ConfiguredTest { * the password * @return a new userid. */ - public static int createAssuranceUser(String firstName, String lastName, String email, String password) { + public static int createVerificationUser(String firstName, String lastName, String email, String password) { int uid = createVerifiedUser(firstName, lastName, email, password); - makeAssurer(uid); + makeAgent(uid); return uid; } diff --git a/tests/club/wpia/gigi/testUtils/OrgTest.java b/tests/club/wpia/gigi/testUtils/OrgTest.java index e7360fe2..949bd2d1 100644 --- a/tests/club/wpia/gigi/testUtils/OrgTest.java +++ b/tests/club/wpia/gigi/testUtils/OrgTest.java @@ -11,7 +11,7 @@ import club.wpia.gigi.dbObjects.Country.CountryCodeType; public class OrgTest extends ClientTest { public OrgTest() throws IOException, GigiApiException { - makeAssurer(u.getId()); + makeAgent(u.getId()); u.grantGroup(getSupporter(), Group.ORGASSURER); clearCaches(); cookie = login(email, TEST_PASSWORD); diff --git a/tests/club/wpia/gigi/testUtils/RestrictedApiTest.java b/tests/club/wpia/gigi/testUtils/RestrictedApiTest.java index a96414fa..3a0f4515 100644 --- a/tests/club/wpia/gigi/testUtils/RestrictedApiTest.java +++ b/tests/club/wpia/gigi/testUtils/RestrictedApiTest.java @@ -35,14 +35,14 @@ public class RestrictedApiTest extends ClientTest { protected static Organisation selfOrg; public RestrictedApiTest() { - makeAssurer(id); + makeAgent(id); } @BeforeClass public static void initCert() { initEnvironment(); try { - User u = User.getById(createAssuranceUser("f", "l", createUniqueName() + "@email.com", TEST_PASSWORD)); + User u = User.getById(createVerificationUser("f", "l", createUniqueName() + "@email.com", TEST_PASSWORD)); grant(u, Group.ORGASSURER); clearCaches(); u = User.getById(u.getId()); diff --git a/tests/club/wpia/gigi/util/TestNotary.java b/tests/club/wpia/gigi/util/TestNotary.java index 6733dd63..45217fd8 100644 --- a/tests/club/wpia/gigi/util/TestNotary.java +++ b/tests/club/wpia/gigi/util/TestNotary.java @@ -11,19 +11,18 @@ import org.junit.Test; import club.wpia.gigi.GigiApiException; import club.wpia.gigi.database.GigiPreparedStatement; import club.wpia.gigi.dbObjects.CATS; +import club.wpia.gigi.dbObjects.CATS.CATSType; import club.wpia.gigi.dbObjects.Country; +import club.wpia.gigi.dbObjects.Country.CountryCodeType; import club.wpia.gigi.dbObjects.Group; import club.wpia.gigi.dbObjects.Name; import club.wpia.gigi.dbObjects.NamePart; +import club.wpia.gigi.dbObjects.NamePart.NamePartType; import club.wpia.gigi.dbObjects.ObjectCache; import club.wpia.gigi.dbObjects.User; -import club.wpia.gigi.dbObjects.Assurance.AssuranceType; -import club.wpia.gigi.dbObjects.CATS.CATSType; -import club.wpia.gigi.dbObjects.Country.CountryCodeType; -import club.wpia.gigi.dbObjects.NamePart.NamePartType; +import club.wpia.gigi.dbObjects.Verification.VerificationType; import club.wpia.gigi.output.DateSelector; import club.wpia.gigi.testUtils.BusinessTest; -import club.wpia.gigi.util.Notary; public class TestNotary extends BusinessTest { @@ -32,40 +31,40 @@ public class TestNotary extends BusinessTest { public TestNotary() throws GigiApiException {} @Test - public void testNormalAssurance() throws SQLException, GigiApiException { + public void testNormalVerification() throws SQLException, GigiApiException { User[] users = new User[30]; for (int i = 0; i < users.length; i++) { int id = createVerifiedUser("fn" + i, "ln" + i, createUniqueName() + "@email.org", TEST_PASSWORD); users[i] = User.getById(id); } - User assurer = User.getById(createAssuranceUser("fn", "ln", createUniqueName() + "@email.org", TEST_PASSWORD)); + User agent = User.getById(createVerificationUser("fn", "ln", createUniqueName() + "@email.org", TEST_PASSWORD)); int[] result = new int[] { 10, 10, 10, 10, 15, 15, 15, 15, 15, 20, 20, 20, 20, 20, 25, 25, 25, 25, 25, 30, 30, 30, 30, 30, 35, 35, 35, 35, 35, 35 }; try { - Notary.assure(assurer, users[0], users[0].getPreferredName(), users[0].getDoB(), -1, "test-notary", validVerificationDateString(), AssuranceType.FACE_TO_FACE, DE); + Notary.verify(agent, users[0], users[0].getPreferredName(), users[0].getDoB(), -1, "test-notary", validVerificationDateString(), VerificationType.FACE_TO_FACE, DE); fail("This shouldn't have passed"); } catch (GigiApiException e) { // expected } for (int i = 0; i < result.length; i++) { - assertEquals(result[i], assurer.getMaxAssurePoints()); + assertEquals(result[i], agent.getMaxVerifyPoints()); - assuranceFail(assurer, users[i], result[i] + 1, "test-notary", validVerificationDateString()); - Notary.assure(assurer, users[i], users[i].getPreferredName(), users[i].getDoB(), result[i], "test-notary", validVerificationDateString(), AssuranceType.FACE_TO_FACE, DE); - assuranceFail(assurer, users[i], result[i], "test-notary", validVerificationDateString()); + verificationFail(agent, users[i], result[i] + 1, "test-notary", validVerificationDateString()); + Notary.verify(agent, users[i], users[i].getPreferredName(), users[i].getDoB(), result[i], "test-notary", validVerificationDateString(), VerificationType.FACE_TO_FACE, DE); + verificationFail(agent, users[i], result[i], "test-notary", validVerificationDateString()); } - assertEquals(35, assurer.getMaxAssurePoints()); + assertEquals(35, agent.getMaxVerifyPoints()); - assertEquals(User.EXPERIENCE_POINTS + (30 * User.EXPERIENCE_POINTS), assurer.getExperiencePoints()); + assertEquals(User.EXPERIENCE_POINTS + (30 * User.EXPERIENCE_POINTS), agent.getExperiencePoints()); } - private void assuranceFail(User assurer, User user, int i, String location, String date) throws SQLException { + private void verificationFail(User agent, User applicant, int i, String location, String date) throws SQLException { try { - Notary.assure(assurer, user, user.getPreferredName(), user.getDoB(), i, location, date, AssuranceType.FACE_TO_FACE, DE); + Notary.verify(agent, applicant, applicant.getPreferredName(), applicant.getDoB(), i, location, date, VerificationType.FACE_TO_FACE, DE); fail("This shouldn't have passed"); } catch (GigiApiException e) { // expected @@ -79,95 +78,95 @@ public class TestNotary extends BusinessTest { int id = createVerifiedUser("fn" + i, "ln" + i, createUniqueName() + "@email.org", TEST_PASSWORD); users[i] = User.getById(id); } - int id = createAssuranceUser("fn", "ln", createUniqueName() + "@email.org", TEST_PASSWORD); + int id = createVerificationUser("fn", "ln", createUniqueName() + "@email.org", TEST_PASSWORD); try (GigiPreparedStatement ps = new GigiPreparedStatement("UPDATE `users` SET dob=NOW() - interval '15 years' WHERE id=?")) { ps.setInt(1, id); ps.execute(); } ObjectCache.clearAllCaches(); // reload values from db - User assurer = User.getById(id); + User agent = User.getById(id); for (int i = 0; i < users.length; i++) { - assuranceFail(assurer, users[i], -1, "test-notary", validVerificationDateString()); - assuranceFail(assurer, users[i], 11, "test-notary", validVerificationDateString()); + verificationFail(agent, users[i], -1, "test-notary", validVerificationDateString()); + verificationFail(agent, users[i], 11, "test-notary", validVerificationDateString()); if (User.POJAM_ENABLED) { - Notary.assure(assurer, users[i], users[i].getPreferredName(), users[i].getDoB(), 10, "test-notary", validVerificationDateString(), AssuranceType.FACE_TO_FACE, DE); + Notary.verify(agent, users[i], users[i].getPreferredName(), users[i].getDoB(), 10, "test-notary", validVerificationDateString(), VerificationType.FACE_TO_FACE, DE); } - assuranceFail(assurer, users[i], 10, "test-notary", validVerificationDateString()); + verificationFail(agent, users[i], 10, "test-notary", validVerificationDateString()); } } @Test public void testFail() throws SQLException, GigiApiException { - User assuranceUser = User.getById(createAssuranceUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD)); - User assuree = User.getById(createVerifiedUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD)); + User agent = User.getById(createVerificationUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD)); + User applicant = User.getById(createVerifiedUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD)); // invalid date format - assuranceFail(assuranceUser, assuree, 10, "notary-junit-test", "2014-01-blah"); + verificationFail(agent, applicant, 10, "notary-junit-test", "2014-01-blah"); // empty date - assuranceFail(assuranceUser, assuree, 10, "notary-junit-test", ""); + verificationFail(agent, applicant, 10, "notary-junit-test", ""); // null date - assuranceFail(assuranceUser, assuree, 10, "notary-junit-test", null); + verificationFail(agent, applicant, 10, "notary-junit-test", null); // null location - assuranceFail(assuranceUser, assuree, 10, null, validVerificationDateString()); + verificationFail(agent, applicant, 10, null, validVerificationDateString()); // empty location - assuranceFail(assuranceUser, assuree, 10, "", validVerificationDateString()); + verificationFail(agent, applicant, 10, "", validVerificationDateString()); // date in the future - assuranceFail(assuranceUser, assuree, 10, "notary-junit-test", DateSelector.getDateFormat().format(new Date(System.currentTimeMillis() + 2 * 24 * 60 * 60 * 1000))); + verificationFail(agent, applicant, 10, "notary-junit-test", DateSelector.getDateFormat().format(new Date(System.currentTimeMillis() + 2 * 24 * 60 * 60 * 1000))); // location too short - assuranceFail(assuranceUser, assuree, 10, "n", validVerificationDateString()); + verificationFail(agent, applicant, 10, "n", validVerificationDateString()); // points too low - assuranceFail(assuranceUser, assuree, -1, "notary-junit-test", validVerificationDateString()); + verificationFail(agent, applicant, -1, "notary-junit-test", validVerificationDateString()); // points too high - assuranceFail(assuranceUser, assuree, 11, "notary-junit-test", validVerificationDateString()); + verificationFail(agent, applicant, 11, "notary-junit-test", validVerificationDateString()); // verify oneself - assuranceFail(assuranceUser, assuranceUser, 10, "notary-junit-test", validVerificationDateString()); - // not an assurer - assuranceFail(assuree, assuranceUser, 10, "notary-junit-test", validVerificationDateString()); + verificationFail(agent, agent, 10, "notary-junit-test", validVerificationDateString()); + // not an agent + verificationFail(applicant, agent, 10, "notary-junit-test", validVerificationDateString()); // valid - Notary.assure(assuranceUser, assuree, assuree.getPreferredName(), assuree.getDoB(), 10, "notary-junit-test", validVerificationDateString(), AssuranceType.FACE_TO_FACE, DE); + Notary.verify(agent, applicant, applicant.getPreferredName(), applicant.getDoB(), 10, "notary-junit-test", validVerificationDateString(), VerificationType.FACE_TO_FACE, DE); // verify double - assuranceFail(assuranceUser, assuree, 10, "notary-junit-test", validVerificationDateString()); + verificationFail(agent, applicant, 10, "notary-junit-test", validVerificationDateString()); } @Test public void testNucleus() throws SQLException, GigiApiException, IOException { - User assuranceUser = User.getById(createAssuranceUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD)); - assuranceUser.grantGroup(getSupporter(), Group.NUCLEUS_ASSURER); - User assuree = User.getById(createVerifiedUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD)); - Name n1 = assuree.getPreferredName(); - Name n2 = new Name(assuree, new NamePart(NamePartType.FIRST_NAME, "F2"), new NamePart(NamePartType.LAST_NAME, "L2")); - - assertEquals(0, assuree.getExperiencePoints()); - assertEquals(User.EXPERIENCE_POINTS, assuranceUser.getExperiencePoints()); - assertEquals(0, assuree.getAssurancePoints()); - assertEquals(0, n2.getAssurancePoints()); - Notary.assureAll(assuranceUser, assuree, assuree.getDoB(), 50, "notary-junit-test", validVerificationDateString(), AssuranceType.NUCLEUS, new Name[] { + User agent = User.getById(createVerificationUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD)); + agent.grantGroup(getSupporter(), Group.NUCLEUS_ASSURER); + User applicant = User.getById(createVerifiedUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD)); + Name n1 = applicant.getPreferredName(); + Name n2 = new Name(applicant, new NamePart(NamePartType.FIRST_NAME, "F2"), new NamePart(NamePartType.LAST_NAME, "L2")); + + assertEquals(0, applicant.getExperiencePoints()); + assertEquals(User.EXPERIENCE_POINTS, agent.getExperiencePoints()); + assertEquals(0, applicant.getVerificationPoints()); + assertEquals(0, n2.getVerificationPoints()); + Notary.verifyAll(agent, applicant, applicant.getDoB(), 50, "notary-junit-test", validVerificationDateString(), VerificationType.NUCLEUS, new Name[] { n1, n2 }, DE); - assertEquals(0, assuree.getExperiencePoints()); - assertEquals(2 * User.EXPERIENCE_POINTS, assuranceUser.getExperiencePoints()); - assertEquals(50, assuree.getAssurancePoints()); - assertEquals(50, n1.getAssurancePoints()); - assertEquals(50, n2.getAssurancePoints()); + assertEquals(0, applicant.getExperiencePoints()); + assertEquals(2 * User.EXPERIENCE_POINTS, agent.getExperiencePoints()); + assertEquals(50, applicant.getVerificationPoints()); + assertEquals(50, n1.getVerificationPoints()); + assertEquals(50, n2.getVerificationPoints()); } @Test public void testNucleusProcess() throws SQLException, GigiApiException, IOException { - User assuranceUser = User.getById(createAssuranceUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD)); - assuranceUser.grantGroup(getSupporter(), Group.NUCLEUS_ASSURER); - User assuranceUser2 = User.getById(createAssuranceUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD)); - assuranceUser2.grantGroup(getSupporter(), Group.NUCLEUS_ASSURER); - User assuree = User.getById(createVerifiedUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD)); - Notary.assure(assuranceUser, assuree, assuree.getPreferredName(), assuree.getDoB(), 50, "test", validVerificationDateString(), AssuranceType.NUCLEUS, DE); - Notary.assure(assuranceUser2, assuree, assuree.getPreferredName(), assuree.getDoB(), 50, "test", validVerificationDateString(), AssuranceType.NUCLEUS, DE); - - assertEquals(100, assuree.getAssurancePoints()); - assertFalse(assuree.canAssure()); - CATS.enterResult(assuree, CATSType.ASSURER_CHALLENGE, new Date(), "de", "1"); - assertTrue(assuree.canAssure()); + User agent1 = User.getById(createVerificationUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD)); + agent1.grantGroup(getSupporter(), Group.NUCLEUS_ASSURER); + User agent2 = User.getById(createVerificationUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD)); + agent2.grantGroup(getSupporter(), Group.NUCLEUS_ASSURER); + User applicant = User.getById(createVerifiedUser("fn", "ln", createUniqueName() + "@example.org", TEST_PASSWORD)); + Notary.verify(agent1, applicant, applicant.getPreferredName(), applicant.getDoB(), 50, "test", validVerificationDateString(), VerificationType.NUCLEUS, DE); + Notary.verify(agent2, applicant, applicant.getPreferredName(), applicant.getDoB(), 50, "test", validVerificationDateString(), VerificationType.NUCLEUS, DE); + + assertEquals(100, applicant.getVerificationPoints()); + assertFalse(applicant.canVerify()); + CATS.enterResult(applicant, CATSType.AGENT_CHALLENGE, new Date(), "de", "1"); + assertTrue(applicant.canVerify()); } } diff --git a/util-testing/club/wpia/gigi/pages/Manager.java b/util-testing/club/wpia/gigi/pages/Manager.java index f7473989..7cecac23 100644 --- a/util-testing/club/wpia/gigi/pages/Manager.java +++ b/util-testing/club/wpia/gigi/pages/Manager.java @@ -27,12 +27,10 @@ import java.util.regex.Pattern; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import sun.security.x509.X509Key; import club.wpia.gigi.Gigi; import club.wpia.gigi.GigiApiException; import club.wpia.gigi.crypto.SPKAC; import club.wpia.gigi.database.GigiPreparedStatement; -import club.wpia.gigi.dbObjects.Assurance.AssuranceType; import club.wpia.gigi.dbObjects.CATS; import club.wpia.gigi.dbObjects.CATS.CATSType; import club.wpia.gigi.dbObjects.Certificate; @@ -47,6 +45,7 @@ import club.wpia.gigi.dbObjects.Group; import club.wpia.gigi.dbObjects.NamePart; import club.wpia.gigi.dbObjects.NamePart.NamePartType; import club.wpia.gigi.dbObjects.User; +import club.wpia.gigi.dbObjects.Verification.VerificationType; import club.wpia.gigi.email.DelegateMailProvider; import club.wpia.gigi.localisation.Language; import club.wpia.gigi.output.template.IterableDataset; @@ -59,6 +58,7 @@ import club.wpia.gigi.util.DayDate; import club.wpia.gigi.util.HTMLEncoder; import club.wpia.gigi.util.Notary; import club.wpia.gigi.util.TimeConditions; +import sun.security.x509.X509Key; public class Manager extends Page { @@ -110,7 +110,7 @@ public class Manager extends Page { return supporter; } try { - User u = createAssurer( -1); + User u = createAgent( -1); if ( !u.isInGroup(Group.SUPPORTER)) { try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `user_groups` SET `user`=?, `permission`=?::`userGroup`, `grantedby`=?")) { ps.setInt(1, u.getId()); @@ -127,29 +127,29 @@ public class Manager extends Page { return supporter; } - public User getAssurer(int i) { - if (assurers[i] != null) { - return assurers[i]; + public User getAgent(int i) { + if (agents[i] != null) { + return agents[i]; } try { - User u = createAssurer(i); - assurers[i] = u; + User u = createAgent(i); + agents[i] = u; } catch (ReflectiveOperationException | GigiApiException e) { e.printStackTrace(); } - return assurers[i]; + return agents[i]; } - private User createAssurer(int i) throws GigiApiException, IllegalAccessException { + private User createAgent(int i) throws GigiApiException, IllegalAccessException { try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?, `country`=?")) { - String mail = "test-assurer" + i + "@example.com"; + String mail = "test-agent" + i + "@example.com"; User u = User.getByEmail(mail); if (u == null) { System.out.println("Creating RA-Agent"); createUser(mail); u = User.getByEmail(mail); - passCATS(u, CATSType.ASSURER_CHALLENGE); + passCATS(u, CATSType.AGENT_CHALLENGE); ps.setInt(1, u.getId()); ps.setInt(2, u.getPreferredName().getId()); ps.setInt(3, 100); @@ -290,7 +290,7 @@ public class Manager extends Page { // ea.verify(hash); } - User[] assurers = new User[25]; + User[] agents = new User[25]; User supporter; @@ -334,8 +334,8 @@ public class Manager extends Page { CATSType test = CATSType.values()[Integer.parseInt(testId)]; passCATS(byEmail, test); resp.getWriter().println("Test '" + test.getDisplayName() + "' was added to user account."); - } else if (req.getParameter("assure") != null) { - String mail = req.getParameter("assureEmail"); + } else if (req.getParameter("verify") != null) { + String mail = req.getParameter("verifyEmail"); String verificationPoints = req.getParameter("verificationPoints"); User byEmail = User.getByEmail(mail); @@ -363,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", validVerificationDateString(), AssuranceType.FACE_TO_FACE, getRandomCountry()); + Notary.verify(getAgent(agentNumber), byEmail, byEmail.getPreferredName(), byEmail.getDoB(), currentVP, "Testmanager Verify up code", validVerificationDateString(), VerificationType.FACE_TO_FACE, getRandomCountry()); agentNumber += 1; vp -= currentVP; } @@ -372,15 +372,15 @@ public class Manager extends Page { throw new Error(e); } - resp.getWriter().println("User has been assured " + agentNumber + " times."); + resp.getWriter().println("User has been verified " + agentNumber + " times."); - } else if (req.getParameter("letassure") != null) { - String mail = req.getParameter("letassureEmail"); + } else if (req.getParameter("letverify") != null) { + String mail = req.getParameter("letverifyEmail"); User byEmail = User.getByEmail(mail); 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", validVerificationDateString(), AssuranceType.FACE_TO_FACE, getRandomCountry()); + User a = getAgent(i); + Notary.verify(byEmail, a, a.getNames()[0], a.getDoB(), 10, "Testmanager exp up code", validVerificationDateString(), VerificationType.FACE_TO_FACE, getRandomCountry()); } } catch (GigiApiException e) { throw new Error(e); diff --git a/util-testing/club/wpia/gigi/pages/Manager.templ b/util-testing/club/wpia/gigi/pages/Manager.templ index 11cbb3da..7cef1608 100644 --- a/util-testing/club/wpia/gigi/pages/Manager.templ +++ b/util-testing/club/wpia/gigi/pages/Manager.templ @@ -55,19 +55,19 @@ Email: Add 100 Verification Points: -Email: +Email: Verification Points to issue to preferred name:
- + Verify 25 others (get 25 Experience Points) : -Email: +Email: - + -- 2.39.2