sequoia-sq/tests/integration/sq_cert_list.rs
Neal H. Walfield 84b1bf99c6
Fix sq cert list for fingerprints and key IDs.
- The implementation of `sq cert list` tried to parse the
    pattern.  To do so, it relied on type inference to determine how
    to parse it.  The type was inferred from the type of the `cert`
    parameter to `authenticate`.  In
    2e17dec9adccb571a5474ed487f3705b5fe9ddf8, the type of the `cert`
    parameter changed from `KeyHandle` to `Cert`.  `Cert` has a
    `Parse` implementation so the type system didn't detect anything
    wrong.  However, we were now trying to parse the pattern as a
    `Cert` instead of a `KeyHandle`, which would fail for key handles.

  - Fix it, and add some tests for `sq cert list`.
2024-11-16 21:19:28 +01:00

42 lines
1.1 KiB
Rust

use super::common::Sq;
#[test]
fn list() {
let sq = Sq::new();
let email = "alice@example.org";
let name = "Alice Lovelace";
let userid = &format!("{} <{}>", name, email);
let (cert, cert_path, _rev_path)
= sq.key_generate(&[], &[ userid ]);
sq.key_import(&cert_path);
sq.pki_link_add(&[], cert.key_handle(), &[ userid ]);
// By fingerprint.
sq.cert_list(&[&cert.fingerprint().to_string()]);
// By user ID.
sq.cert_list(&[userid]);
sq.cert_list(&["--userid", userid]);
// By email.
sq.cert_list(&[email]);
sq.cert_list(&["--email", email]);
// By name.
sq.cert_list(&[name]);
// By substring.
sq.cert_list(&["lice"]);
sq.cert_list(&["LICE"]);
sq.cert_list(&["example.or"]);
sq.cert_list(&["ExAmPlE.Or"]);
// When we use --userid, then we don't do substring matching.
assert!(sq.cert_list_maybe(&["--userid", &userid[1..]]).is_err());
// When we use --email, then we don't do substring matching.
assert!(sq.cert_list_maybe(&["--email", &email[1..]]).is_err());
}