From d53776dfc8c895acfcc753beb985b09a5430dbf4 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Tue, 18 Apr 2023 17:58:47 +0200 Subject: [PATCH] external-sop: Fix error code mapping of new exceptions --- external-sop/src/main/java/sop/external/ExternalSOP.java | 8 ++++++++ .../java/sop/testsuite/operation/ListProfilesTest.java | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/external-sop/src/main/java/sop/external/ExternalSOP.java b/external-sop/src/main/java/sop/external/ExternalSOP.java index f6e90a5..f22c778 100644 --- a/external-sop/src/main/java/sop/external/ExternalSOP.java +++ b/external-sop/src/main/java/sop/external/ExternalSOP.java @@ -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); diff --git a/sop-java/src/testFixtures/java/sop/testsuite/operation/ListProfilesTest.java b/sop-java/src/testFixtures/java/sop/testsuite/operation/ListProfilesTest.java index e97dd39..af60fc9 100644 --- a/sop-java/src/testFixtures/java/sop/testsuite/operation/ListProfilesTest.java +++ b/sop-java/src/testFixtures/java/sop/testsuite/operation/ListProfilesTest.java @@ -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")); + } }