Add test for dearmoring and armoring certificate

This commit is contained in:
Paul Schaub 2023-01-13 16:06:34 +01:00
parent 125eefed6e
commit 670aa0f242

View file

@ -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);
}
}