UPD: clean up/document/beatufy testcases.
authorFelix Dörre <felix@dogcraft.de>
Sun, 1 Feb 2015 01:03:49 +0000 (02:03 +0100)
committerFelix Dörre <felix@dogcraft.de>
Sun, 1 Feb 2015 01:45:47 +0000 (02:45 +0100)
13 files changed:
tests/org/cacert/gigi/pages/account/TestCertificateAdd.java
tests/org/cacert/gigi/pages/account/TestChangePassword.java
tests/org/cacert/gigi/pages/account/TestContactInformation.java
tests/org/cacert/gigi/pages/account/TestDomain.java
tests/org/cacert/gigi/pages/account/TestMailManagement.java
tests/org/cacert/gigi/pages/orga/TestOrgaManagement.java
tests/org/cacert/gigi/pages/wot/TestTTP.java
tests/org/cacert/gigi/pages/wot/TestTTPAdmin.java
tests/org/cacert/gigi/ping/TestSSL.java
tests/org/cacert/gigi/testUtils/ClientTest.java
tests/org/cacert/gigi/testUtils/ConfiguredTest.java
tests/org/cacert/gigi/testUtils/ManagedTest.java
tests/org/cacert/gigi/testUtils/PingTest.java

index e1cc64fddffea0b3d7d19410b29a2c00bc251ddd..ba36830be206646de8b20f15b6492cc0c65d7f81 100644 (file)
@@ -31,11 +31,10 @@ import java.util.regex.Pattern;
 
 import org.cacert.gigi.crypto.SPKAC;
 import org.cacert.gigi.dbObjects.Digest;
-import org.cacert.gigi.dbObjects.User;
 import org.cacert.gigi.pages.account.certs.CertificateAdd;
 import org.cacert.gigi.pages.account.certs.CertificateIssueForm;
+import org.cacert.gigi.testUtils.ClientTest;
 import org.cacert.gigi.testUtils.IOUtils;
-import org.cacert.gigi.testUtils.ManagedTest;
 import org.cacert.gigi.util.PEM;
 import org.junit.Test;
 
@@ -53,18 +52,14 @@ import sun.security.x509.RFC822Name;
 import sun.security.x509.SubjectAlternativeNameExtension;
 import sun.security.x509.X509Key;
 
-public class TestCertificateAdd extends ManagedTest {
+public class TestCertificateAdd extends ClientTest {
 
     KeyPair kp = generateKeypair();
 
-    User u = User.getById(createVerifiedUser("testuser", "testname", uniq + "@testdom.com", TEST_PASSWORD));
-
-    String session = login(uniq + "@testdom.com", TEST_PASSWORD);
-
     String csrf;
 
     public TestCertificateAdd() throws GeneralSecurityException, IOException {
-        TestDomain.addDomain(session, uniq + ".tld");
+        TestDomain.addDomain(cookie, uniq + ".tld");
 
     }
 
@@ -86,13 +81,13 @@ public class TestCertificateAdd extends ManagedTest {
     public void testSimpleMail() throws IOException, GeneralSecurityException {
         PKCS10Attributes atts = buildAtts(new ObjectIdentifier[] {
             CertificateIssueForm.OID_KEY_USAGE_EMAIL_PROTECTION
-        }, new DNSName("a." + uniq + ".tld"), new DNSName("b." + uniq + ".tld"), new RFC822Name(uniq + "@testdom.com"));
+        }, new DNSName("a." + uniq + ".tld"), new DNSName("b." + uniq + ".tld"), new RFC822Name(email));
 
-        String pem = generatePEMCSR(kp, "CN=testuser testname", atts, "SHA384WithRSA");
+        String pem = generatePEMCSR(kp, "CN=a b", atts, "SHA384WithRSA");
 
         String[] res = fillOutForm("CSR=" + URLEncoder.encode(pem, "UTF-8"));
         assertArrayEquals(new String[] {
-                "mail", "testuser testname", "dns:a." + uniq + ".tld\ndns:b." + uniq + ".tld\nemail:" + uniq + "@testdom.com\n", Digest.SHA384.toString()
+                "mail", "a b", "dns:a." + uniq + ".tld\ndns:b." + uniq + ".tld\nemail:" + email + "\n", Digest.SHA384.toString()
         }, res);
     }
 
@@ -100,13 +95,13 @@ public class TestCertificateAdd extends ManagedTest {
     public void testSimpleClient() throws IOException, GeneralSecurityException {
         PKCS10Attributes atts = buildAtts(new ObjectIdentifier[] {
             CertificateIssueForm.OID_KEY_USAGE_SSL_CLIENT
-        }, new RFC822Name(uniq + "@testdom.com"));
+        }, new RFC822Name(email));
 
-        String pem = generatePEMCSR(kp, "CN=testuser testname,email=" + uniq + "@testdom.com", atts, "SHA512WithRSA");
+        String pem = generatePEMCSR(kp, "CN=a b,email=" + email, atts, "SHA512WithRSA");
 
         String[] res = fillOutForm("CSR=" + URLEncoder.encode(pem, "UTF-8"));
         assertArrayEquals(new String[] {
-                "client", "testuser testname", "email:" + uniq + "@testdom.com\n", Digest.SHA512.toString()
+                "client", "a b", "email:" + email + "\n", Digest.SHA512.toString()
         }, res);
     }
 
@@ -120,21 +115,21 @@ public class TestCertificateAdd extends ManagedTest {
     public void testIssue() throws IOException, GeneralSecurityException {
         PKCS10Attributes atts = buildAtts(new ObjectIdentifier[] {
             CertificateIssueForm.OID_KEY_USAGE_SSL_CLIENT
-        }, new RFC822Name(uniq + "@testdom.com"));
+        }, new RFC822Name(email));
 
-        String pem = generatePEMCSR(kp, "CN=testuser testname,email=" + uniq + "@testdom.com", atts, "SHA512WithRSA");
+        String pem = generatePEMCSR(kp, "CN=a b,email=" + email, atts, "SHA512WithRSA");
 
         String[] res = fillOutForm("CSR=" + URLEncoder.encode(pem, "UTF-8"));
         assertArrayEquals(new String[] {
-                "client", "testuser testname", "email:" + uniq + "@testdom.com\n", Digest.SHA512.toString()
+                "client", "a b", "email:" + email + "\n", Digest.SHA512.toString()
         }, res);
 
         HttpURLConnection huc = (HttpURLConnection) ncert.openConnection();
-        huc.setRequestProperty("Cookie", session);
+        huc.setRequestProperty("Cookie", cookie);
         huc.setDoOutput(true);
         OutputStream out = huc.getOutputStream();
         out.write(("csrf=" + URLEncoder.encode(csrf, "UTF-8")).getBytes());
-        out.write(("&profile=client&CN=testuser+testname&SANs=" + URLEncoder.encode("email:" + uniq + "@testdom.com\n", "UTF-8")).getBytes());
+        out.write(("&profile=client&CN=a+b&SANs=" + URLEncoder.encode("email:" + email + "\n", "UTF-8")).getBytes());
         out.write(("&hash_alg=SHA512&CCA=y").getBytes());
         URLConnection uc = authenticate(new URL(huc.getHeaderField("Location") + ".crt"));
         String crt = IOUtils.readURL(new InputStreamReader(uc.getInputStream(), "UTF-8"));
@@ -151,9 +146,9 @@ public class TestCertificateAdd extends ManagedTest {
         uc = authenticate(new URL(huc.getHeaderField("Location")));
         String gui = IOUtils.readURL(uc);
         assertThat(gui, containsString("clientAuth"));
-        assertThat(gui, containsString("CN=testuser testname"));
+        assertThat(gui, containsString("CN=a b"));
         assertThat(gui, containsString("SHA512withRSA"));
-        assertThat(gui, containsString("RFC822Name: " + uniq + "@testdom.com"));
+        assertThat(gui, containsString("RFC822Name: " + email));
 
     }
 
@@ -207,17 +202,17 @@ public class TestCertificateAdd extends ManagedTest {
     private X509Certificate createCertWithValidity(String validity) throws IOException, GeneralSecurityException, UnsupportedEncodingException, MalformedURLException, CertificateException {
         PKCS10Attributes atts = buildAtts(new ObjectIdentifier[] {
             CertificateIssueForm.OID_KEY_USAGE_SSL_CLIENT
-        }, new RFC822Name(uniq + "@testdom.com"));
+        }, new RFC822Name(email));
 
-        String pem = generatePEMCSR(kp, "CN=testuser testname", atts, "SHA512WithRSA");
+        String pem = generatePEMCSR(kp, "CN=a b", atts, "SHA512WithRSA");
         fillOutForm("CSR=" + URLEncoder.encode(pem, "UTF-8"));
 
         HttpURLConnection huc = (HttpURLConnection) ncert.openConnection();
