bc5c0cf9f1
- Rename the `--expiry` argument to `--expiration`, and adjust the name of the corresponding fields, and data structures. - Expiration and expiry have about the same meaning. According to my research, "expiration" is used in American English whereas both are used in British English. - This change aligns the usage with RFC 4880's terminology, which uses the word "expiration" many times, but never uses "expiry".
49 lines
1.3 KiB
Rust
49 lines
1.3 KiB
Rust
use std::time;
|
|
|
|
use assert_cmd::Command;
|
|
use tempfile::TempDir;
|
|
|
|
use sequoia_openpgp as openpgp;
|
|
use openpgp::Result;
|
|
use openpgp::cert::prelude::*;
|
|
use openpgp::parse::Parse;
|
|
use openpgp::policy::StandardPolicy;
|
|
|
|
mod integration {
|
|
use super::*;
|
|
|
|
const P: &StandardPolicy = &StandardPolicy::new();
|
|
|
|
#[test]
|
|
fn sq_key_generate_creation_time() -> Result<()>
|
|
{
|
|
// $ date +'%Y%m%dT%H%M%S%z'; date +'%s'
|
|
let iso8601 = "20220120T163236+0100";
|
|
let t = 1642692756;
|
|
|
|
let dir = TempDir::new()?;
|
|
let key_pgp = dir.path().join("key.pgp");
|
|
|
|
// Build up the command line.
|
|
let mut cmd = Command::cargo_bin("sq")?;
|
|
cmd.args(["--no-cert-store",
|
|
"--no-key-store",
|
|
"key", "generate",
|
|
"--no-userids",
|
|
"--time", iso8601,
|
|
"--expiration", "never",
|
|
"--output", &*key_pgp.to_string_lossy()]);
|
|
|
|
cmd.assert().success();
|
|
|
|
let result = Cert::from_file(key_pgp)?;
|
|
let vc = result.with_policy(P, None)?;
|
|
|
|
assert_eq!(vc.primary_key().creation_time(),
|
|
time::UNIX_EPOCH + time::Duration::new(t, 0));
|
|
assert!(vc.primary_key().key_expiration_time().is_none());
|
|
|
|
Ok(())
|
|
}
|
|
}
|