Skip to content

Commit

Permalink
Sign: Test that key passwords are passed down from CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
vanitasvitae committed Aug 1, 2022
1 parent c4cbf8f commit d80a0a0
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
import sop.SOP;
import sop.SigningResult;
import sop.cli.picocli.SopCLI;
import sop.cli.picocli.TestFileUtil;
import sop.exception.SOPGPException;
import sop.operation.DetachedSign;

public class SignCmdTest {

DetachedSign detachedSign;
File keyFile;
File passFile;

@BeforeEach
public void mockComponents() throws IOException, SOPGPException.ExpectedText {
Expand All @@ -47,6 +49,7 @@ public SigningResult writeTo(OutputStream outputStream) {
SopCLI.setSopInstance(sop);

keyFile = File.createTempFile("sign-", ".asc");
passFile = TestFileUtil.writeTempStringFile("sw0rdf1sh");
}

@Test
Expand Down Expand Up @@ -107,6 +110,12 @@ public void noArmor_passedDown() {
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 {
Expand Down

0 comments on commit d80a0a0

Please sign in to comment.