mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-06-28 14:34:53 +02:00
Compare commits
7 commits
Author | SHA1 | Date | |
---|---|---|---|
Paul Schaub | b9de503221 | ||
Paul Schaub | 94378f63d7 | ||
Paul Schaub | df78dbd2b0 | ||
Paul Schaub | a984b6e9f3 | ||
Paul Schaub | d028480b1a | ||
Paul Schaub | 01f7fc158c | ||
Paul Schaub | d53776dfc8 |
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in a new issue