diff --git a/src/cli/types.rs b/src/cli/types.rs index 3cba795a..23b4b6dc 100644 --- a/src/cli/types.rs +++ b/src/cli/types.rs @@ -59,6 +59,12 @@ where fn as_ref(&self) -> &T; } +impl MyAsRef for UserID { + fn as_ref(&self) -> &UserID { + self + } +} + impl MyAsRef for &UserID { fn as_ref(&self) -> &UserID { self diff --git a/src/commands/pki/link.rs b/src/commands/pki/link.rs index 1afa832e..f40363a1 100644 --- a/src/commands/pki/link.rs +++ b/src/commands/pki/link.rs @@ -191,7 +191,27 @@ pub fn list(sq: Sq, mut c: link::ListCommand) let (certs, errors) = if c.certs.is_empty() { (cert_store.certs(), Vec::new()) } else { - let (c, e) = sq.resolve_certs(&c.certs, 0)?; + let (c, e) = sq.resolve_certs_filter( + &c.certs, 0, &mut |designator, cert| { + let userids = cert.userids().filter(|uid| { + match designator.query_params() { + Err(_) => false, + Ok(None) => true, + Ok(Some((q, p))) => q.check(uid, &p), + } + }); + + if active_certification( + &sq, cert.to_cert()?, userids, trust_root_key) + .into_iter() + .filter(|(_uid, certification)| certification.is_some()) + .next().is_some() + { + Ok(()) + } else { + Err(anyhow::anyhow!("not linked")) + } + })?; (Box::new(c.into_iter().map(|c| Arc::new(LazyCert::from(c)))) as Box>>>, e) diff --git a/tests/integration/sq_pki_link_list.rs b/tests/integration/sq_pki_link_list.rs index 81b95d8c..e43b58bc 100644 --- a/tests/integration/sq_pki_link_list.rs +++ b/tests/integration/sq_pki_link_list.rs @@ -16,10 +16,7 @@ fn list_empty() { sq.key_import(cert_path); // Not linked => error. - - // Reenable when the following issue is fixed: - // https://gitlab.com/sequoia-pgp/sequoia-sq/-/issues/484 - //assert!(sq.try_pki_link_list(&["alice"]).is_err()); + assert!(sq.try_pki_link_list(&["alice"]).is_err()); // Not found => error. assert!(sq.try_pki_link_list(&["not found"]).is_err());