]> WPIA git - gigi.git/commitdiff
upd: redesign of find cert result page
authorINOPIAE <m.maengel@inopiae.de>
Wed, 9 Oct 2019 08:49:08 +0000 (10:49 +0200)
committerINOPIAE <m.maengel@inopiae.de>
Thu, 19 Mar 2020 05:36:26 +0000 (06:36 +0100)
The column id is removed and if a certificate is in draft status draft
is displayed instead of the missing serial number

Change-Id: I14232ae6201631efce1ccdd3185b4e739980889f

src/club/wpia/gigi/pages/admin/support/FindCertPage.java
src/club/wpia/gigi/pages/admin/support/FindCertPage.templ
tests/club/wpia/gigi/pages/admin/TestSEAdminPageCertSearch.java

index ea5ac1e9d8924ef512cf50103444f4919506b9d5..19064a66882f16fbbd97d60a3e59b6e694808f68 100644 (file)
@@ -57,8 +57,8 @@ public class FindCertPage extends Page {
 
                     @Override
                     public void apply(Certificate t, Language l, Map<String, Object> vars) {
-                        vars.put("id", t.getId());
                         vars.put("serial", t.getSerial());
+                        vars.put("draftinfo", t.getStatus() == CertificateStatus.DRAFT ? l.getTranslation("Draft") : "");
 
                         if (t.getStatus() == CertificateStatus.REVOKED) {
                             vars.put("revoked", t.getRevocationDate());
index 0e0fa25b0123e524fec64d6e792f8f789bf9f0d9..1648f0dd2c0bffd17b13ed1853eb23e546a51989 100644 (file)
@@ -1,11 +1,10 @@
 <p><?=_Multiple certificates?>: <?=$limit?></p>
 <table class="table">
 <tr>
-<th>Id</th><th><?=_Serial number?></th><th><?=_SAN?></th><th><?=_Revocation Date?></th></tr>
+<th><?=_Serial number?></th><th><?=_SAN?></th><th><?=_Revocation Date?></th></tr>
 <? foreach($certtable) {?>
   <tr>
-    <td><a href="/support/certs/<?=$serial?>"><?=$id?></a></td>
-    <td><a href="/support/certs/<?=$serial?>"><?=$serial?></a></td>
+    <td><a href="/support/certs/<?=$serial?>"><?=$serial?></a> <?=$draftinfo?></td>
     <td>
     <? foreach($san) {?>
        <?=$entry?>
index cf9b403b253aa6438b7c38f0483e39832b0120ae..0d556419bbdd8095139b60928eda63925bce1f39 100644 (file)
@@ -1,5 +1,6 @@
 package club.wpia.gigi.pages.admin;
 
+import static org.hamcrest.CoreMatchers.*;
 import static org.junit.Assert.*;
 
 import java.io.IOException;
@@ -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();