From d80a0a067fb327b848ea329ca34512f31ddc066e Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Mon, 1 Aug 2022 18:46:11 +0200 Subject: [PATCH] Sign: Test that key passwords are passed down from CLI --- .../test/java/sop/cli/picocli/commands/SignCmdTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sop-java-picocli/src/test/java/sop/cli/picocli/commands/SignCmdTest.java b/sop-java-picocli/src/test/java/sop/cli/picocli/commands/SignCmdTest.java index 3b96012..c3d6b59 100644 --- a/sop-java-picocli/src/test/java/sop/cli/picocli/commands/SignCmdTest.java +++ b/sop-java-picocli/src/test/java/sop/cli/picocli/commands/SignCmdTest.java @@ -23,6 +23,7 @@ import sop.ReadyWithResult; import sop.SOP; import sop.SigningResult; import sop.cli.picocli.SopCLI; +import sop.cli.picocli.TestFileUtil; import sop.exception.SOPGPException; import sop.operation.DetachedSign; @@ -30,6 +31,7 @@ public class SignCmdTest { DetachedSign detachedSign; File keyFile; + File passFile; @BeforeEach public void mockComponents() throws IOException, SOPGPException.ExpectedText { @@ -47,6 +49,7 @@ public class SignCmdTest { SopCLI.setSopInstance(sop); keyFile = File.createTempFile("sign-", ".asc"); + passFile = TestFileUtil.writeTempStringFile("sw0rdf1sh"); } @Test @@ -107,6 +110,12 @@ public class SignCmdTest { verify(detachedSign, times(1)).noArmor(); } + @Test + public void withKeyPassword_passedDown() { + SopCLI.main(new String[] {"sign", "--with-key-password", passFile.getAbsolutePath(), keyFile.getAbsolutePath()}); + verify(detachedSign, times(1)).withKeyPassword("sw0rdf1sh"); + } + @Test @ExpectSystemExitWithStatus(1) public void data_ioExceptionCausesExit1() throws IOException, SOPGPException.ExpectedText {