From 670aa0f2424a50435ca443a7126bed23280d7dfa Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Fri, 13 Jan 2023 16:06:34 +0100 Subject: [PATCH] Add test for dearmoring and armoring certificate --- .../ExternalArmorDearmorRoundTripTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/external-sop/src/test/java/sop/external/ExternalArmorDearmorRoundTripTest.java b/external-sop/src/test/java/sop/external/ExternalArmorDearmorRoundTripTest.java index 0a4dbdf..7763842 100644 --- a/external-sop/src/test/java/sop/external/ExternalArmorDearmorRoundTripTest.java +++ b/external-sop/src/test/java/sop/external/ExternalArmorDearmorRoundTripTest.java @@ -19,6 +19,8 @@ public class ExternalArmorDearmorRoundTripTest extends AbstractExternalSOPTest { private static final String BEGIN_PGP_PRIVATE_KEY_BLOCK = "-----BEGIN PGP PRIVATE KEY BLOCK-----\n"; private static final byte[] BEGIN_PGP_PRIVATE_KEY_BLOCK_BYTES = BEGIN_PGP_PRIVATE_KEY_BLOCK.getBytes(StandardCharsets.UTF_8); + private static final String BEGIN_PGP_PUBLIC_KEY_BLOCK = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n"; + private static final byte[] BEGIN_PGP_PUBLIC_KEY_BLOCK_BYTES = BEGIN_PGP_PUBLIC_KEY_BLOCK.getBytes(StandardCharsets.UTF_8); @Test public void dearmorArmorAliceKey() throws IOException { @@ -36,4 +38,22 @@ public class ExternalArmorDearmorRoundTripTest extends AbstractExternalSOPTest { assertArrayStartsWith(armored, BEGIN_PGP_PRIVATE_KEY_BLOCK_BYTES); } + + + @Test + public void dearmorArmorAliceCert() throws IOException { + byte[] aliceCert = TestKeys.ALICE_CERT.getBytes(StandardCharsets.UTF_8); + + byte[] dearmored = getSop().dearmor() + .data(aliceCert) + .getBytes(); + + assertFalse(arrayStartsWith(dearmored, BEGIN_PGP_PUBLIC_KEY_BLOCK_BYTES)); + + byte[] armored = getSop().armor() + .data(dearmored) + .getBytes(); + + assertArrayStartsWith(armored, BEGIN_PGP_PUBLIC_KEY_BLOCK_BYTES); + } }