1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-09-11 19:29:39 +02:00

CleartextSignedMessage processing: Reuse normal processing API

This commit is contained in:
Paul Schaub 2021-09-27 11:47:54 +02:00
parent f15f3a4e2a
commit ece5897bae
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
4 changed files with 92 additions and 80 deletions

View file

@ -89,13 +89,18 @@ public class CleartextSignatureVerificationTest {
.withStrategy(multiPassStrategy)
.withOptions(options);
OpenPgpMetadata result = processor.process();
DecryptionStream decryptionStream = processor.getVerificationStream();
ByteArrayOutputStream out = new ByteArrayOutputStream();
Streams.pipeAll(decryptionStream, out);
decryptionStream.close();
OpenPgpMetadata result = decryptionStream.getResult();
assertTrue(result.isVerified());
PGPSignature signature = result.getVerifiedSignatures().values().iterator().next();
assertEquals(signature.getKeyID(), signingKeys.getPublicKey().getKeyID());
assertArrayEquals(MESSAGE_BODY, multiPassStrategy.getBytes());
assertArrayEquals(MESSAGE_BODY, out.toByteArray());
}
@Test
@ -112,7 +117,13 @@ public class CleartextSignatureVerificationTest {
.withStrategy(multiPassStrategy)
.withOptions(options);
OpenPgpMetadata result = processor.process();
DecryptionStream decryptionStream = processor.getVerificationStream();
ByteArrayOutputStream out = new ByteArrayOutputStream();
Streams.pipeAll(decryptionStream, out);
decryptionStream.close();
OpenPgpMetadata result = decryptionStream.getResult();
assertTrue(result.isVerified());
PGPSignature signature = result.getVerifiedSignatures().values().iterator().next();
@ -205,6 +216,6 @@ public class CleartextSignatureVerificationTest {
.onInputStream(new ByteArrayInputStream(inlineSignedMessage.getBytes(StandardCharsets.UTF_8)))
.withStrategy(new InMemoryMultiPassStrategy())
.withOptions(options)
.process());
.getVerificationStream());
}
}