mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2025-09-09 10:19:47 +02:00
Add initial tests for all operations
This commit is contained in:
parent
bd02b11944
commit
6e40c7dc17
7 changed files with 340 additions and 2 deletions
39
external-sop/src/test/java/sop/external/ExternalArmorDearmorRoundTripTest.java
vendored
Normal file
39
external-sop/src/test/java/sop/external/ExternalArmorDearmorRoundTripTest.java
vendored
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue