mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-11-26 09:02:06 +01:00
Sign: Test that key passwords are passed down from CLI
This commit is contained in:
parent
c4cbf8ff69
commit
d80a0a067f
1 changed files with 9 additions and 0 deletions
|
@ -23,6 +23,7 @@ import sop.ReadyWithResult;
|
||||||
import sop.SOP;
|
import sop.SOP;
|
||||||
import sop.SigningResult;
|
import sop.SigningResult;
|
||||||
import sop.cli.picocli.SopCLI;
|
import sop.cli.picocli.SopCLI;
|
||||||
|
import sop.cli.picocli.TestFileUtil;
|
||||||
import sop.exception.SOPGPException;
|
import sop.exception.SOPGPException;
|
||||||
import sop.operation.DetachedSign;
|
import sop.operation.DetachedSign;
|
||||||
|
|
||||||
|
@ -30,6 +31,7 @@ public class SignCmdTest {
|
||||||
|
|
||||||
DetachedSign detachedSign;
|
DetachedSign detachedSign;
|
||||||
File keyFile;
|
File keyFile;
|
||||||
|
File passFile;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void mockComponents() throws IOException, SOPGPException.ExpectedText {
|
public void mockComponents() throws IOException, SOPGPException.ExpectedText {
|
||||||
|
@ -47,6 +49,7 @@ public class SignCmdTest {
|
||||||
SopCLI.setSopInstance(sop);
|
SopCLI.setSopInstance(sop);
|
||||||
|
|
||||||
keyFile = File.createTempFile("sign-", ".asc");
|
keyFile = File.createTempFile("sign-", ".asc");
|
||||||
|
passFile = TestFileUtil.writeTempStringFile("sw0rdf1sh");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -107,6 +110,12 @@ public class SignCmdTest {
|
||||||
verify(detachedSign, times(1)).noArmor();
|
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
|
@Test
|
||||||
@ExpectSystemExitWithStatus(1)
|
@ExpectSystemExitWithStatus(1)
|
||||||
public void data_ioExceptionCausesExit1() throws IOException, SOPGPException.ExpectedText {
|
public void data_ioExceptionCausesExit1() throws IOException, SOPGPException.ExpectedText {
|
||||||
|
|
Loading…
Reference in a new issue