decrypt: rename --not-after, --not-before to --verify-not-after, --verify-not-before

This commit is contained in:
Paul Schaub 2023-01-12 14:03:12 +01:00
parent 2c3717157a
commit d9708e882d
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 11 additions and 11 deletions

View file

@ -26,14 +26,14 @@ import java.util.List;
exitCodeOnInvalidInput = SOPGPException.UnsupportedOption.EXIT_CODE) exitCodeOnInvalidInput = SOPGPException.UnsupportedOption.EXIT_CODE)
public class DecryptCmd extends AbstractSopCmd { public class DecryptCmd extends AbstractSopCmd {
private static final String OPT_SESSION_KEY_OUT = "--session-key-out";
private static final String OPT_WITH_SESSION_KEY = "--with-session-key"; private static final String OPT_WITH_SESSION_KEY = "--with-session-key";
private static final String OPT_WITH_PASSWORD = "--with-password"; private static final String OPT_WITH_PASSWORD = "--with-password";
private static final String OPT_NOT_BEFORE = "--not-before";
private static final String OPT_NOT_AFTER = "--not-after";
private static final String OPT_SESSION_KEY_OUT = "--session-key-out";
private static final String OPT_VERIFICATIONS_OUT = "--verifications-out";
private static final String OPT_VERIFY_WITH = "--verify-with";
private static final String OPT_WITH_KEY_PASSWORD = "--with-key-password"; private static final String OPT_WITH_KEY_PASSWORD = "--with-key-password";
private static final String OPT_VERIFICATIONS_OUT = "--verifications-out"; // see SOP-05
private static final String OPT_VERIFY_WITH = "--verify-with";
private static final String OPT_NOT_BEFORE = "--verify-not-before";
private static final String OPT_NOT_AFTER = "--verify-not-after";
@CommandLine.Option( @CommandLine.Option(

View file

@ -123,7 +123,7 @@ public class DecryptCmdTest {
@Test @Test
public void assertVerifyNotAfterAndBeforeDashResultsInMaxTimeRange() throws SOPGPException.UnsupportedOption { public void assertVerifyNotAfterAndBeforeDashResultsInMaxTimeRange() throws SOPGPException.UnsupportedOption {
SopCLI.main(new String[] {"decrypt", "--not-before", "-", "--not-after", "-"}); SopCLI.main(new String[] {"decrypt", "--verify-not-before", "-", "--verify-not-after", "-"});
verify(decrypt, times(1)).verifyNotBefore(AbstractSopCmd.BEGINNING_OF_TIME); verify(decrypt, times(1)).verifyNotBefore(AbstractSopCmd.BEGINNING_OF_TIME);
verify(decrypt, times(1)).verifyNotAfter(AbstractSopCmd.END_OF_TIME); verify(decrypt, times(1)).verifyNotAfter(AbstractSopCmd.END_OF_TIME);
} }
@ -136,7 +136,7 @@ public class DecryptCmdTest {
return Math.abs(now.getTime() - argument.getTime()) <= 1000; return Math.abs(now.getTime() - argument.getTime()) <= 1000;
}; };
SopCLI.main(new String[] {"decrypt", "--not-before", "now", "--not-after", "now"}); SopCLI.main(new String[] {"decrypt", "--verify-not-before", "now", "--verify-not-after", "now"});
verify(decrypt, times(1)).verifyNotAfter(ArgumentMatchers.argThat(isMaxOneSecOff)); verify(decrypt, times(1)).verifyNotAfter(ArgumentMatchers.argThat(isMaxOneSecOff));
verify(decrypt, times(1)).verifyNotBefore(ArgumentMatchers.argThat(isMaxOneSecOff)); verify(decrypt, times(1)).verifyNotBefore(ArgumentMatchers.argThat(isMaxOneSecOff));
} }
@ -145,28 +145,28 @@ public class DecryptCmdTest {
@ExpectSystemExitWithStatus(1) @ExpectSystemExitWithStatus(1)
public void assertMalformedDateInNotBeforeCausesExit1() { public void assertMalformedDateInNotBeforeCausesExit1() {
// ParserException causes exit(1) // ParserException causes exit(1)
SopCLI.main(new String[] {"decrypt", "--not-before", "invalid"}); SopCLI.main(new String[] {"decrypt", "--verify-not-before", "invalid"});
} }
@Test @Test
@ExpectSystemExitWithStatus(1) @ExpectSystemExitWithStatus(1)
public void assertMalformedDateInNotAfterCausesExit1() { public void assertMalformedDateInNotAfterCausesExit1() {
// ParserException causes exit(1) // ParserException causes exit(1)
SopCLI.main(new String[] {"decrypt", "--not-after", "invalid"}); SopCLI.main(new String[] {"decrypt", "--verify-not-after", "invalid"});
} }
@Test @Test
@ExpectSystemExitWithStatus(SOPGPException.UnsupportedOption.EXIT_CODE) @ExpectSystemExitWithStatus(SOPGPException.UnsupportedOption.EXIT_CODE)
public void assertUnsupportedNotAfterCausesExit37() throws SOPGPException.UnsupportedOption { public void assertUnsupportedNotAfterCausesExit37() throws SOPGPException.UnsupportedOption {
when(decrypt.verifyNotAfter(any())).thenThrow(new SOPGPException.UnsupportedOption("Setting upper signature date boundary not supported.")); when(decrypt.verifyNotAfter(any())).thenThrow(new SOPGPException.UnsupportedOption("Setting upper signature date boundary not supported."));
SopCLI.main(new String[] {"decrypt", "--not-after", "now"}); SopCLI.main(new String[] {"decrypt", "--verify-not-after", "now"});
} }
@Test @Test
@ExpectSystemExitWithStatus(SOPGPException.UnsupportedOption.EXIT_CODE) @ExpectSystemExitWithStatus(SOPGPException.UnsupportedOption.EXIT_CODE)
public void assertUnsupportedNotBeforeCausesExit37() throws SOPGPException.UnsupportedOption { public void assertUnsupportedNotBeforeCausesExit37() throws SOPGPException.UnsupportedOption {
when(decrypt.verifyNotBefore(any())).thenThrow(new SOPGPException.UnsupportedOption("Setting lower signature date boundary not supported.")); when(decrypt.verifyNotBefore(any())).thenThrow(new SOPGPException.UnsupportedOption("Setting lower signature date boundary not supported."));
SopCLI.main(new String[] {"decrypt", "--not-before", "now"}); SopCLI.main(new String[] {"decrypt", "--verify-not-before", "now"});
} }
@Test @Test