]> WPIA git - gigi.git/blobdiff - tests/org/cacert/gigi/TestCertificate.java
Move the "dbObject"s to their own package.
[gigi.git] / tests / org / cacert / gigi / TestCertificate.java
index d14d0487f435616b67a180974f6a1c2e43c9fc1a..c9ada28899711068f748f625e74ac8f728b932f9 100644 (file)
@@ -9,10 +9,12 @@ import java.sql.SQLException;
 import java.util.Collection;
 import java.util.List;
 
-import org.cacert.gigi.Certificate.CSRType;
-import org.cacert.gigi.Certificate.CertificateStatus;
-import org.cacert.gigi.Certificate.SANType;
-import org.cacert.gigi.Certificate.SubjectAlternateName;
+import org.cacert.gigi.dbObjects.Certificate;
+import org.cacert.gigi.dbObjects.CertificateProfile;
+import org.cacert.gigi.dbObjects.Certificate.CSRType;
+import org.cacert.gigi.dbObjects.Certificate.CertificateStatus;
+import org.cacert.gigi.dbObjects.Certificate.SANType;
+import org.cacert.gigi.dbObjects.Certificate.SubjectAlternateName;
 import org.cacert.gigi.testUtils.ManagedTest;
 import org.junit.Test;
 
@@ -22,25 +24,25 @@ import static org.junit.Assert.*;
 public class TestCertificate extends ManagedTest {
 
     @Test
-    public void testClientCertLoginStates() throws IOException, GeneralSecurityException, SQLException, InterruptedException {
+    public void testClientCertLoginStates() throws IOException, GeneralSecurityException, SQLException, InterruptedException, GigiApiException {
         KeyPair kp = generateKeypair();
         String key1 = generatePEMCSR(kp, "CN=testmail@example.com");
         Certificate c = new Certificate(1, "/CN=testmail@example.com", "sha256", key1, CSRType.CSR, CertificateProfile.getById(1));
         final PrivateKey pk = kp.getPrivate();
-        c.issue().waitFor(60000);
+        c.issue(null, "2y").waitFor(60000);
         final X509Certificate ce = c.cert();
         assertNotNull(login(pk, ce));
     }
 
     @Test
-    public void testSANs() throws IOException, GeneralSecurityException, SQLException, InterruptedException {
+    public void testSANs() throws IOException, GeneralSecurityException, SQLException, InterruptedException, GigiApiException {
         KeyPair kp = generateKeypair();
         String key = generatePEMCSR(kp, "CN=testmail@example.com");
         Certificate c = new Certificate(1, "/CN=testmail@example.com", "sha256", key, CSRType.CSR, CertificateProfile.getById(1),//
                 new SubjectAlternateName(SANType.EMAIL, "testmail@example.com"), new SubjectAlternateName(SANType.DNS, "testmail.example.com"));
 
         testFails(CertificateStatus.DRAFT, c);
-        c.issue().waitFor(60000);
+        c.issue(null, "2y").waitFor(60000);
         X509Certificate cert = c.cert();
         Collection<List<?>> sans = cert.getSubjectAlternativeNames();
         assertEquals(2, sans.size());
@@ -84,14 +86,14 @@ public class TestCertificate extends ManagedTest {
     }
 
     @Test
-    public void testCertLifeCycle() throws IOException, GeneralSecurityException, SQLException, InterruptedException {
+    public void testCertLifeCycle() throws IOException, GeneralSecurityException, SQLException, InterruptedException, GigiApiException {
         KeyPair kp = generateKeypair();
         String key = generatePEMCSR(kp, "CN=testmail@example.com");
         Certificate c = new Certificate(1, "/CN=testmail@example.com", "sha256", key, CSRType.CSR, CertificateProfile.getById(1));
         final PrivateKey pk = kp.getPrivate();
 
         testFails(CertificateStatus.DRAFT, c);
-        c.issue().waitFor(60000);
+        c.issue(null, "2y").waitFor(60000);
 
         testFails(CertificateStatus.ISSUED, c);
         X509Certificate cert = c.cert();
@@ -103,7 +105,7 @@ public class TestCertificate extends ManagedTest {
 
     }
 
-    private void testFails(CertificateStatus status, Certificate c) throws IOException, GeneralSecurityException, SQLException {
+    private void testFails(CertificateStatus status, Certificate c) throws IOException, GeneralSecurityException, SQLException, GigiApiException {
         assertEquals(status, c.getStatus());
         if (status != CertificateStatus.ISSUED) {
             try {
@@ -115,7 +117,7 @@ public class TestCertificate extends ManagedTest {
         }
         if (status != CertificateStatus.DRAFT) {
             try {
-                c.issue();
+                c.issue(null, "2y");
                 fail(status + " is in invalid state");
             } catch (IllegalStateException ise) {