add: enable Support to see the new RA Agent status
authorINOPIAE <m.maengel@inopiae.de>
Tue, 24 Jul 2018 13:46:42 +0000 (15:46 +0200)
committerINOPIAE <m.maengel@inopiae.de>
Sun, 1 Dec 2019 05:12:02 +0000 (06:12 +0100)
Change-Id: I211817db4565f7a033cb8837e51a086303d7d5eb

src/club/wpia/gigi/pages/admin/support/SupportUserDetailsForm.java
src/club/wpia/gigi/pages/admin/support/SupportUserDetailsForm.templ
tests/club/wpia/gigi/pages/TestMain.java
tests/club/wpia/gigi/pages/admin/TestSEAdminPageDetails.java
tests/club/wpia/gigi/pages/wot/TestVerification.java
tests/club/wpia/gigi/testUtils/ConfiguredTest.java

index 71909cf..0ed43d9 100644 (file)
@@ -8,6 +8,7 @@ import javax.servlet.http.HttpServletRequest;
 
 import club.wpia.gigi.Gigi;
 import club.wpia.gigi.GigiApiException;
+import club.wpia.gigi.dbObjects.Contract;
 import club.wpia.gigi.dbObjects.Group;
 import club.wpia.gigi.dbObjects.Name;
 import club.wpia.gigi.dbObjects.SupportedUser;
@@ -112,6 +113,7 @@ public class SupportUserDetailsForm extends Form {
 
         });
         vars.put("agent", user.canVerify());
+        vars.put("agentcontract", Contract.hasSignedContract(user, Contract.ContractType.RA_AGENT_CONTRACT));
         vars.put("dob", dobSelector);
         vars.put("verificationPoints", user.getVerificationPoints());
         vars.put("exppoints", user.getExperiencePoints());
index e357564..5f5ec99 100644 (file)
@@ -28,7 +28,7 @@
                 <? if($agent) { ?>
                 <?=_Yes?>
                 <? } else { ?>
-                <?=_No?>
+                <?=_No?> (<?=_RA Agent Contract signed:?> <? if($agentcontract) { ?><?=_Yes?><? } else { ?><?=_No?><?}?>)
                 <? } ?>
             </td>
         </tr>
index be642f0..d0d03ec 100644 (file)
@@ -97,9 +97,10 @@ public class TestMain extends ClientTest {
 
     @Test
     public void testValidChallenges() throws GeneralSecurityException, IOException, GigiApiException, InterruptedException {
-
+        insertRAContract(u.getId());
         // test RA Agent challenge
         cookie = cookieWithCertificateLogin(u);
+
         testChallengeText("you need to pass the RA Agent Challenge", false);
 
         add100Points(u.getId());
index 9187c4f..b3dad24 100644 (file)
@@ -183,4 +183,28 @@ public class TestSEAdminPageDetails extends SEClientTest {
         return c;
     }
 
+    @Test
+    public void testUserDetailsRAAgent() throws IOException, GigiApiException {
+        User u0 = User.getById(createVerifiedUser("Kurti", "Hansel", createUniqueName() + "@email.com", TEST_PASSWORD));
+
+        HttpURLConnection uc = get(cookie, SupportUserDetailsPage.PATH + u0.getId() + "/");
+        String res = IOUtils.readURL(uc);
+        assertThat(res, containsString("No (RA Agent Contract signed: No)"));
+
+        signRAContract(u0);
+        uc = get(cookie, SupportUserDetailsPage.PATH + u0.getId() + "/");
+        res = IOUtils.readURL(uc);
+        assertThat(res, containsString("No (RA Agent Contract signed: Yes)"));
+
+        insertPassedTest(u0.getId());
+        uc = get(cookie, SupportUserDetailsPage.PATH + u0.getId() + "/");
+        res = IOUtils.readURL(uc);
+        assertThat(res, containsString("No (RA Agent Contract signed: Yes)"));
+
+        insertVerificationPoints(u0.getId());
+        uc = get(cookie, SupportUserDetailsPage.PATH + u0.getId() + "/");
+        res = IOUtils.readURL(uc);
+        assertThat(res, not(containsString("RA Agent Contract signed:")));
+
+    }
 }
index 81ec4df..dcc61fc 100644 (file)
@@ -399,6 +399,7 @@ public class TestVerification extends ManagedTest {
     public void testVerifyWithoutValidChallenge() throws IOException, GigiApiException {
         cookie = cookieWithCertificateLogin(User.getById(applicantId));
         add100Points(applicantId);
+        insertRAContract(applicantId);
         addChallengeInPast(applicantId, CATSType.AGENT_CHALLENGE);
         assertEquals(403, get(cookie, VerifyPage.PATH).getResponseCode());
         addChallenge(applicantId, CATSType.AGENT_CHALLENGE);
index 845f695..322af0b 100644 (file)
@@ -42,6 +42,7 @@ import club.wpia.gigi.database.SQLFileManager.ImportType;
 import club.wpia.gigi.dbObjects.CATS;
 import club.wpia.gigi.dbObjects.CATS.CATSType;
 import club.wpia.gigi.dbObjects.CertificateProfile;
+import club.wpia.gigi.dbObjects.Contract;
 import club.wpia.gigi.dbObjects.Contract.ContractType;
 import club.wpia.gigi.dbObjects.Domain;
 import club.wpia.gigi.dbObjects.DomainPingType;
@@ -338,6 +339,7 @@ public abstract class ConfiguredTest {
     public static void makeAgent(int uid) {
         addChallenge(uid, CATSType.AGENT_CHALLENGE);
         add100Points(uid);
+        insertRAContract(uid);
     }
 
     public static void addChallenge(int uid, CATSType ct) {
@@ -363,7 +365,9 @@ public abstract class ConfiguredTest {
             ps2.setInt(2, User.getById(uid).getPreferredName().getId());
             ps2.execute();
         }
+    }
 
+    public static void insertRAContract(int uid) {
         // insert signed RA Contract
         try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `user_contracts` SET `memid`=?, `token`=?, `document`=?::`contractType`,`agentname`=?")) {
             ps.setInt(1, uid);
@@ -374,6 +378,24 @@ public abstract class ConfiguredTest {
         }
     }
 
+    public static void insertVerificationPoints(int uid) {
+        // insert Verification Points
+        try (GigiPreparedStatement ps2 = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, points='100'")) {
+            ps2.setInt(1, uid);
+            ps2.setInt(2, User.getById(uid).getPreferredName().getId());
+            ps2.execute();
+        }
+    }
+
+    public static void insertPassedTest(int uid) {
+        // insert passed test
+        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.AGENT_CHALLENGE.getId());
+            ps1.execute();
+        }
+    }
+
     public MailReceiver getMailReceiver() {
         throw new Error("Feature requires Business or ManagedTest.");
     }
@@ -417,4 +439,9 @@ public abstract class ConfiguredTest {
         c.add(Calendar.MONTH, -Notary.LIMIT_MAX_MONTHS_VERIFICATION + 1);
         return sdf.format(new Date(c.getTimeInMillis()));
     }
+
+    public void signRAContract(User u) throws GigiApiException {
+        new Contract(u, ContractType.RA_AGENT_CONTRACT);
+        getMailReceiver().receive(u.getEmail());
+    }
 }