chg: create superclass for SE tests
authorINOPIAE <m.maengel@inopiae.de>
Wed, 17 Jan 2018 11:28:30 +0000 (12:28 +0100)
committerFelix Dörre <felix@dogcraft.de>
Wed, 17 Jan 2018 15:50:40 +0000 (16:50 +0100)
Change-Id: I30261f79e4f3a4babf62ce2d824716ec4b808609

tests/club/wpia/gigi/pages/admin/TestSEAdminNotificationMail.java
tests/club/wpia/gigi/pages/admin/TestSEAdminPageCertSearch.java
tests/club/wpia/gigi/pages/admin/TestSEAdminPageDetails.java
tests/club/wpia/gigi/pages/admin/TestSEAdminPageUserDomainSearch.java
tests/club/wpia/gigi/pages/admin/TestSEAdminPageUserMailSearch.java
tests/club/wpia/gigi/testUtils/SEClientTest.java [new file with mode: 0644]

index 9bcaa82..30aeb64 100644 (file)
@@ -17,23 +17,18 @@ import club.wpia.gigi.GigiApiException;
 import club.wpia.gigi.dbObjects.Group;
 import club.wpia.gigi.dbObjects.User;
 import club.wpia.gigi.localisation.Language;
-import club.wpia.gigi.pages.admin.support.SupportEnterTicketPage;
 import club.wpia.gigi.pages.admin.support.SupportUserDetailsPage;
-import club.wpia.gigi.testUtils.ClientTest;
+import club.wpia.gigi.testUtils.SEClientTest;
 import club.wpia.gigi.testUtils.TestEmailReceiver.TestMail;
 import club.wpia.gigi.util.ServerConstants;
 
