]> WPIA git - gigi.git/blobdiff - tests/club/wpia/gigi/pages/wot/TestTTPAdmin.java
add: ensure that for TTPAgent action there is a valid TTPAgent Challenge
[gigi.git] / tests / club / wpia / gigi / pages / wot / TestTTPAdmin.java
index 0e11f6df501c479c8b0d6fea2da5780c315e7368..ec423d681c3f76321f347b6a4467f4cc2be71dab 100644 (file)
@@ -9,6 +9,7 @@ import java.security.GeneralSecurityException;
 import org.junit.Test;
 
 import club.wpia.gigi.GigiApiException;
+import club.wpia.gigi.dbObjects.CATS.CATSType;
 import club.wpia.gigi.dbObjects.Group;
 import club.wpia.gigi.dbObjects.User;
 import club.wpia.gigi.pages.admin.TTPAdminPage;
@@ -35,6 +36,7 @@ public class TestTTPAdmin extends ClientTest {
     public void testTTPAdmin(boolean hasRight) throws IOException, GigiApiException, GeneralSecurityException, InterruptedException {
         if (hasRight) {
             grant(u, Group.TTP_AGENT);
+            addChallenge(u.getId(), CATSType.TTP_AGENT_CHALLENGE);
         }
         grant(u, TTPAdminPage.TTP_APPLICANT);
         cookie = cookieWithCertificateLogin(u);
@@ -56,4 +58,12 @@ public class TestTTPAdmin extends ClientTest {
         loginCertificate = null;
         assertEquals(403, get(cookie, TTPAdminPage.PATH).getResponseCode());
     }
+
+    @Test
+    public void testAccessTTPPageWithoutValidChallenge() throws IOException, GigiApiException {
+        grant(u, Group.TTP_AGENT);
+        loginCertificate = null;
+        cookie = cookieWithCertificateLogin(u);
+        assertEquals(403, get(cookie, TTPAdminPage.PATH).getResponseCode());
+    }
 }