mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-09 18:29:39 +02:00
Introduce SigningResult class to allow for additional signing information to be returned
This commit is contained in:
parent
987c328ad8
commit
f2d88d8a86
5 changed files with 70 additions and 15 deletions
|
@ -15,6 +15,7 @@ import java.util.List;
|
|||
import picocli.CommandLine;
|
||||
import sop.MicAlg;
|
||||
import sop.ReadyWithResult;
|
||||
import sop.SigningResult;
|
||||
import sop.cli.picocli.Print;
|
||||
import sop.cli.picocli.SopCLI;
|
||||
import sop.enums.SignAs;
|
||||
|
@ -93,9 +94,10 @@ public class SignCmd implements Runnable {
|
|||
}
|
||||
|
||||
try {
|
||||
ReadyWithResult<MicAlg> ready = sign.data(System.in);
|
||||
MicAlg micAlg = ready.writeTo(System.out);
|
||||
ReadyWithResult<SigningResult> ready = sign.data(System.in);
|
||||
SigningResult result = ready.writeTo(System.out);
|
||||
|
||||
MicAlg micAlg = result.getMicAlg();
|
||||
if (micAlgOut != null) {
|
||||
// Write micalg out
|
||||
micAlgOut.createNewFile();
|
||||
|
|
|
@ -19,9 +19,9 @@ import java.io.OutputStream;
|
|||
import com.ginsberg.junit.exit.ExpectSystemExitWithStatus;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import sop.MicAlg;
|
||||
import sop.ReadyWithResult;
|
||||
import sop.SOP;
|
||||
import sop.SigningResult;
|
||||
import sop.cli.picocli.SopCLI;
|
||||
import sop.exception.SOPGPException;
|
||||
import sop.operation.Sign;
|
||||
|
@ -34,10 +34,10 @@ public class SignCmdTest {
|
|||
@BeforeEach
|
||||
public void mockComponents() throws IOException, SOPGPException.ExpectedText {
|
||||
sign = mock(Sign.class);
|
||||
when(sign.data((InputStream) any())).thenReturn(new ReadyWithResult<MicAlg>() {
|
||||
when(sign.data((InputStream) any())).thenReturn(new ReadyWithResult<SigningResult>() {
|
||||
@Override
|
||||
public MicAlg writeTo(OutputStream outputStream) {
|
||||
return MicAlg.fromHashAlgorithmId(10);
|
||||
public SigningResult writeTo(OutputStream outputStream) {
|
||||
return SigningResult.builder().build();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -110,9 +110,9 @@ public class SignCmdTest {
|
|||
@Test
|
||||
@ExpectSystemExitWithStatus(1)
|
||||
public void data_ioExceptionCausesExit1() throws IOException, SOPGPException.ExpectedText {
|
||||
when(sign.data((InputStream) any())).thenReturn(new ReadyWithResult<MicAlg>() {
|
||||
when(sign.data((InputStream) any())).thenReturn(new ReadyWithResult<SigningResult>() {
|
||||
@Override
|
||||
public MicAlg writeTo(OutputStream outputStream) throws IOException {
|
||||
public SigningResult writeTo(OutputStream outputStream) throws IOException {
|
||||
throw new IOException();
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue