1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-29 15:52:08 +01:00

SOP: Test profile support of encrypt subcommand

This commit is contained in:
Paul Schaub 2023-06-12 14:37:33 +02:00
parent 08ce7c099c
commit ea9b0d68fb
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -546,4 +546,32 @@ public class EncryptDecryptRoundTripTest {
.toByteArrayAndResult() .toByteArrayAndResult()
); );
} }
@Test
public void encryptWithUnsupportedProfileFails() {
assertThrows(SOPGPException.UnsupportedProfile.class, () -> sop
.encrypt()
.profile("Unknown"));
}
@Test
public void encryptWithSupportedProfileTest() throws IOException {
byte[] encrypted = sop.encrypt()
.profile("rfc4880")
.withCert(bobCert)
.plaintext(message)
.getBytes();
ByteArrayAndResult<DecryptionResult> bytesAndResult = sop.decrypt()
.withKey(bobKey)
.ciphertext(encrypted)
.toByteArrayAndResult();
ByteArrayOutputStream decrypted = new ByteArrayOutputStream();
Streams.pipeAll(bytesAndResult.getInputStream(), decrypted);
assertArrayEquals(message, decrypted.toByteArray());
DecryptionResult result = bytesAndResult.getResult();
assertTrue(result.getSessionKey().isPresent());
}
} }