Port sq verify's examples to the example framework.

- Port `sq verify`'s examples to the example framework and improve
    them.

  - See #196.
This commit is contained in:
Justus Winter 2024-06-20 18:00:47 +02:00
parent 279cf37665
commit 846d819368
No known key found for this signature in database
GPG Key ID: 686F55B4AB2B3386
3 changed files with 56 additions and 13 deletions

View File

@ -11,6 +11,49 @@ use super::types::ClapData;
use super::types::FileOrStdin;
use super::types::FileOrStdout;
use crate::cli::examples;
use examples::*;
const VERIFY_EXAMPLES: Actions = Actions {
actions: &[
Action::Setup(Setup {
command: &[
"sq", "cert", "import", "juliet.pgp",
],
}),
Action::Setup(Setup {
command: &[
"sq", "--time", "2024-06-19",
"pki", "link", "add",
"7A58B15E3B9459483D9FFA8D40E299AC5F2B0872",
"--email", "juliet@example.org",
],
}),
Action::Example(Example {
comment: "\
Verify a signed message.",
command: &[
"sq", "verify", "document.pgp",
],
}),
Action::Example(Example {
comment: "\
Verify a detached message.",
command: &[
"sq", "verify", "--detached", "document.sig", "document.txt",
],
}),
Action::Example(Example {
comment: "\
Verify a message as of June 19, 2024 at midnight UTC.",
command: &[
"sq", "verify", "--time", "2024-06-19", "document.pgp",
],
}),
]
};
test_examples!(sq_verify, VERIFY_EXAMPLES);
#[derive(Parser, Debug)]
#[clap(
name = "verify",
@ -49,19 +92,8 @@ signatures, consider using sequoia-sqv.
`--time` argument. When set, it verifies the message as of the
reference time instead of the current time.
",
after_help =
"EXAMPLES:
# Verify a signed message
$ sq verify signed-message.pgp
# Verify a detached message
$ sq verify --detached message.sig message.txt
# Verify a message as of June 9, 2011 at midnight UTC:
$ sq verify --time 20130721 msg.pgp
",
)]
after_help = VERIFY_EXAMPLES,
)]
pub struct Command {
#[clap(
default_value_t = FileOrStdin::default(),

View File

@ -38,6 +38,8 @@ By using static data, we can use known fingerprints in the examples.
- `sq sign --detached --signer-file juliet-secret.pgp document.txt > document.sig`
- `sq verify --signer-file juliet-secret.pgp --detached document.sig document.txt`
- document.pgp: An inline-signed document, equivalent to the above.
- message.pgp: A document encrypted for Bob, and signed by Alice.
- `echo 'Golf this afternoon?' | sq encrypt --recipient-file bob-secret.pgp --signer-file alice-secret.pgp > message.pgp`

View File

@ -0,0 +1,9 @@
-----BEGIN PGP MESSAGE-----
xA0DAAoWgwSEvazMQyUAyxxiAAAAAABJbXBvcnRhbnQgYmxhaCwgYmxhaC4Kwr0E
ABYKAG8FgmXxa5IJEIMEhL2szEMlRxQAAAAAAB4AIHNhbHRAbm90YXRpb25zLnNl
cXVvaWEtcGdwLm9yZ231Pyp72PaeRUCoTgZ9zMup1KjxAbUtf8+F6A7iU+2HFiEE
zb/YfSE60fznV0XtgwSEvazMQyUAAJyuAQDaJBP7U79ef2jlO9opGRt6+XZh5hk3
BFMH6p92SquVuwD+LoAxLQmp+U68U3BVN0R81Ncd1XZ/VwIsbteTEa2KEwQ=
=Q9mj
-----END PGP MESSAGE-----