Sign: Test that key passwords are passed down from CLI

This commit is contained in:
Paul Schaub 2022-08-01 18:46:11 +02:00
parent c4cbf8ff69
commit d80a0a067f
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -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 {