X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=tests%2Fclub%2Fwpia%2Fgigi%2Fpages%2Fadmin%2FTestSEAdminPageCertSearch.java;h=0d556419bbdd8095139b60928eda63925bce1f39;hp=74375f2f500c933baeceaa2f9c5d1a9616dd6b0a;hb=374e616d077431214c8128e3bf5ac3045a088aae;hpb=8818e81eee23a66ef6c9cc5d056bc25c79234274 diff --git a/tests/club/wpia/gigi/pages/admin/TestSEAdminPageCertSearch.java b/tests/club/wpia/gigi/pages/admin/TestSEAdminPageCertSearch.java index 74375f2f..0d556419 100644 --- a/tests/club/wpia/gigi/pages/admin/TestSEAdminPageCertSearch.java +++ b/tests/club/wpia/gigi/pages/admin/TestSEAdminPageCertSearch.java @@ -1,5 +1,6 @@ package club.wpia.gigi.pages.admin; +import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; import java.io.IOException; @@ -46,13 +47,13 @@ public class TestSEAdminPageCertSearch extends SEClientTest { @Test public void testSerialSearch() throws IOException { URLConnection uc = post(cookie, FindCertPage.PATH, "certType=serial&process=Next&cert=" + c.getSerial(), 0); - assertEquals("https://" + ServerConstants.getHostNamePortSecure(Host.WWW) + Certificates.SUPPORT_PATH + "/" + c.getSerial(), uc.getHeaderField("Location")); + assertEquals("https://" + ServerConstants.getHostNamePortSecure(Host.SECURE) + Certificates.SUPPORT_PATH + "/" + c.getSerial(), uc.getHeaderField("Location")); } @Test public void testEmailSearch() throws IOException { URLConnection uc = post(cookie, FindCertPage.PATH, "certType=email&process=Next&cert=" + URLEncoder.encode(certMail, "UTF-8"), 0); - assertEquals("https://" + ServerConstants.getHostNamePortSecure(Host.WWW) + Certificates.SUPPORT_PATH + "/" + c.getSerial(), uc.getHeaderField("Location")); + assertEquals("https://" + ServerConstants.getHostNamePortSecure(Host.SECURE) + Certificates.SUPPORT_PATH + "/" + c.getSerial(), uc.getHeaderField("Location")); } @Test @@ -67,7 +68,7 @@ public class TestSEAdminPageCertSearch extends SEClientTest { @Test 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")); + assertEquals("https://" + ServerConstants.getHostNamePortSecure(Host.SECURE) + Certificates.SUPPORT_PATH + "/" + c.getSerial(), conn.getHeaderField("Location")); for (int i = 0; i < 2; i++) { TestMail tm = getMailReceiver().receive(i == 0 ? ServerConstants.getSupportMailAddress() : certMail); assertThat(tm.getMessage(), CoreMatchers.containsString(certMail)); @@ -89,6 +90,24 @@ public class TestSEAdminPageCertSearch extends SEClientTest { assertThat(result, CoreMatchers.containsString("N/A")); } + @Test + public void testShowDraft() throws GeneralSecurityException, IOException, GigiApiException, InterruptedException { + KeyPair kp = generateKeypair(); + String key = generatePEMCSR(kp, "CN=" + certMail); + Certificate c1 = new Certificate(u, u, Certificate.buildDN("CN", certMail), Digest.SHA512, key, CSRType.CSR, getClientProfile(), new Certificate.SubjectAlternateName(SANType.EMAIL, certMail)); + URLConnection uc = post(cookie, FindCertPage.PATH, "certType=email&process=Next&cert=" + URLEncoder.encode(certMail, "UTF-8"), 0); + String result = IOUtils.readURL(uc); + assertThat(result, CoreMatchers.containsString(c.getSerial())); + assertThat(result, CoreMatchers.containsString("Draft")); + + await(c1.issue(null, "2y", u)); + uc = post(cookie, FindCertPage.PATH, "certType=email&process=Next&cert=" + URLEncoder.encode(certMail, "UTF-8"), 0); + result = IOUtils.readURL(uc); + assertThat(result, CoreMatchers.containsString(c.getSerial())); + assertThat(result, CoreMatchers.containsString(c1.getSerial())); + assertThat(result, not(CoreMatchers.containsString("Draft"))); + } + private Certificate createCertificate() throws GeneralSecurityException, IOException, GigiApiException, InterruptedException { User u1 = User.getById(id); KeyPair kp = generateKeypair();