Add initial tests for all operations

This commit is contained in:
Paul Schaub 2023-01-12 16:55:47 +01:00
parent bd02b11944
commit 6e40c7dc17
7 changed files with 340 additions and 2 deletions

View file

@ -0,0 +1,39 @@
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package sop.external;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIf;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static sop.external.JUtils.arrayStartsWith;
import static sop.external.JUtils.assertArrayStartsWith;
@EnabledIf("sop.external.AbstractExternalSOPTest#isExternalSopInstalled")
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);
@Test
public void dearmorArmorAliceKey() throws IOException {
byte[] aliceKey = TestKeys.ALICE_KEY.getBytes(StandardCharsets.UTF_8);
byte[] dearmored = getSop().dearmor()
.data(aliceKey)
.getBytes();
assertFalse(arrayStartsWith(dearmored, BEGIN_PGP_PRIVATE_KEY_BLOCK_BYTES));
byte[] armored = getSop().armor()
.data(dearmored)
.getBytes();
assertArrayStartsWith(armored, BEGIN_PGP_PRIVATE_KEY_BLOCK_BYTES);
}
}