From 374e616d077431214c8128e3bf5ac3045a088aae Mon Sep 17 00:00:00 2001 From: INOPIAE Date: Wed, 9 Oct 2019 10:49:08 +0200 Subject: [PATCH 1/1] upd: redesign of find cert result page 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 --- .../pages/admin/support/FindCertPage.java | 2 +- .../pages/admin/support/FindCertPage.templ | 5 ++--- .../admin/TestSEAdminPageCertSearch.java | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/club/wpia/gigi/pages/admin/support/FindCertPage.java b/src/club/wpia/gigi/pages/admin/support/FindCertPage.java index ea5ac1e9..19064a66 100644 --- a/src/club/wpia/gigi/pages/admin/support/FindCertPage.java +++ b/src/club/wpia/gigi/pages/admin/support/FindCertPage.java @@ -57,8 +57,8 @@ public class FindCertPage extends Page { @Override public void apply(Certificate t, Language l, Map 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()); diff --git a/src/club/wpia/gigi/pages/admin/support/FindCertPage.templ b/src/club/wpia/gigi/pages/admin/support/FindCertPage.templ index 0e0fa25b..1648f0dd 100644 --- a/src/club/wpia/gigi/pages/admin/support/FindCertPage.templ +++ b/src/club/wpia/gigi/pages/admin/support/FindCertPage.templ @@ -1,11 +1,10 @@

:

- + - - +
Id
diff --git a/tests/club/wpia/gigi/pages/admin/TestSEAdminPageCertSearch.java b/tests/club/wpia/gigi/pages/admin/TestSEAdminPageCertSearch.java index cf9b403b..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; @@ -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(); -- 2.39.2