mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-12-22 04:57:56 +01:00
Add tests for extracting certs from known keys
This commit is contained in:
parent
ffc5b26c0d
commit
0d9db2bdd3
1 changed files with 25 additions and 0 deletions
|
@ -14,6 +14,7 @@ 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;
|
||||
import static sop.external.JUtils.assertAsciiArmorEquals;
|
||||
|
||||
@EnabledIf("sop.external.AbstractExternalSOPTest#isExternalSopInstalled")
|
||||
public class ExternalExtractCertTest extends AbstractExternalSOPTest {
|
||||
|
@ -32,6 +33,30 @@ public class ExternalExtractCertTest extends AbstractExternalSOPTest {
|
|||
assertArrayStartsWith(cert, BEGIN_PGP_PUBLIC_KEY_BLOCK_BYTES);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extractAliceCertFromAliceKeyTest() throws IOException {
|
||||
byte[] armoredCert = getSop().extractCert()
|
||||
.key(TestKeys.ALICE_KEY.getBytes(StandardCharsets.UTF_8))
|
||||
.getBytes();
|
||||
assertAsciiArmorEquals(TestKeys.ALICE_CERT.getBytes(StandardCharsets.UTF_8), armoredCert);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extractBobsCertFromBobsKeyTest() throws IOException {
|
||||
byte[] armoredCert = getSop().extractCert()
|
||||
.key(TestKeys.BOB_KEY.getBytes(StandardCharsets.UTF_8))
|
||||
.getBytes();
|
||||
assertAsciiArmorEquals(TestKeys.BOB_CERT.getBytes(StandardCharsets.UTF_8), armoredCert);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extractCarolsCertFromCarolsKeyTest() throws IOException {
|
||||
byte[] armoredCert = getSop().extractCert()
|
||||
.key(TestKeys.CAROL_KEY.getBytes(StandardCharsets.UTF_8))
|
||||
.getBytes();
|
||||
assertAsciiArmorEquals(TestKeys.CAROL_CERT.getBytes(StandardCharsets.UTF_8), armoredCert);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extractUnarmoredCertFromArmoredKeyTest() throws IOException {
|
||||
InputStream keyIn = getSop().generateKey()
|
||||
|
|
Loading…
Reference in a new issue