diff --git a/sop-java-picocli/src/main/java/sop/cli/picocli/commands/DecryptCmd.java b/sop-java-picocli/src/main/java/sop/cli/picocli/commands/DecryptCmd.java index 090276f..3a845b4 100644 --- a/sop-java-picocli/src/main/java/sop/cli/picocli/commands/DecryptCmd.java +++ b/sop-java-picocli/src/main/java/sop/cli/picocli/commands/DecryptCmd.java @@ -199,7 +199,7 @@ public class DecryptCmd implements Runnable { try { sessionKey = FileUtil.stringFromInputStream(FileUtil.getFileInputStream(sessionKeyFile)); } catch (IOException e) { - throw new SOPGPException.BadData("Cannot read session key from session key file " + sessionKeyFile, e); + throw new RuntimeException(e); } if (!sessionKeyPattern.matcher(sessionKey).matches()) { throw new IllegalArgumentException("Session keys are expected in the format 'ALGONUM:HEXKEY'."); @@ -224,7 +224,7 @@ public class DecryptCmd implements Runnable { } catch (SOPGPException.UnsupportedOption unsupportedOption) { throw new SOPGPException.UnsupportedOption(String.format(ERROR_UNSUPPORTED_OPTION, "--with-password"), unsupportedOption); } catch (IOException e) { - throw new SOPGPException.PasswordNotHumanReadable("Cannot read password from password file " + passwordFile, e); + throw new RuntimeException(e); } } } diff --git a/sop-java-picocli/src/main/java/sop/cli/picocli/commands/EncryptCmd.java b/sop-java-picocli/src/main/java/sop/cli/picocli/commands/EncryptCmd.java index 47447d2..8d26742 100644 --- a/sop-java-picocli/src/main/java/sop/cli/picocli/commands/EncryptCmd.java +++ b/sop-java-picocli/src/main/java/sop/cli/picocli/commands/EncryptCmd.java @@ -75,7 +75,7 @@ public class EncryptCmd implements Runnable { } catch (SOPGPException.UnsupportedOption unsupportedOption) { throw new SOPGPException.UnsupportedOption("Unsupported option '--with-password'.", unsupportedOption); } catch (IOException e) { - throw new SOPGPException.PasswordNotHumanReadable("Cannot read password from the provided password file " + passwordFileName, e); + throw new RuntimeException(e); } } diff --git a/sop-java-picocli/src/test/java/sop/cli/picocli/commands/DecryptCmdTest.java b/sop-java-picocli/src/test/java/sop/cli/picocli/commands/DecryptCmdTest.java index 54a8485..f04026d 100644 --- a/sop-java-picocli/src/test/java/sop/cli/picocli/commands/DecryptCmdTest.java +++ b/sop-java-picocli/src/test/java/sop/cli/picocli/commands/DecryptCmdTest.java @@ -345,6 +345,18 @@ public class DecryptCmdTest { SopCLI.main(new String[] {"decrypt", tempKeyFile.getAbsolutePath()}); } + @Test + @ExpectSystemExitWithStatus(61) + public void assertMissingPassphraseFileCausesExit61() { + SopCLI.main(new String[] {"decrypt", "--with-password", "missing"}); + } + + @Test + @ExpectSystemExitWithStatus(61) + public void assertMissingSessionKeyFileCausesExit61() { + SopCLI.main(new String[] {"decrypt", "--with-session-key", "missing"}); + } + @Test @ExpectSystemExitWithStatus(23) public void verifyOutWithoutVerifyWithCausesExit23() { diff --git a/sop-java-picocli/src/test/java/sop/cli/picocli/commands/VersionCmdTest.java b/sop-java-picocli/src/test/java/sop/cli/picocli/commands/VersionCmdTest.java index 98ea58e..d11352d 100644 --- a/sop-java-picocli/src/test/java/sop/cli/picocli/commands/VersionCmdTest.java +++ b/sop-java-picocli/src/test/java/sop/cli/picocli/commands/VersionCmdTest.java @@ -26,6 +26,8 @@ public class VersionCmdTest { version = mock(Version.class); when(version.getName()).thenReturn("MockSop"); when(version.getVersion()).thenReturn("1.0"); + when(version.getExtendedVersion()).thenReturn("MockSop Extended Version Information"); + when(version.getBackendVersion()).thenReturn("Foo"); when(sop.version()).thenReturn(version); SopCLI.setSopInstance(sop); @@ -38,6 +40,18 @@ public class VersionCmdTest { verify(version, times(1)).getName(); } + @Test + public void assertExtendedVersionCommandWorks() { + SopCLI.main(new String[] {"version", "--extended"}); + verify(version, times(1)).getExtendedVersion(); + } + + @Test + public void assertBackendVersionCommandWorks() { + SopCLI.main(new String[] {"version", "--backend"}); + verify(version, times(1)).getBackendVersion(); + } + @Test @ExpectSystemExitWithStatus(37) public void assertInvalidOptionResultsInExit37() {