mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-01 16:52:08 +01:00
SOP: Test profile support of encrypt subcommand
This commit is contained in:
parent
08ce7c099c
commit
ea9b0d68fb
1 changed files with 28 additions and 0 deletions
|
@ -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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue