Compare commits

...

7 commits
main ... 5.0.2

6 changed files with 35 additions and 12 deletions

View file

@ -6,6 +6,14 @@ SPDX-License-Identifier: Apache-2.0
# Changelog
## 5.0.2
- `decrypt`: Do not throw `NoSignature` exception (exit code 3) if `--verify-with` is set, but `VERIFICATIONS` is empty.
## 5.0.1
- `external-sop`: Properly map error codes to new exception types:
- `UNSUPPORTED_PROFILE`
- `INCOMPATIBLE_OPTIONS`
## 5.0.0
- Update implementation to [SOP Specification revision 05](https://www.ietf.org/archive/id/draft-dkg-openpgp-stateless-cli-05.html).
- Add the concept of profiles

View file

@ -267,6 +267,14 @@ public class ExternalSOP implements SOP {
throw new SOPGPException.KeyCannotSign("External SOP backend reported error KeyCannotSign (" +
exitCode + "):\n" + errorMessage);
case SOPGPException.IncompatibleOptions.EXIT_CODE:
throw new SOPGPException.IncompatibleOptions("External SOP backend reported error IncompatibleOptions (" +
exitCode + "):\n" + errorMessage);
case SOPGPException.UnsupportedProfile.EXIT_CODE:
throw new SOPGPException.UnsupportedProfile("External SOP backend reported error UnsupportedProfile (" +
exitCode + "):\n" + errorMessage);
default:
throw new RuntimeException("External SOP backend reported unknown exit code (" +
exitCode + "):\n" + errorMessage);

View file

@ -115,11 +115,6 @@ public class DecryptCmd extends AbstractSopCmd {
private void writeVerifyOut(DecryptionResult result) throws IOException {
if (verifyOut != null) {
if (result.getVerifications().isEmpty()) {
String errorMsg = getMsg("sop.error.runtime.no_verifiable_signature_found");
throw new SOPGPException.NoSignature(errorMsg);
}
try (OutputStream fileOut = getOutput(verifyOut)) {
PrintWriter writer = new PrintWriter(fileOut);
for (Verification verification : result.getVerifications()) {

View file

@ -21,6 +21,7 @@ import sop.operation.Decrypt;
import sop.util.HexUtil;
import sop.util.UTCUtil;
import javax.annotation.Nonnull;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
@ -246,15 +247,17 @@ public class DecryptCmdTest {
}
@Test
@ExpectSystemExitWithStatus(SOPGPException.NoSignature.EXIT_CODE)
public void assertNoSignatureExceptionCausesExit3() throws SOPGPException.CannotDecrypt, SOPGPException.MissingArg, SOPGPException.BadData, IOException {
public void assertNoVerificationsIsOkay() throws SOPGPException.CannotDecrypt, SOPGPException.MissingArg, SOPGPException.BadData, IOException {
File tempFile = File.createTempFile("verify-with-", ".tmp");
File verifyOut = new File(tempFile.getParent(), "verifications.out");
verifyOut.deleteOnExit();
when(decrypt.ciphertext((InputStream) any())).thenReturn(new ReadyWithResult<DecryptionResult>() {
@Override
public DecryptionResult writeTo(OutputStream outputStream) throws SOPGPException.NoSignature {
throw new SOPGPException.NoSignature();
public DecryptionResult writeTo(@Nonnull OutputStream outputStream) throws SOPGPException.NoSignature {
return new DecryptionResult(null, Collections.emptyList());
}
});
SopCLI.main(new String[] {"decrypt"});
SopCLI.main(new String[] {"decrypt", "--verify-with", tempFile.getAbsolutePath(), "--verifications-out", verifyOut.getAbsolutePath()});
}
@Test

View file

@ -9,12 +9,14 @@ import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import sop.Profile;
import sop.SOP;
import sop.exception.SOPGPException;
import java.io.IOException;
import java.util.List;
import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class ListProfilesTest extends AbstractSOPTest {
@ -30,4 +32,11 @@ public class ListProfilesTest extends AbstractSOPTest {
assertFalse(profiles.isEmpty());
}
@ParameterizedTest
@MethodSource("provideInstances")
public void listUnsupportedProfiles(SOP sop) throws IOException {
assertThrows(SOPGPException.UnsupportedProfile.class, () -> sop
.listProfiles()
.subcommand("invalid"));
}
}

View file

@ -4,8 +4,8 @@
allprojects {
ext {
shortVersion = '5.0.1'
isSnapshot = true
shortVersion = '5.0.2'
isSnapshot = false
minAndroidSdk = 10
javaSourceCompatibility = 1.8
gsonVersion = '2.10.1'