1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-25 22:02:05 +01:00

Add test for inline-sign --as=text

This commit is contained in:
Paul Schaub 2022-11-18 15:36:58 +01:00
parent ce929fd055
commit 508864c4ff

View file

@ -172,6 +172,31 @@ public class RoundTripInlineSignInlineVerifyCmdTest extends CLITest {
assertTrue(verificationString.contains(CERT_1_SIGNING_KEY)); assertTrue(verificationString.contains(CERT_1_SIGNING_KEY));
} }
@Test
public void createAndVerifyTextSignedMessage() throws IOException {
File key = writeFile("key.asc", KEY_1);
File password = writeFile("password", KEY_1_PASSWORD);
pipeStringToStdin(MESSAGE);
ByteArrayOutputStream ciphertextOut = pipeStdoutToStream();
assertSuccess(executeCommand("inline-sign",
"--as", "text",
key.getAbsolutePath(),
"--with-key-password", password.getAbsolutePath()));
File cert = writeFile("cert.asc", CERT_1);
File verifications = nonExistentFile("verifications");
pipeStringToStdin(ciphertextOut.toString());
ByteArrayOutputStream plaintextOut = pipeStdoutToStream();
assertSuccess(executeCommand("inline-verify",
"--verifications-out", verifications.getAbsolutePath(),
cert.getAbsolutePath()));
assertEquals(MESSAGE, plaintextOut.toString());
String verificationString = readStringFromFile(verifications);
assertTrue(verificationString.contains(CERT_1_SIGNING_KEY));
}
@Test @Test
public void createSignedMessageWithKeyAAndVerifyWithKeyBFails() throws IOException { public void createSignedMessageWithKeyAAndVerifyWithKeyBFails() throws IOException {
File key = writeFile("key.asc", KEY_1); File key = writeFile("key.asc", KEY_1);