mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-22 19:08:00 +01:00
Add encrypt-decrypt roundtrip test for rfc4880 profile to cli tests
This commit is contained in:
parent
8369333355
commit
d9ab91516d
1 changed files with 26 additions and 0 deletions
|
@ -644,4 +644,30 @@ public class RoundTripEncryptDecryptCmdTest extends CLITest {
|
|||
int exitCode = executeCommand("decrypt");
|
||||
assertEquals(SOPGPException.MissingArg.EXIT_CODE, exitCode);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEncryptDecryptWithFreshRSAKey() throws IOException {
|
||||
// Generate key
|
||||
File passwordFile = writeFile("password", "sw0rdf1sh");
|
||||
File keyFile = pipeStdoutToFile("key.asc");
|
||||
assertSuccess(executeCommand("generate-key", "--profile=rfc4880", "--with-key-password", passwordFile.getAbsolutePath(), "Alice <alice@example.org>"));
|
||||
|
||||
File certFile = pipeStdoutToFile("cert.asc");
|
||||
pipeFileToStdin(keyFile);
|
||||
assertSuccess(executeCommand("extract-cert"));
|
||||
|
||||
// Write plaintext
|
||||
File plaintextFile = writeFile("msg.txt", "Hello, World!\n");
|
||||
|
||||
// Encrypt
|
||||
File ciphertextFile = pipeStdoutToFile("msg.asc");
|
||||
pipeFileToStdin(plaintextFile);
|
||||
assertSuccess(executeCommand("encrypt", "--profile=rfc4880", certFile.getAbsolutePath()));
|
||||
|
||||
ByteArrayOutputStream decrypted = pipeStdoutToStream();
|
||||
pipeFileToStdin(ciphertextFile);
|
||||
assertSuccess(executeCommand("decrypt", "--with-key-password", passwordFile.getAbsolutePath(), keyFile.getAbsolutePath()));
|
||||
|
||||
assertEquals("Hello, World!\n", decrypted.toString());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue