X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=tests%2Fclub%2Fwpia%2Fgigi%2FdbObjects%2FTestCertificate.java;h=0b4d6549d962ceb255ad924d3622a74ac6f3c021;hp=694bc491c8f514550664419d54528cecf9273b72;hb=e19697179fb3d680062918e011f41e1d89e31778;hpb=c4c60e1b9446e5ab69b8431ce71a2fbe11d47ef5 diff --git a/tests/club/wpia/gigi/dbObjects/TestCertificate.java b/tests/club/wpia/gigi/dbObjects/TestCertificate.java index 694bc491..0b4d6549 100644 --- a/tests/club/wpia/gigi/dbObjects/TestCertificate.java +++ b/tests/club/wpia/gigi/dbObjects/TestCertificate.java @@ -38,10 +38,7 @@ public class TestCertificate extends ClientBusinessTest { 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()); assertNull(c.getAttachment(AttachmentType.CRT)); - assertNull(c.getAttachment(AttachmentType.CSR)); - c.addAttachment(AttachmentType.CSR, "a"); - assertNull(c.getAttachment(AttachmentType.CRT)); - assertEquals("a", c.getAttachment(AttachmentType.CSR)); + assertEquals(key, c.getAttachment(AttachmentType.CSR)); try { c.addAttachment(AttachmentType.CSR, "different CSR"); fail("double add attachment must fail"); @@ -49,7 +46,7 @@ public class TestCertificate extends ClientBusinessTest { // expected } assertNull(c.getAttachment(AttachmentType.CRT)); - assertEquals("a", c.getAttachment(AttachmentType.CSR)); + assertEquals(key, c.getAttachment(AttachmentType.CSR)); try { c.addAttachment(AttachmentType.CRT, null); fail("attachment must not be null"); @@ -57,9 +54,9 @@ public class TestCertificate extends ClientBusinessTest { // expected } assertNull(c.getAttachment(AttachmentType.CRT)); - assertEquals("a", c.getAttachment(AttachmentType.CSR)); + assertEquals(key, c.getAttachment(AttachmentType.CSR)); c.addAttachment(AttachmentType.CRT, "b"); - assertEquals("a", c.getAttachment(AttachmentType.CSR)); + assertEquals(key, c.getAttachment(AttachmentType.CSR)); assertEquals("b", c.getAttachment(AttachmentType.CRT)); try { c.addAttachment(AttachmentType.CRT, "different CRT"); @@ -67,7 +64,17 @@ public class TestCertificate extends ClientBusinessTest { } catch (GigiApiException e) { // expected } - assertEquals("a", c.getAttachment(AttachmentType.CSR)); + assertEquals(key, c.getAttachment(AttachmentType.CSR)); assertEquals("b", c.getAttachment(AttachmentType.CRT)); } + + @Test + public void testActor() throws GeneralSecurityException, IOException, 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()); + + assertEquals(u, c.getActor()); + assertEquals("AB", c.getActor().getInitials()); + } }