+ testFails(CertificateStatus.ISSUED, c);
+
+ Certificate c2 = Certificate.getBySerial(c.getSerial());
+ assertNotNull(c2);
+ assertEquals(2, c2.getSANs().size());
+ assertEquals(c.getSANs().get(0).getName(), c2.getSANs().get(0).getName());
+ assertEquals(c.getSANs().get(0).getType(), c2.getSANs().get(0).getType());
+ assertEquals(c.getSANs().get(1).getName(), c2.getSANs().get(1).getName());
+ assertEquals(c.getSANs().get(1).getType(), c2.getSANs().get(1).getType());
+
+ try {
+ c2.getSANs().remove(0);
+ fail("the list should not be modifiable");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testCertLifeCycle() throws IOException, GeneralSecurityException, SQLException, InterruptedException, GigiApiException {
+ KeyPair kp = generateKeypair();
+ String key = generatePEMCSR(kp, "CN=testmail@example.com");
+ Certificate c = new Certificate(u, u, Certificate.buildDN("CN", "testmail@example.com"), Digest.SHA256, key, CSRType.CSR, getClientProfile());
+ final PrivateKey pk = kp.getPrivate();
+
+ testFails(CertificateStatus.DRAFT, c);
+ await(c.issue(null, "2y", u));
+
+ String cookie = login(u.getEmail(), TEST_PASSWORD);