mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-23 03:17:58 +01:00
add unit test to read decryption stream beyond end
This commit is contained in:
parent
6999f4d241
commit
9ab0c35b78
1 changed files with 18 additions and 0 deletions
|
@ -82,6 +82,24 @@ public class DecryptAndVerifyMessageTest {
|
||||||
assertEquals(new SubkeyIdentifier(TestKeys.JULIET_FINGERPRINT), metadata.getDecryptionKey());
|
assertEquals(new SubkeyIdentifier(TestKeys.JULIET_FINGERPRINT), metadata.getDecryptionKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestTemplate
|
||||||
|
@ExtendWith(TestAllImplementations.class)
|
||||||
|
public void decryptMessageAndReadBeyondEndTest() throws Exception {
|
||||||
|
final String encryptedMessage = TestKeys.MSG_SIGN_CRYPT_JULIET_JULIET;
|
||||||
|
|
||||||
|
final ConsumerOptions options = new ConsumerOptions()
|
||||||
|
.addDecryptionKey(juliet)
|
||||||
|
.addVerificationCert(KeyRingUtils.publicKeyRingFrom(juliet));
|
||||||
|
|
||||||
|
try (final DecryptionStream decryptor = PGPainless.decryptAndOrVerify()
|
||||||
|
.onInputStream(new ByteArrayInputStream(encryptedMessage.getBytes()))
|
||||||
|
.withOptions(options);
|
||||||
|
final ByteArrayOutputStream toPlain = new ByteArrayOutputStream()) {
|
||||||
|
Streams.pipeAll(decryptor, toPlain);
|
||||||
|
assertEquals(-1, decryptor.read());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestTemplate
|
@TestTemplate
|
||||||
@ExtendWith(TestAllImplementations.class)
|
@ExtendWith(TestAllImplementations.class)
|
||||||
public void decryptMessageAndVerifySignatureByteByByteTest() throws Exception {
|
public void decryptMessageAndVerifySignatureByteByByteTest() throws Exception {
|
||||||
|
|
Loading…
Reference in a new issue