-        huc.setRequestProperty("Cookie", session);
+        huc.setRequestProperty("Cookie", cookie);
         huc.setDoOutput(true);
         OutputStream out = huc.getOutputStream();
         out.write(("csrf=" + URLEncoder.encode(csrf, "UTF-8")).getBytes());
-        out.write(("&profile=client&CN=testuser+testname&SANs=" + URLEncoder.encode("email:" + uniq + "@testdom.com\n", "UTF-8")).getBytes());
+        out.write(("&profile=client&CN=a+b&SANs=" + URLEncoder.encode("email:" + email + "\n", "UTF-8")).getBytes());
         out.write(("&hash_alg=SHA512&CCA=y&").getBytes());
         out.write(validity.getBytes());
 
@@ -235,13 +230,13 @@ public class TestCertificateAdd extends ManagedTest {
 
     private URLConnection authenticate(URL url) throws IOException {
         URLConnection uc = url.openConnection();
-        uc.setRequestProperty("Cookie", session);
+        uc.setRequestProperty("Cookie", cookie);
         return uc;
     }
 
     protected String testSPKAC(boolean correctChallange) throws GeneralSecurityException, IOException {
         HttpURLConnection uc = (HttpURLConnection) ncert.openConnection();
-        uc.setRequestProperty("Cookie", session);
+        uc.setRequestProperty("Cookie", cookie);
         String s = IOUtils.readURL(uc);
 
         csrf = extractPattern(s, Pattern.compile("<input [^>]*name='csrf' [^>]*value='([^']*)'>"));
@@ -285,7 +280,7 @@ public class TestCertificateAdd extends ManagedTest {
 
     private String[] fillOutForm(String pem) throws IOException {
         HttpURLConnection uc = (HttpURLConnection) ncert.openConnection();
-        uc.setRequestProperty("Cookie", session);
+        uc.setRequestProperty("Cookie", cookie);
         csrf = getCSRF(uc);
         return fillOutFormDirect(pem);
 
@@ -294,7 +289,7 @@ public class TestCertificateAdd extends ManagedTest {
     private String[] fillOutFormDirect(String pem) throws IOException {
 
         HttpURLConnection uc = (HttpURLConnection) ncert.openConnection();
-        uc.setRequestProperty("Cookie", session);
+        uc.setRequestProperty("Cookie", cookie);
         uc.setDoOutput(true);
         uc.getOutputStream().write(("csrf=" + URLEncoder.encode(csrf, "UTF-8") + "&" + pem).getBytes());
         uc.getOutputStream().flush();
index 21be9c15113f343171ad17b457fc914b72d35ac9..89d318e6e54e06c89fd0b8105fb366d75e395759 100644 (file)
@@ -6,15 +6,10 @@ import java.io.IOException;
 import java.net.URLEncoder;
 
 import org.cacert.gigi.GigiApiException;
-import org.cacert.gigi.dbObjects.User;
-import org.cacert.gigi.testUtils.ManagedTest;
+import org.cacert.gigi.testUtils.ClientTest;
 import org.junit.Test;
 
-public class TestChangePassword extends ManagedTest {
-
-    User u = User.getById(createVerifiedUser("fn", "ln", createUniqueName() + "uni@example.org", TEST_PASSWORD));
-
-    String cookie;
+public class TestChangePassword extends ClientTest {
 
     String path = ChangePasswordPage.PATH;
 
index 6360578b42da418202fd4273fafa6e50b66dcaf4..c63e36d2b3d76866e521fdd7ce305ef111555cd1 100644 (file)
@@ -7,17 +7,14 @@ import java.io.IOException;
 import java.net.URL;
 import java.net.URLConnection;
 
+import org.cacert.gigi.testUtils.ClientTest;
 import org.cacert.gigi.testUtils.IOUtils;
-import org.cacert.gigi.testUtils.ManagedTest;
 import org.junit.Test;
 
-public class TestContactInformation extends ManagedTest {
+public class TestContactInformation extends ClientTest {
 
     @Test
     public void testDirectoryListingToggle() throws IOException {
-        String email = createUniqueName() + "@e.fg";
-        createVerifiedUser("Kurti", createUniqueName(), email, TEST_PASSWORD);
-        String cookie = login(email, TEST_PASSWORD);
         assertNull(executeBasicWebInteraction(cookie, MyDetails.PATH, "listme=1&contactinfo=&processContact", 1));
         URLConnection url = new URL("https://" + getServerName() + MyDetails.PATH).openConnection();
         url.setRequestProperty("Cookie", cookie);
@@ -34,9 +31,6 @@ public class TestContactInformation extends ManagedTest {
 
     @Test
     public void testContactinfoSet() throws IOException {
-        String email = createUniqueName() + "@e.fg";
-        createVerifiedUser("Kurti", createUniqueName(), email, TEST_PASSWORD);
-        String cookie = login(email, TEST_PASSWORD);
         String text = createUniqueName();
         assertNull(executeBasicWebInteraction(cookie, MyDetails.PATH, "listme=1&contactinfo=" + text + "&processContact", 1));
         URLConnection url = new URL("https://" + getServerName() + MyDetails.PATH).openConnection();
index faa9ac8b58e6a659e24dfd03e5dfba49cedde0d4..1a3a5a081f3cdbbeef92838061d739ec82073b3b 100644 (file)
@@ -5,23 +5,18 @@ import static org.junit.Assert.*;
 import java.io.IOException;
 import java.net.URLEncoder;
 
-import org.cacert.gigi.dbObjects.User;
 import org.cacert.gigi.pages.account.domain.DomainOverview;
-import org.cacert.gigi.testUtils.ManagedTest;
+import org.cacert.gigi.testUtils.ClientTest;
 import org.junit.Test;
 
-public class TestDomain extends ManagedTest {
-
-    User u = User.getById(createVerifiedUser("testuser", "testname", uniq + "@testdom.com", TEST_PASSWORD));
-
-    String session = login(uniq + "@testdom.com", TEST_PASSWORD);
+public class TestDomain extends ClientTest {
 
     public TestDomain() throws IOException {}
 
     @Test
     public void testAdd() throws IOException {
-        assertNull(addDomain(session, uniq + ".de"));
-        assertNotNull(addDomain(session, uniq + ".de"));
+        assertNull(addDomain(cookie, uniq + ".de"));
+        assertNotNull(addDomain(cookie, uniq + ".de"));
     }
 
     public static String addDomain(String session, String domain) throws IOException {
index 3d813ec981d857aa1728de40b6ea9bdaf8a5c8b2..6659a1e115cbacb5467aca7c3cbe8e75267ee8b0 100644 (file)
@@ -14,14 +14,10 @@ import org.cacert.gigi.dbObjects.ObjectCache;
 import org.cacert.gigi.dbObjects.User;
 import org.cacert.gigi.localisation.Language;
 import org.cacert.gigi.pages.account.mail.MailOverview;
-import org.cacert.gigi.testUtils.ManagedTest;
+import org.cacert.gigi.testUtils.ClientTest;
 import org.junit.Test;
 
-public class TestMailManagement extends ManagedTest {
-
-    private User u = User.getById(createVerifiedUser("fn", "ln", createUniqueName() + "uni@example.org", TEST_PASSWORD));
-
-    private String cookie;
+public class TestMailManagement extends ClientTest {
 
     private String path = MailOverview.DEFAULT_PATH;
 
index 2623fa020ac85b3fa61f810087d8049a16c8489c..f0a07a801d39e24ff8c2d912834c36061385000e 100644 (file)
@@ -14,25 +14,21 @@ import org.cacert.gigi.dbObjects.Group;
 import org.cacert.gigi.dbObjects.Organisation;
 import org.cacert.gigi.dbObjects.Organisation.Affiliation;
 import org.cacert.gigi.dbObjects.User;
+import org.cacert.gigi.testUtils.ClientTest;
 import org.cacert.gigi.testUtils.IOUtils;
-import org.cacert.gigi.testUtils.ManagedTest;
 import org.junit.Test;
 
-public class TestOrgaManagement extends ManagedTest {
-
-    public User u = User.getById(createVerifiedUser("testuser", "testname", uniq + "@testdom.com", TEST_PASSWORD));
-
-    public String session;
+public class TestOrgaManagement extends ClientTest {
 
     public TestOrgaManagement() throws IOException {
         u.grantGroup(u, Group.getByString("orgassurer"));
         clearCaches();
-        session = login(uniq + "@testdom.com", TEST_PASSWORD);
+        cookie = login(email, TEST_PASSWORD);
     }
 
     @Test
     public void testAdd() throws IOException {
-        executeBasicWebInteraction(session, CreateOrgPage.DEFAULT_PATH, "O=name&contact=mail&L=K%C3%B6ln&ST=%C3%9C%C3%96%C3%84%C3%9F&C=DE&comments=jkl%C3%B6loiuzfdfgjlh%C3%B6", 0);
+        executeBasicWebInteraction(cookie, CreateOrgPage.DEFAULT_PATH, "O=name&contact=mail&L=K%C3%B6ln&ST=%C3%9C%C3%96%C3%84%C3%9F&C=DE&comments=jkl%C3%B6loiuzfdfgjlh%C3%B6", 0);
         Organisation[] orgs = Organisation.getOrganisations(0, 30);
         assertEquals(1, orgs.length);
         assertEquals("mail", orgs[0].getContactEmail());
@@ -41,14 +37,14 @@ public class TestOrgaManagement extends ManagedTest {
         assertEquals("ÜÖÄß", orgs[0].getProvince());
 
         User u2 = User.getById(createVerifiedUser("testworker", "testname", createUniqueName() + "@testdom.com", TEST_PASSWORD));
-        executeBasicWebInteraction(session, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "email=" + URLEncoder.encode(u2.getEmail(), "UTF-8") + "&do_affiliate=y&master=y", 1);
+        executeBasicWebInteraction(cookie, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "email=" + URLEncoder.encode(u2.getEmail(), "UTF-8") + "&do_affiliate=y&master=y", 1);
         List<Affiliation> allAdmins = orgs[0].getAllAdmins();
         assertEquals(1, allAdmins.size());
         Affiliation affiliation = allAdmins.get(0);
         assertSame(u2, affiliation.getTarget());
         assertTrue(affiliation.isMaster());
 
-        executeBasicWebInteraction(session, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "email=" + URLEncoder.encode(u.getEmail(), "UTF-8") + "&do_affiliate=y", 1);
+        executeBasicWebInteraction(cookie, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "email=" + URLEncoder.encode(u.getEmail(), "UTF-8") + "&do_affiliate=y", 1);
         allAdmins = orgs[0].getAllAdmins();
         assertEquals(2, allAdmins.size());
         Affiliation affiliation2 = allAdmins.get(0);
@@ -58,13 +54,13 @@ public class TestOrgaManagement extends ManagedTest {
         assertSame(u.getId(), affiliation2.getTarget().getId());
         assertFalse(affiliation2.isMaster());
 
-        executeBasicWebInteraction(session, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "del=" + URLEncoder.encode(u.getEmail(), "UTF-8") + "&email=&do_affiliate=y", 1);
+        executeBasicWebInteraction(cookie, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "del=" + URLEncoder.encode(u.getEmail(), "UTF-8") + "&email=&do_affiliate=y", 1);
         assertEquals(1, orgs[0].getAllAdmins().size());
 
-        executeBasicWebInteraction(session, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "del=" + URLEncoder.encode(u2.getEmail(), "UTF-8") + "&email=&do_affiliate=y", 1);
+        executeBasicWebInteraction(cookie, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "del=" + URLEncoder.encode(u2.getEmail(), "UTF-8") + "&email=&do_affiliate=y", 1);
         assertEquals(0, orgs[0].getAllAdmins().size());
 
-        executeBasicWebInteraction(session, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "O=name1&contact=&L=K%C3%B6ln&ST=%C3%9C%C3%96%C3%84%C3%9F&C=DE&comments=jkl%C3%B6loiuzfdfgjlh%C3%B6", 0);
+        executeBasicWebInteraction(cookie, ViewOrgPage.DEFAULT_PATH + "/" + orgs[0].getId(), "O=name1&contact=&L=K%C3%B6ln&ST=%C3%9C%C3%96%C3%84%C3%9F&C=DE&comments=jkl%C3%B6loiuzfdfgjlh%C3%B6", 0);
         clearCaches();
         orgs = Organisation.getOrganisations(0, 30);
         assertEquals("name1", orgs[0].getName());
@@ -89,13 +85,13 @@ public class TestOrgaManagement extends ManagedTest {
         assertEquals(404, ((HttpURLConnection) uc).getResponseCode());
 
         uc = new URL("https://" + getServerName() + ViewOrgPage.DEFAULT_PATH).openConnection();
-        uc.addRequestProperty("Cookie", session);
+        uc.addRequestProperty("Cookie", cookie);
         content = IOUtils.readURL(uc);
         assertThat(content, containsString("name21"));
         assertThat(content, containsString("name12"));
-        uc = cookie(new URL("https://" + getServerName() + ViewOrgPage.DEFAULT_PATH + "/" + o1.getId()).openConnection(), session);
+        uc = cookie(new URL("https://" + getServerName() + ViewOrgPage.DEFAULT_PATH + "/" + o1.getId()).openConnection(), cookie);
         assertEquals(200, ((HttpURLConnection) uc).getResponseCode());
-        uc = cookie(new URL("https://" + getServerName() + ViewOrgPage.DEFAULT_PATH + "/" + o2.getId()).openConnection(), session);
+        uc = cookie(new URL("https://" + getServerName() + ViewOrgPage.DEFAULT_PATH + "/" + o2.getId()).openConnection(), cookie);
         assertEquals(200, ((HttpURLConnection) uc).getResponseCode());
         o1.delete();
         o2.delete();
index 9f5aae30477202161d72d4769279c00bf6ee7e7e..7c8884ba8c22acb8a6952af95ac0fdabc5119301 100644 (file)
@@ -10,15 +10,11 @@ import org.cacert.gigi.GigiApiException;
 import org.cacert.gigi.dbObjects.Group;
 import org.cacert.gigi.dbObjects.ObjectCache;
 import org.cacert.gigi.dbObjects.User;
+import org.cacert.gigi.testUtils.ClientTest;
 import org.cacert.gigi.testUtils.IOUtils;
-import org.cacert.gigi.testUtils.ManagedTest;
 import org.junit.Test;
 
-public class TestTTP extends ManagedTest {
-
-    User u = User.getById(createVerifiedUser("fn", "ln", "test-" + createUniqueName() + "@example.org", TEST_PASSWORD));
-
-    String cookie = login(u.getEmail(), TEST_PASSWORD);
+public class TestTTP extends ClientTest {
 
     URL ttpPage = new URL("https://" + getServerName() + RequestTTPPage.PATH);
 
index b1cbf9aba6625e1349eaf435bc2ed51fa58648fe..32c4268afc120846f613a5a72d07917b9953e824 100644 (file)
@@ -10,21 +10,14 @@ import java.net.URL;
 import org.cacert.gigi.dbObjects.Group;
 import org.cacert.gigi.dbObjects.User;
 import org.cacert.gigi.pages.admin.TTPAdminPage;
-import org.cacert.gigi.testUtils.ManagedTest;
+import org.cacert.gigi.testUtils.ClientTest;
 import org.junit.Test;
 
-public class TestTTPAdmin extends ManagedTest {
-
-    User us;
-
-    String cookie;
+public class TestTTPAdmin extends ClientTest {
 
     User us2;
 
     public TestTTPAdmin() throws IOException {
-        String email = uniq + "@example.com";
-        us = User.getById(createVerifiedUser("fn", "ln", email, TEST_PASSWORD));
-        cookie = login(email, TEST_PASSWORD);
         us2 = User.getById(createVerifiedUser("fn", "ln", createUniqueName() + "@example.com", TEST_PASSWORD));
     }
 
@@ -40,14 +33,14 @@ public class TestTTPAdmin extends ManagedTest {
 
     public void testTTPAdmin(boolean hasRight) throws IOException {
         if (hasRight) {
-            grant(us.getEmail(), Group.getByString("ttp-assurer"));
+            grant(email, Group.getByString("ttp-assurer"));
         }
-        grant(us.getEmail(), TTPAdminPage.TTP_APPLICANT);
-        cookie = login(us.getEmail(), TEST_PASSWORD);
+        grant(u.getEmail(), TTPAdminPage.TTP_APPLICANT);
+        cookie = login(u.getEmail(), TEST_PASSWORD);
 
         assertEquals( !hasRight ? 403 : 200, fetchStatusCode("https://" + getServerName() + TTPAdminPage.PATH));
         assertEquals( !hasRight ? 403 : 200, fetchStatusCode("https://" + getServerName() + TTPAdminPage.PATH + "/"));
-        assertEquals( !hasRight ? 403 : 200, fetchStatusCode("https://" + getServerName() + TTPAdminPage.PATH + "/" + us.getId()));
+        assertEquals( !hasRight ? 403 : 200, fetchStatusCode("https://" + getServerName() + TTPAdminPage.PATH + "/" + u.getId()));
         assertEquals( !hasRight ? 403 : 404, fetchStatusCode("https://" + getServerName() + TTPAdminPage.PATH + "/" + us2.getId()));
         assertEquals( !hasRight ? 403 : 404, fetchStatusCode("https://" + getServerName() + TTPAdminPage.PATH + "/" + 100));
     }
index 007d570b435b6ff32e15420f209610cb47d94c5b..610e11536700513835604187bdce687a96dd0c0d 100644 (file)
@@ -139,7 +139,7 @@ public class TestSSL extends PingTest {
     private void createCertificate(String test, CertificateProfile profile) throws GeneralSecurityException, IOException, SQLException, InterruptedException, GigiApiException {
         kp = generateKeypair();
         String csr = generatePEMCSR(kp, "CN=" + test);
-        c = new Certificate(User.getById(userid), Certificate.buildDN("CN", test), "sha256", csr, CSRType.CSR, profile);
+        c = new Certificate(User.getById(id), Certificate.buildDN("CN", test), "sha256", csr, CSRType.CSR, profile);
         c.issue(null, "2y").waitFor(60000);
     }
 
index ab88844f07c218f380179d05fae87f3d9a9d6003..fc22e6d086bc58399c3463e30aa237f8db32a94d 100644 (file)
@@ -2,15 +2,33 @@ package org.cacert.gigi.testUtils;
 
 import java.io.IOException;
 
+import org.cacert.gigi.dbObjects.User;
+
+/**
+ * Superclass for testsuites in a scenario where there is an registered member,
+ * who is already logged on.
+ */
 public abstract class ClientTest extends ManagedTest {
 
+    /**
+     * Email of the member.
+     */
     protected String email = createUniqueName() + "@example.org";
 
-    protected int userid = createVerifiedUser("a", "b", email, TEST_PASSWORD);
+    /**
+     * Id of the member
+     */
+    protected int id = createVerifiedUser("a", "b", email, TEST_PASSWORD);
 
-    protected String cookie;
+    /**
+     * {@link User} object of the member
+     */
+    protected User u = User.getById(id);
 
-    protected String csrf;
+    /**
+     * Session cookie of the member.
+     */
+    protected String cookie;
 
     public ClientTest() {
         try {
index a6bbed85be7c6684a6dfabeaaa3370f952aecd96..97b8823b7888c96add41158c13c9a612864eff43 100644 (file)
@@ -20,7 +20,11 @@ import sun.security.pkcs10.PKCS10;
 import sun.security.pkcs10.PKCS10Attributes;
 import sun.security.x509.X500Name;
 
-public class ConfiguredTest {
+/**
+ * Base class for a Testsuite that makes use of the config variables that define
+ * the environment.
+ */
+public abstract class ConfiguredTest {
 
     static Properties testProps = new Properties();
 
index c0c8ad49275843b94aa64ac1de90b78780c53bd7..ce96cf2894497caac41c31b93f710856e973dcb1 100644 (file)
@@ -55,6 +55,10 @@ import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 
+/**
+ * Base class for test suites who require a launched Gigi instance. The instance
+ * is cleared once per test suite.
+ */
 public class ManagedTest extends ConfiguredTest {
 
     static {
@@ -62,7 +66,7 @@ public class ManagedTest extends ConfiguredTest {
     }
 
     /**
-     * Some password that fullfills the password criteria.
+     * Some password that fulfills the password criteria.
      */
     protected static final String TEST_PASSWORD = "xvXV12°§";
 
index 50d5d7fc14696a97692c39e8fb85b35ec8feb9ed..4fb49595c316e84a5e9452f14bd6ebb7e82fd991 100644 (file)
@@ -18,8 +18,14 @@ import org.cacert.gigi.database.GigiResultSet;
 import org.cacert.gigi.pages.account.domain.DomainOverview;
 import org.junit.After;
 
+/**
+ * Base class for test suites that check extensively if the domain-ping
+ * functionality wroks as expected.
+ */
 public abstract class PingTest extends ClientTest {
 
+    protected String csrf;
+
     protected static void updateService(String token, String value, String action) throws IOException, MalformedURLException {
         String manage = getTestProps().getProperty("domain.manage");
         assumeNotNull(manage);