X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=tests%2Fclub%2Fwpia%2Fgigi%2Fpages%2Fwot%2FTestVerification.java;h=dcc61fc070cf66d857ec173546001b527c415e01;hp=a25a2bc43b4887cd9667821e52d2ff61bc2920c2;hb=bb3f2922c28e31def60ea7be34a8c5015ca18bb1;hpb=c23bd923858a6c589bddecebd65fdf0739c62e6a diff --git a/tests/club/wpia/gigi/pages/wot/TestVerification.java b/tests/club/wpia/gigi/pages/wot/TestVerification.java index a25a2bc4..dcc61fc0 100644 --- a/tests/club/wpia/gigi/pages/wot/TestVerification.java +++ b/tests/club/wpia/gigi/pages/wot/TestVerification.java @@ -23,6 +23,7 @@ import org.junit.Test; import club.wpia.gigi.GigiApiException; import club.wpia.gigi.database.GigiPreparedStatement; +import club.wpia.gigi.dbObjects.CATS.CATSType; import club.wpia.gigi.dbObjects.Country; import club.wpia.gigi.dbObjects.Group; import club.wpia.gigi.dbObjects.User; @@ -41,6 +42,8 @@ public class TestVerification extends ManagedTest { private int applicantName; + private int applicantId; + private String cookie; @Before @@ -50,7 +53,7 @@ public class TestVerification extends ManagedTest { applicantM = createUniqueName() + "@example.org"; createVerificationUser("a", "b", agentM, TEST_PASSWORD); - int applicantId = createVerifiedUser("a", "c", applicantM, TEST_PASSWORD); + applicantId = createVerifiedUser("a", "c", applicantM, TEST_PASSWORD); applicantName = User.getById(applicantId).getPreferredName().getId(); User users[] = User.findByEmail(agentM); @@ -391,4 +394,32 @@ public class TestVerification extends ManagedTest { loginCertificate = null; assertEquals(403, get(cookie, VerifyPage.PATH).getResponseCode()); } + + @Test + 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); + assertEquals(200, get(cookie, VerifyPage.PATH).getResponseCode()); + } + + @Test + public void testVerifyValidTTPChallenge() throws IOException, GigiApiException { + grant(User.getByEmail(agentM), Group.TTP_AGENT); + grant(User.getById(applicantId), Group.TTP_APPLICANT); + cookie = cookieWithCertificateLogin(User.getById(applicantId)); + cookie = cookieWithCertificateLogin(User.getByEmail(agentM)); + + // test without valid challenge + String content = search("email=" + URLEncoder.encode(applicantM, "UTF-8") + "&day=1&month=1&year=1910"); + assertThat(content, containsString("you need to pass the TTP RA Agent Challenge")); + + // test with valid challenge + addChallenge(User.getByEmail(agentM).getId(), CATSType.TTP_AGENT_CHALLENGE); + content = search("email=" + URLEncoder.encode(applicantM, "UTF-8") + "&day=1&month=1&year=1910"); + assertThat(content, not(containsString("you need to pass the TTP RA Agent Challenge"))); + } }