-public class TestSEAdminNotificationMail extends ClientTest {
+public class TestSEAdminNotificationMail extends SEClientTest {
 
     private int targetID;
 
     private String targetEmail;
 
     public TestSEAdminNotificationMail() throws IOException, GigiApiException {
-        grant(u, Group.SUPPORTER);
-        cookie = login(email, TEST_PASSWORD);
-        assertEquals(302, post(cookie, SupportEnterTicketPage.PATH, "ticketno=a20140808.8&setTicket=action", 0).getResponseCode());
-
         targetEmail = createUniqueName() + "@example.com";
         String fname = "Först";
         String lname = "Secönd";
index 6feaafc..74375f2 100644 (file)
@@ -19,19 +19,17 @@ import club.wpia.gigi.dbObjects.Certificate.CertificateStatus;
 import club.wpia.gigi.dbObjects.Certificate.RevocationType;
 import club.wpia.gigi.dbObjects.Certificate.SANType;
 import club.wpia.gigi.dbObjects.Digest;
-import club.wpia.gigi.dbObjects.Group;
 import club.wpia.gigi.dbObjects.User;
 import club.wpia.gigi.output.template.Template;
 import club.wpia.gigi.pages.account.certs.Certificates;
 import club.wpia.gigi.pages.admin.support.FindCertPage;
-import club.wpia.gigi.pages.admin.support.SupportEnterTicketPage;
-import club.wpia.gigi.testUtils.ClientTest;
 import club.wpia.gigi.testUtils.IOUtils;
+import club.wpia.gigi.testUtils.SEClientTest;
 import club.wpia.gigi.testUtils.TestEmailReceiver.TestMail;
 import club.wpia.gigi.util.ServerConstants;
 import club.wpia.gigi.util.ServerConstants.Host;
 
-public class TestSEAdminPageCertSearch extends ClientTest {
+public class TestSEAdminPageCertSearch extends SEClientTest {
 
     private Certificate c;
 
@@ -40,10 +38,6 @@ public class TestSEAdminPageCertSearch extends ClientTest {
     private int id;
 
     public TestSEAdminPageCertSearch() throws IOException, GigiApiException, GeneralSecurityException, InterruptedException {
-        grant(u, Group.SUPPORTER);
-        cookie = login(email, TEST_PASSWORD);
-        assertEquals(302, post(cookie, SupportEnterTicketPage.PATH, "ticketno=a20140808.8&setTicket=action", 0).getResponseCode());
-
         certMail = uniq + "_certowner@example.com";
         id = createVerifiedUser("fn", "ln", certMail, TEST_PASSWORD);
         c = createCertificate();
@@ -71,7 +65,7 @@ public class TestSEAdminPageCertSearch extends ClientTest {
     }
 
     @Test
-    public void testRevoke() throws IOException, GeneralSecurityException, GigiApiException, InterruptedException {
+    public void testRevoke() throws IOException {
         URLConnection conn = post(Certificates.SUPPORT_PATH + "/" + c.getSerial(), "action=revoke");
         assertEquals("https://" + ServerConstants.getHostNamePortSecure(Host.WWW) + Certificates.SUPPORT_PATH + "/" + c.getSerial(), conn.getHeaderField("Location"));
         for (int i = 0; i < 2; i++) {
index 72930b3..9b92fcb 100644 (file)
@@ -16,23 +16,18 @@ import org.junit.Test;
 import club.wpia.gigi.GigiApiException;
 import club.wpia.gigi.database.GigiPreparedStatement;
 import club.wpia.gigi.dbObjects.EmailAddress;
-import club.wpia.gigi.dbObjects.Group;
 import club.wpia.gigi.dbObjects.ObjectCache;
 import club.wpia.gigi.dbObjects.User;
 import club.wpia.gigi.pages.account.History;
 import club.wpia.gigi.pages.admin.support.SupportEnterTicketPage;
 import club.wpia.gigi.pages.admin.support.SupportUserDetailsPage;
-import club.wpia.gigi.testUtils.ClientTest;
 import club.wpia.gigi.testUtils.IOUtils;
+import club.wpia.gigi.testUtils.SEClientTest;
 import club.wpia.gigi.util.DayDate;
 
-public class TestSEAdminPageDetails extends ClientTest {
+public class TestSEAdminPageDetails extends SEClientTest {
 
-    public TestSEAdminPageDetails() throws IOException, GigiApiException {
-        grant(u, Group.SUPPORTER);
-        cookie = login(email, TEST_PASSWORD);
-        assertEquals(302, post(cookie, SupportEnterTicketPage.PATH, "ticketno=a20140808.8&setTicket=action", 0).getResponseCode());
-    }
+    public TestSEAdminPageDetails() throws IOException, GigiApiException {}
 
     @Test
     public void testUserDetailsDisplay() throws MalformedURLException, IOException {
index 7574165..383d232 100644 (file)
@@ -14,17 +14,15 @@ import org.junit.Test;
 
 import club.wpia.gigi.GigiApiException;
 import club.wpia.gigi.dbObjects.Domain;
-import club.wpia.gigi.dbObjects.Group;
 import club.wpia.gigi.dbObjects.User;
 import club.wpia.gigi.pages.admin.support.FindUserByDomainPage;
-import club.wpia.gigi.pages.admin.support.SupportEnterTicketPage;
 import club.wpia.gigi.pages.admin.support.SupportUserDetailsPage;
-import club.wpia.gigi.testUtils.ClientTest;
 import club.wpia.gigi.testUtils.IOUtils;
+import club.wpia.gigi.testUtils.SEClientTest;
 import club.wpia.gigi.util.ServerConstants;
 import club.wpia.gigi.util.ServerConstants.Host;
 
-public class TestSEAdminPageUserDomainSearch extends ClientTest {
+public class TestSEAdminPageUserDomainSearch extends SEClientTest {
 
     private Domain d;
 
@@ -35,10 +33,6 @@ public class TestSEAdminPageUserDomainSearch extends ClientTest {
     private int tid;
 
     public TestSEAdminPageUserDomainSearch() throws IOException, GigiApiException {
-        grant(u, Group.SUPPORTER);
-        cookie = login(email, TEST_PASSWORD);
-        assertEquals(302, post(cookie, SupportEnterTicketPage.PATH, "ticketno=a20140808.8&setTicket=action", 0).getResponseCode());
-
         String mail = createUniqueName() + "@example.com";
         tid = createVerifiedUser("Först", "Secönd", mail, TEST_PASSWORD);
         User user = User.getById(tid);
index c4bf8b4..a21ca96 100644 (file)
@@ -12,23 +12,17 @@ import java.net.URLEncoder;
 import org.junit.Test;
 
 import club.wpia.gigi.GigiApiException;
-import club.wpia.gigi.dbObjects.Group;
 import club.wpia.gigi.dbObjects.User;
 import club.wpia.gigi.pages.admin.support.FindUserByEmailPage;
-import club.wpia.gigi.pages.admin.support.SupportEnterTicketPage;
 import club.wpia.gigi.pages.admin.support.SupportUserDetailsPage;
-import club.wpia.gigi.testUtils.ClientTest;
 import club.wpia.gigi.testUtils.IOUtils;
+import club.wpia.gigi.testUtils.SEClientTest;
 import club.wpia.gigi.util.ServerConstants;
 import club.wpia.gigi.util.ServerConstants.Host;
 
-public class TestSEAdminPageUserMailSearch extends ClientTest {
+public class TestSEAdminPageUserMailSearch extends SEClientTest {
 
-    public TestSEAdminPageUserMailSearch() throws IOException, GigiApiException {
-        grant(u, Group.SUPPORTER);
-        cookie = login(email, TEST_PASSWORD);
-        assertEquals(302, post(cookie, SupportEnterTicketPage.PATH, "ticketno=a20140808.8&setTicket=action", 0).getResponseCode());
-    }
+    public TestSEAdminPageUserMailSearch() throws IOException, GigiApiException {}
 
     @Test
     public void testFulltextMailSearch() throws MalformedURLException, UnsupportedEncodingException, IOException {
diff --git a/tests/club/wpia/gigi/testUtils/SEClientTest.java b/tests/club/wpia/gigi/testUtils/SEClientTest.java
new file mode 100644 (file)
index 0000000..004f34f
--- /dev/null
@@ -0,0 +1,23 @@
+package club.wpia.gigi.testUtils;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+
+import club.wpia.gigi.GigiApiException;
+import club.wpia.gigi.dbObjects.Group;
+import club.wpia.gigi.pages.admin.support.SupportEnterTicketPage;
+
+/**
+ * Superclass for testsuites in a scenario where there is a supporter, who is
+ * already logged on.
+ */
+public abstract class SEClientTest extends ClientTest {
+
+    public SEClientTest() throws IOException, GigiApiException {
+        grant(u, Group.SUPPORTER);
+        cookie = login(email, TEST_PASSWORD);
+        assertEquals(302, post(cookie, SupportEnterTicketPage.PATH, "ticketno=a20140808.8&setTicket=action", 0).getResponseCode());
+    }
+
+}