sequoia-sq/tests/sq-key-generate.rs
Neal H. Walfield 936ae250e1
Add support for a persistant certificate store
- Add support for a persistant certificate store using
    `sequoia-cert-store`.

  - Add `sq --no-cert-store` to disable the use of the certificate
    store.  Add `sq --cert-store PATH` to use an alternate certificate
    store.

  - Add `sq import` to import a certificate into the certificate
    store.  Add `sq export` to export certificates.

  - Modify `sq certify`, `sq encrypt`, and `sq verify` to lookup
    certificates in the certificate store, if it is configured.
2023-03-16 13:46:50 +01:00

47 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",
"key", "generate",
"--creation-time", iso8601,
"--expires", "never",
"--export", &*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(())
}
}