]> WPIA git - gigi.git/blobdiff - tests/org/cacert/gigi/TestSeparateSessionScope.java
upd: factor out default client certificate profile
[gigi.git] / tests / org / cacert / gigi / TestSeparateSessionScope.java
index 9d2ff10c411ed21bfd67eb4ea5d692f5566f6fbc..9ace036ea78e02f03a62cf77d1ba9577169c9dd4 100644 (file)
@@ -15,7 +15,6 @@ import java.sql.SQLException;
 
 import org.cacert.gigi.dbObjects.Certificate;
 import org.cacert.gigi.dbObjects.Certificate.CSRType;
-import org.cacert.gigi.dbObjects.CertificateProfile;
 import org.cacert.gigi.dbObjects.Digest;
 import org.cacert.gigi.dbObjects.Job;
 import org.cacert.gigi.dbObjects.User;
@@ -32,10 +31,11 @@ public class TestSeparateSessionScope extends ManagedTest {
         KeyPair kp = generateKeypair();
         String csr = generatePEMCSR(kp, "CN=hans");
         User u = User.getById(user);
-        Certificate c = new Certificate(u, u, Certificate.buildDN("CN", "hans"), Digest.SHA256, csr, CSRType.CSR, CertificateProfile.getById(1));
+        Certificate c = new Certificate(u, u, Certificate.buildDN("CN", "hans"), Digest.SHA256, csr, CSRType.CSR, getClientProfile());
         final PrivateKey pk = kp.getPrivate();
-        c.issue(null, "2y", u).waitFor(60000);
+        await(c.issue(null, "2y", u));
         final X509Certificate ce = c.cert();
+        c.setLoginEnabled(true);
         String scookie = login(pk, ce);
 
         assertTrue(isLoggedin(cookie));
@@ -52,13 +52,14 @@ public class TestSeparateSessionScope extends ManagedTest {
         KeyPair kp = generateKeypair();
         String csr = generatePEMCSR(kp, "CN=hans");
         User u = User.getById(user);
-        Certificate c = new Certificate(u, u, Certificate.buildDN("CN", "hans"), Digest.SHA256, csr, CSRType.CSR, CertificateProfile.getById(1));
-        Certificate c2 = new Certificate(u, u, Certificate.buildDN("CN", "hans"), Digest.SHA256, csr, CSRType.CSR, CertificateProfile.getById(1));
+        Certificate c = new Certificate(u, u, Certificate.buildDN("CN", "hans"), Digest.SHA256, csr, CSRType.CSR, getClientProfile());
+        Certificate c2 = new Certificate(u, u, Certificate.buildDN("CN", "hans"), Digest.SHA256, csr, CSRType.CSR, getClientProfile());
         final PrivateKey pk = kp.getPrivate();
         Job j1 = c.issue(null, "2y", u);
-        c2.issue(null, "2y", u).waitFor(60000);
-        j1.waitFor(60000);
+        await(c2.issue(null, "2y", u));
+        await(j1);
         final X509Certificate ce = c.cert();
+        c.setLoginEnabled(true);
         String scookie = login(pk, ce);
 
         checkCertLogin(c, pk, scookie, 200);
@@ -68,7 +69,7 @@ public class TestSeparateSessionScope extends ManagedTest {
     }
 
     private void checkCertLogin(Certificate c2, final PrivateKey pk, String scookie, int expected) throws IOException, NoSuchAlgorithmException, KeyManagementException, GeneralSecurityException {
-        URL u = new URL("https://" + getServerName().replaceAll("^www", "secure") + SECURE_REFERENCE);
+        URL u = new URL("https://" + getSecureServerName() + SECURE_REFERENCE);
         HttpURLConnection huc = (HttpURLConnection) u.openConnection();
         authenticateClientCert(pk, c2.cert(), huc);
         huc.setRequestProperty("Cookie", scookie);