]> WPIA git - gigi.git/blobdiff - tests/club/wpia/gigi/pages/TestMain.java
add: ensure that for OrgAgent action there is a valid OrgAgent Challenge
[gigi.git] / tests / club / wpia / gigi / pages / TestMain.java
index e6dce4569348d0d6a795aecaa742911a449c80fb..70a71a5dc50c6f7672ca699f24ea5aefd9095253 100644 (file)
@@ -117,5 +117,55 @@ public class TestMain extends ClientTest {
         authenticate((HttpURLConnection) uc);
         content = IOUtils.readURL(uc);
         assertThat(content, not(containsString("you need to pass the RA Agent Challenge")));
+
+        // test Support challenge
+        uc = new URL("https://" + getSecureServerName()).openConnection();
+        authenticate((HttpURLConnection) uc);
+        content = IOUtils.readURL(uc);
+        assertThat(content, not(containsString("you need to pass the Support Challenge")));
+
+        grant(u, Group.SUPPORTER);
+        cookie = login(loginPrivateKey, loginCertificate.cert());
+        uc = new URL("https://" + getSecureServerName()).openConnection();
+        authenticate((HttpURLConnection) uc);
+        content = IOUtils.readURL(uc);
+        assertThat(content, containsString("you need to pass the Support Challenge"));
+
+        addChallengeInPast(u.getId(), CATSType.SUPPORT_DP_CHALLENGE_NAME);
+        uc = new URL("https://" + getSecureServerName()).openConnection();
+        authenticate((HttpURLConnection) uc);
+        content = IOUtils.readURL(uc);
+        assertThat(content, containsString("you need to pass the Support Challenge"));
+
+        addChallenge(u.getId(), CATSType.SUPPORT_DP_CHALLENGE_NAME);
+        uc = new URL("https://" + getSecureServerName()).openConnection();
+        authenticate((HttpURLConnection) uc);
+        content = IOUtils.readURL(uc);
+        assertThat(content, not(containsString("you need to pass the Support Challenge")));
+
+        // test Org Agent challenge
+        uc = new URL("https://" + getSecureServerName()).openConnection();
+        authenticate((HttpURLConnection) uc);
+        content = IOUtils.readURL(uc);
+        assertThat(content, not(containsString("you need to pass the Organisation Agent Challenge")));
+
+        grant(u, Group.ORG_AGENT);
+        cookie = login(loginPrivateKey, loginCertificate.cert());
+        uc = new URL("https://" + getSecureServerName()).openConnection();
+        authenticate((HttpURLConnection) uc);
+        content = IOUtils.readURL(uc);
+        assertThat(content, containsString("you need to pass the Organisation Agent Challenge"));
+
+        addChallengeInPast(u.getId(), CATSType.ORG_AGENT_CHALLENGE);
+        uc = new URL("https://" + getSecureServerName()).openConnection();
+        authenticate((HttpURLConnection) uc);
+        content = IOUtils.readURL(uc);
+        assertThat(content, containsString("you need to pass the Organisation Agent Challenge"));
+
+        addChallenge(u.getId(), CATSType.ORG_AGENT_CHALLENGE);
+        uc = new URL("https://" + getSecureServerName()).openConnection();
+        authenticate((HttpURLConnection) uc);
+        content = IOUtils.readURL(uc);
+        assertThat(content, not(containsString("you need to pass the Organisation Agent Challenge")));
     }
 }