mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-12-22 04:57:56 +01:00
Even more tests
This commit is contained in:
parent
9cf6301b8c
commit
e73c7e5f91
3 changed files with 31 additions and 7 deletions
|
@ -228,4 +228,16 @@ public class ExternalDetachedSignVerifyRoundTripTest extends AbstractExternalSOP
|
|||
.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyMissingCertCausesMissingArg() {
|
||||
ignoreIf("PGPainless-SOP", Is.geq, "0.0.0"); // PGPainless uses picocli which throws
|
||||
// UNSUPPORTED_OPTION for missing arg
|
||||
byte[] message = TestData.PLAINTEXT.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
assertThrows(SOPGPException.MissingArg.class, () ->
|
||||
getSop().verify()
|
||||
.signatures(TestData.ALICE_DETACHED_SIGNED_MESSAGE.getBytes(StandardCharsets.UTF_8))
|
||||
.data(message));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class ExternalEncryptDecryptRoundTripTest extends AbstractExternalSOPTest
|
|||
|
||||
@Test
|
||||
public void encryptDecryptRoundTripPasswordTest() throws IOException {
|
||||
byte[] message = "Hello, World!\n".getBytes(StandardCharsets.UTF_8);
|
||||
byte[] message = TestData.PLAINTEXT.getBytes(StandardCharsets.UTF_8);
|
||||
byte[] ciphertext = getSop().encrypt()
|
||||
.withPassword("sw0rdf1sh")
|
||||
.plaintext(message)
|
||||
|
@ -47,7 +47,7 @@ public class ExternalEncryptDecryptRoundTripTest extends AbstractExternalSOPTest
|
|||
|
||||
@Test
|
||||
public void encryptDecryptRoundTripAliceTest() throws IOException {
|
||||
byte[] message = "Hello, World!\n".getBytes(StandardCharsets.UTF_8);
|
||||
byte[] message = TestData.PLAINTEXT.getBytes(StandardCharsets.UTF_8);
|
||||
byte[] ciphertext = getSop().encrypt()
|
||||
.withCert(TestData.ALICE_CERT.getBytes(StandardCharsets.UTF_8))
|
||||
.plaintext(message)
|
||||
|
@ -67,7 +67,7 @@ public class ExternalEncryptDecryptRoundTripTest extends AbstractExternalSOPTest
|
|||
|
||||
@Test
|
||||
public void encryptDecryptRoundTripBobTest() throws IOException {
|
||||
byte[] message = "Hello, World!\n".getBytes(StandardCharsets.UTF_8);
|
||||
byte[] message = TestData.PLAINTEXT.getBytes(StandardCharsets.UTF_8);
|
||||
byte[] ciphertext = getSop().encrypt()
|
||||
.withCert(TestData.BOB_CERT.getBytes(StandardCharsets.UTF_8))
|
||||
.plaintext(message)
|
||||
|
@ -86,7 +86,7 @@ public class ExternalEncryptDecryptRoundTripTest extends AbstractExternalSOPTest
|
|||
public void encryptDecryptRoundTripCarolTest() throws IOException {
|
||||
ignoreIf("sqop", Is.geq, "0.0.0"); // sqop reports cert not encryption capable
|
||||
|
||||
byte[] message = "Hello, World!\n".getBytes(StandardCharsets.UTF_8);
|
||||
byte[] message = TestData.PLAINTEXT.getBytes(StandardCharsets.UTF_8);
|
||||
byte[] ciphertext = getSop().encrypt()
|
||||
.withCert(TestData.CAROL_CERT.getBytes(StandardCharsets.UTF_8))
|
||||
.plaintext(message)
|
||||
|
@ -105,7 +105,7 @@ public class ExternalEncryptDecryptRoundTripTest extends AbstractExternalSOPTest
|
|||
public void encryptNoArmorThenArmorThenDecryptRoundTrip() throws IOException {
|
||||
ignoreIf("sqop", Is.leq, "0.26.1"); // Invalid data type
|
||||
|
||||
byte[] message = "Hello, World!\n".getBytes(StandardCharsets.UTF_8);
|
||||
byte[] message = TestData.PLAINTEXT.getBytes(StandardCharsets.UTF_8);
|
||||
byte[] ciphertext = getSop().encrypt()
|
||||
.withCert(TestData.ALICE_CERT.getBytes(StandardCharsets.UTF_8))
|
||||
.noArmor()
|
||||
|
@ -127,7 +127,7 @@ public class ExternalEncryptDecryptRoundTripTest extends AbstractExternalSOPTest
|
|||
|
||||
@Test
|
||||
public void encryptSignDecryptVerifyRoundTripAliceTest() throws IOException {
|
||||
byte[] message = "Hello, World!\n".getBytes(StandardCharsets.UTF_8);
|
||||
byte[] message = TestData.PLAINTEXT.getBytes(StandardCharsets.UTF_8);
|
||||
byte[] ciphertext = getSop().encrypt()
|
||||
.withCert(TestData.ALICE_CERT.getBytes(StandardCharsets.UTF_8))
|
||||
.signWith(TestData.ALICE_KEY.getBytes(StandardCharsets.UTF_8))
|
||||
|
@ -152,7 +152,7 @@ public class ExternalEncryptDecryptRoundTripTest extends AbstractExternalSOPTest
|
|||
|
||||
@Test
|
||||
public void encryptSignAsTextDecryptVerifyRoundTripAliceTest() throws IOException {
|
||||
byte[] message = "Hello, World!\n".getBytes(StandardCharsets.UTF_8);
|
||||
byte[] message = TestData.PLAINTEXT.getBytes(StandardCharsets.UTF_8);
|
||||
byte[] ciphertext = getSop().encrypt()
|
||||
.withCert(TestData.ALICE_CERT.getBytes(StandardCharsets.UTF_8))
|
||||
.signWith(TestData.ALICE_KEY.getBytes(StandardCharsets.UTF_8))
|
||||
|
@ -278,4 +278,13 @@ public class ExternalEncryptDecryptRoundTripTest extends AbstractExternalSOPTest
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void missingArgsTest() throws IOException {
|
||||
byte[] message = TestData.PLAINTEXT.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
assertThrows(SOPGPException.MissingArg.class, () -> getSop().encrypt()
|
||||
.plaintext(message)
|
||||
.getBytes());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ public class ExternalExtractCertTest extends AbstractExternalSOPTest {
|
|||
|
||||
@Test
|
||||
public void extractAliceCertFromAliceKeyTest() throws IOException {
|
||||
ignoreIf("PGPainless-SOP", Is.geq, "0.0.0"); // PGPainless uses old CTB
|
||||
byte[] armoredCert = getSop().extractCert()
|
||||
.key(TestData.ALICE_KEY.getBytes(StandardCharsets.UTF_8))
|
||||
.getBytes();
|
||||
|
@ -43,6 +44,7 @@ public class ExternalExtractCertTest extends AbstractExternalSOPTest {
|
|||
|
||||
@Test
|
||||
public void extractBobsCertFromBobsKeyTest() throws IOException {
|
||||
ignoreIf("PGPainless-SOP", Is.geq, "0.0.0"); // PGPainless uses old CTB
|
||||
byte[] armoredCert = getSop().extractCert()
|
||||
.key(TestData.BOB_KEY.getBytes(StandardCharsets.UTF_8))
|
||||
.getBytes();
|
||||
|
@ -51,6 +53,7 @@ public class ExternalExtractCertTest extends AbstractExternalSOPTest {
|
|||
|
||||
@Test
|
||||
public void extractCarolsCertFromCarolsKeyTest() throws IOException {
|
||||
ignoreIf("PGPainless-SOP", Is.geq, "0.0.0"); // PGPainless uses old CTB
|
||||
byte[] armoredCert = getSop().extractCert()
|
||||
.key(TestData.CAROL_KEY.getBytes(StandardCharsets.UTF_8))
|
||||
.getBytes();
|
||||
|
|
Loading…
Reference in a new issue