27093c1709
- Support using keys managed by `sequoia-keystore`. - When decrypting a message, have `sq` automatically ask the key store to decrypt the PKESKs. - Extend `sq sign` and `sq encrypt` with the `--signer-key` parameter to use a key managed by the keystore. - Add two top-level options: `--no-key-store`, which disables the use of the key store, and `--key-store`, which uses an alternate key store instance. - Add `sq key list` to list keys on the key store.
48 lines
1.2 KiB
Rust
48 lines
1.2 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",
|
|
"--time", iso8601,
|
|
"--expiry", "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(())
|
|
}
|
|
}
|