]> WPIA git - gigi.git/blobdiff - tests/club/wpia/gigi/pages/admin/TestSEAdminPageDetails.java
add: enable Support to see the new RA Agent status
[gigi.git] / tests / club / wpia / gigi / pages / admin / TestSEAdminPageDetails.java
index 9b92fcbc08dfb20dc52e1d83dc1a8472a242b3c1..b3dad24073a29e7572bf9a71225ca999dd0acd0c 100644 (file)
@@ -15,6 +15,7 @@ import org.junit.Test;
 
 import club.wpia.gigi.GigiApiException;
 import club.wpia.gigi.database.GigiPreparedStatement;
+import club.wpia.gigi.dbObjects.Certificate;
 import club.wpia.gigi.dbObjects.EmailAddress;
 import club.wpia.gigi.dbObjects.ObjectCache;
 import club.wpia.gigi.dbObjects.User;
@@ -27,7 +28,11 @@ import club.wpia.gigi.util.DayDate;
 
 public class TestSEAdminPageDetails extends SEClientTest {
 
-    public TestSEAdminPageDetails() throws IOException, GigiApiException {}
+    private Certificate cs;
+
+    public TestSEAdminPageDetails() throws IOException, GigiApiException {
+        cs = loginCertificate;
+    }
 
     @Test
     public void testUserDetailsDisplay() throws MalformedURLException, IOException {
@@ -118,12 +123,13 @@ public class TestSEAdminPageDetails extends SEClientTest {
         String clientCookie = login(email, TEST_PASSWORD);
 
         // try to open mypoints as user
+        loginCertificate = null;
         HttpURLConnection uc = get(clientCookie, SupportUserDetailsPage.PATH + id + "/points");
 
         assertEquals(403, uc.getResponseCode());
 
         // enter verification and open mypoints as supporter
-
+        loginCertificate = cs;
         makeAgent(this.id);
         String location = createUniqueName();
         try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `notary` SET `from`=?, `to`=?, `points`=?, `location`=?, `date`=?, `when`=? ")) {
@@ -157,7 +163,10 @@ public class TestSEAdminPageDetails extends SEClientTest {
     }
 
     private int logCountUser(String cookie) throws IOException {
-        return getLogEntryCount(IOUtils.readURL(get(cookie, History.PATH)));
+        loginCertificate = null;
+        int count = getLogEntryCount(IOUtils.readURL(get(cookie, History.PATH)));
+        loginCertificate = cs;
+        return count;
     }
 
     private int getLogEntryCount(String readURL) {
@@ -174,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:")));
+
+    }
 }