]> WPIA git - gigi.git/blobdiff - tests/club/wpia/gigi/pages/admin/TestSEAdminTicketSetting.java
add: ensure that for Support actions there is a valid Support Challenge
[gigi.git] / tests / club / wpia / gigi / pages / admin / TestSEAdminTicketSetting.java
index e20b4944da0e88bdc7b145a5e9e15df4bb00d99f..7562ed0076d6eac643423019287c4b92a4c10efa 100644 (file)
@@ -12,7 +12,10 @@ import java.util.Random;
 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.support.FindCertPage;
 import club.wpia.gigi.pages.admin.support.FindUserByDomainPage;
 import club.wpia.gigi.pages.admin.support.FindUserByEmailPage;
 import club.wpia.gigi.pages.admin.support.SupportEnterTicketForm;
@@ -24,16 +27,17 @@ public class TestSEAdminTicketSetting extends ClientTest {
 
     public TestSEAdminTicketSetting() throws IOException, GigiApiException {
         grant(u, Group.SUPPORTER);
-        cookie = login(email, TEST_PASSWORD);
+        addChallenge(u.getId(), CATSType.SUPPORT_DP_CHALLENGE_NAME);
+        cookie = cookieWithCertificateLogin(u);
     }
 
     @Test
     public void testFulltextMailSearch() throws MalformedURLException, UnsupportedEncodingException, IOException {
         assertEquals(403, get(FindUserByEmailPage.PATH).getResponseCode());
-        assertEquals(302, post(cookie, SupportEnterTicketPage.PATH, "ticketno=a20140808.8&setTicket=action", 0).getResponseCode());
+        assertEquals(302, post(SupportEnterTicketPage.PATH, "ticketno=a20140808.8&setTicket=action", 0).getResponseCode());
         assertEquals(200, get(FindUserByEmailPage.PATH).getResponseCode());
         assertEquals(200, get(FindUserByDomainPage.PATH).getResponseCode());
-        assertEquals(302, post(cookie, SupportEnterTicketPage.PATH, "ticketno=a20140808.8&deleteTicket=action", 0).getResponseCode());
+        assertEquals(302, post(SupportEnterTicketPage.PATH, "ticketno=a20140808.8&deleteTicket=action", 0).getResponseCode());
         assertEquals(403, get(FindUserByEmailPage.PATH).getResponseCode());
     }
 
@@ -45,9 +49,9 @@ public class TestSEAdminTicketSetting extends ClientTest {
         // test allowed character
         for (char ch : SupportEnterTicketForm.TICKET_PREFIX.toCharArray()) {
             ticket = ch + "20171212.1";
-            assertEquals(302, post(cookie, SupportEnterTicketPage.PATH, "ticketno=" + ticket + "&setTicket=action", 0).getResponseCode());
+            assertEquals(302, post(SupportEnterTicketPage.PATH, "ticketno=" + ticket + "&setTicket=action", 0).getResponseCode());
             ticket = Character.toUpperCase(ch) + "20171212.1";
-            assertEquals(302, post(cookie, SupportEnterTicketPage.PATH, "ticketno=" + ticket + "&setTicket=action", 0).getResponseCode());
+            assertEquals(302, post(SupportEnterTicketPage.PATH, "ticketno=" + ticket + "&setTicket=action", 0).getResponseCode());
             alphabet = alphabet.replaceAll(Character.toString(ch), "");
         }
 
@@ -99,4 +103,28 @@ public class TestSEAdminTicketSetting extends ClientTest {
         String res = IOUtils.readURL(post(SupportEnterTicketPage.PATH, "ticketno=" + ticket + "&setTicket=action"));
         assertThat(res, containsString("Ticket format malformed"));
     }
+
+    @Test
+    public void testPWLogin() throws MalformedURLException, UnsupportedEncodingException, IOException {
+        String cookiePW = login(email, TEST_PASSWORD);
+        loginCertificate = null;
+        assertEquals(403, get(cookiePW, SupportEnterTicketPage.PATH).getResponseCode());
+        assertEquals(403, get(cookiePW, FindUserByEmailPage.PATH).getResponseCode());
+        assertEquals(403, get(cookiePW, FindUserByDomainPage.PATH).getResponseCode());
+        assertEquals(403, get(cookiePW, FindCertPage.PATH).getResponseCode());
+    }
+
+    @Test
+    public void testNoSupportChallenge() throws MalformedURLException, UnsupportedEncodingException, IOException, GigiApiException {
+        User supporter1 = User.getById(createVerificationUser("testworker", "testname", createUniqueName() + "@testdom.com", TEST_PASSWORD));
+        grant(supporter1, Group.SUPPORTER);
+        loginCertificate = null;
+        cookie = cookieWithCertificateLogin(supporter1);
+
+        assertEquals(403, get(SupportEnterTicketPage.PATH).getResponseCode());
+        assertEquals(403, get(FindUserByEmailPage.PATH).getResponseCode());
+        assertEquals(403, get(FindUserByDomainPage.PATH).getResponseCode());
+        assertEquals(403, get(FindCertPage.PATH).getResponseCode());
+    }
+
 }