external-sop: Fix error code mapping of new exceptions

This commit is contained in:
Paul Schaub 2023-04-18 17:58:47 +02:00
parent 51a7d950e5
commit d8cac7b9d7
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 17 additions and 0 deletions

View file

@ -267,6 +267,14 @@ public class ExternalSOP implements SOP {
throw new SOPGPException.KeyCannotSign("External SOP backend reported error KeyCannotSign (" + throw new SOPGPException.KeyCannotSign("External SOP backend reported error KeyCannotSign (" +
exitCode + "):\n" + errorMessage); 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: default:
throw new RuntimeException("External SOP backend reported unknown exit code (" + throw new RuntimeException("External SOP backend reported unknown exit code (" +
exitCode + "):\n" + errorMessage); exitCode + "):\n" + errorMessage);

View file

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