diff options
author | Heiko Schaefer <heiko@schaefer.name> | 2021-11-03 21:19:59 +0100 |
---|---|---|
committer | Heiko Schaefer <heiko@schaefer.name> | 2021-11-03 21:19:59 +0100 |
commit | 690b097bbded71514c57a09b6a0a23c8c0647d99 (patch) | |
tree | 8ab3aaccc09067fca256ae6e45c0628607badc46 | |
parent | f42783dc141106711259f8b9d6a9bb2f260e5b41 (diff) | |
download | openpgp-ca-690b097bbded71514c57a09b6a0a23c8c0647d99.tar.gz |
Clippy lints.
-rw-r--r-- | openpgp-ca-lib/src/ca.rs | 24 | ||||
-rw-r--r-- | openpgp-ca-lib/src/ca_secret.rs | 2 | ||||
-rw-r--r-- | openpgp-ca-lib/src/cert.rs | 12 | ||||
-rw-r--r-- | openpgp-ca-lib/src/db/mod.rs | 2 | ||||
-rw-r--r-- | openpgp-ca-lib/src/export.rs | 2 | ||||
-rw-r--r-- | openpgp-ca-lib/src/pgp.rs | 6 | ||||
-rw-r--r-- | openpgp-ca-lib/src/revocation.rs | 4 | ||||
-rw-r--r-- | openpgp-ca-lib/src/update.rs | 2 | ||||
-rw-r--r-- | openpgp-ca-lib/tests/test_gpg.rs | 30 | ||||
-rw-r--r-- | openpgp-ca-lib/tests/test_oca.rs | 82 |
10 files changed, 80 insertions, 86 deletions
diff --git a/openpgp-ca-lib/src/ca.rs b/openpgp-ca-lib/src/ca.rs index e075553..9306cef 100644 --- a/openpgp-ca-lib/src/ca.rs +++ b/openpgp-ca-lib/src/ca.rs @@ -303,7 +303,7 @@ impl OpenpgpCa { ) -> Result<()> { self.db().transaction(|| { cert::user_new( - &self, + self, name, emails, duration_days, @@ -369,7 +369,7 @@ impl OpenpgpCa { &self, user: &models::User, ) -> Result<Vec<models::Cert>> { - self.db.certs_by_user(&user) + self.db.certs_by_user(user) } /// Get a list of all Users, ordered by name @@ -408,7 +408,7 @@ impl OpenpgpCa { let db_users = self.users_get_all()?; for db_user in &db_users { - for db_cert in self.get_certs_by_user(&db_user)? { + for db_cert in self.get_certs_by_user(db_user)? { let (sig_from_ca, tsig_on_ca) = self.check_mutual_certifications(&db_cert)?; @@ -549,7 +549,7 @@ impl OpenpgpCa { /// cert. Only if this is successful is the revocation stored. pub fn revocation_add(&self, revoc_cert_str: &str) -> Result<()> { self.db() - .transaction(|| revocation::revocation_add(&self, revoc_cert_str)) + .transaction(|| revocation::revocation_add(self, revoc_cert_str)) } /// Add a revocation certificate to the OpenPGP CA database (from a file). @@ -577,7 +577,7 @@ impl OpenpgpCa { /// The revocation is merged into out copy of the OpenPGP Cert. pub fn revocation_apply(&self, revoc: models::Revocation) -> Result<()> { self.db() - .transaction(|| revocation::revocation_apply(&self, revoc)) + .transaction(|| revocation::revocation_apply(self, revoc)) } /// Get reason and creation time for a Revocation @@ -678,7 +678,7 @@ impl OpenpgpCa { if commit { self.db.transaction::<_, anyhow::Error, _>(|| { let (bridge, fingerprint) = - bridge::bridge_new(&self, key_file, email, scope)?; + bridge::bridge_new(self, key_file, email, scope)?; println!( "Signed OpenPGP key for {} as bridge.\n", @@ -756,7 +756,7 @@ impl OpenpgpCa { /// /// https://tools.ietf.org/html/draft-koch-openpgp-webkey-service-08 pub fn export_wkd(&self, domain: &str, path: &Path) -> Result<()> { - export::wkd_export(&self, domain, path) + export::wkd_export(self, domain, path) } /// Export the contents of a CA in Keylist format. @@ -777,7 +777,7 @@ impl OpenpgpCa { signature_uri: String, force: bool, ) -> Result<()> { - export::export_keylist(&self, path, signature_uri, force) + export::export_keylist(self, path, signature_uri, force) } /// Export Certs from this CA into files, with filenames based on email @@ -787,11 +787,11 @@ impl OpenpgpCa { email_filter: Option<String>, path: &str, ) -> Result<()> { - export::export_certs_as_files(&self, email_filter, path) + export::export_certs_as_files(self, email_filter, path) } pub fn print_certring(&self, email_filter: Option<String>) -> Result<()> { - export::print_certring(&self, email_filter) + export::print_certring(self, email_filter) } // -------- Update certs from public sources @@ -801,7 +801,7 @@ impl OpenpgpCa { pub fn update_from_wkd(&self) -> Result<()> { for c in self.user_certs_get_all()? { self.db().transaction::<_, anyhow::Error, _>(|| { - let updated = update::update_from_wkd(&self, &c)?; + let updated = update::update_from_wkd(self, &c)?; if updated { println!("Got update for cert {}", c.fingerprint); } @@ -829,6 +829,6 @@ impl OpenpgpCa { /// Returns "true" if updated data was received, false if not. pub fn update_from_hagrid(&self, cert: &models::Cert) -> Result<bool> { self.db() - .transaction(|| update::update_from_hagrid(&self, cert)) + .transaction(|| update::update_from_hagrid(self, cert)) } } diff --git a/openpgp-ca-lib/src/ca_secret.rs b/openpgp-ca-lib/src/ca_secret.rs index 47d758e..93b1379 100644 --- a/openpgp-ca-lib/src/ca_secret.rs +++ b/openpgp-ca-lib/src/ca_secret.rs @@ -439,7 +439,7 @@ adversaries."#; ReasonForRevocation::Unspecified, b"removing OpenPGP CA bridge", )? - .build(signer, &remote_ca, remote_uid, None)?; + .build(signer, remote_ca, remote_uid, None)?; let revoked = remote_ca .clone() diff --git a/openpgp-ca-lib/src/cert.rs b/openpgp-ca-lib/src/cert.rs index 63c7891..9417092 100644 --- a/openpgp-ca-lib/src/cert.rs +++ b/openpgp-ca-lib/src/cert.rs @@ -34,7 +34,7 @@ pub fn user_new( // CA certifies user cert let user_certified = - sign_cert_emails(&oca, &user_key, Some(emails), duration_days) + sign_cert_emails(oca, &user_key, Some(emails), duration_days) .context("sign_user_emails failed")?; // User tsigns CA cert @@ -107,7 +107,7 @@ pub fn cert_import_new( // Sign user cert with CA key (only the User IDs that have been specified) let certified = - sign_cert_emails(&oca, &user_cert, Some(emails), duration_days) + sign_cert_emails(oca, &user_cert, Some(emails), duration_days) .context("sign_cert_emails() failed")?; // use name from User IDs, if no name was passed @@ -128,7 +128,7 @@ pub fn cert_import_new( .context("cert_import_new: Couldn't re-armor key")?; oca.db() - .user_add(name.as_deref(), (&pub_cert, &fp), &emails, &revoc_certs) + .user_add(name.as_deref(), (&pub_cert, &fp), emails, &revoc_certs) .context("Couldn't insert user")?; Ok(()) @@ -258,11 +258,11 @@ pub fn check_mutual_certifications( cert: &models::Cert, ) -> Result<(Vec<UserID>, bool)> { let sig_from_ca = oca - .cert_check_ca_sig(&cert) + .cert_check_ca_sig(cert) .context("Failed while checking CA sig")?; let tsig_on_ca = oca - .cert_check_tsig_on_ca(&cert) + .cert_check_tsig_on_ca(cert) .context("Failed while checking tsig on CA")?; Ok((sig_from_ca, tsig_on_ca)) @@ -277,7 +277,7 @@ pub fn cert_check_ca_sig( Ok(c.userids() .filter(|uid| { - !Pgp::valid_certifications_by(&uid, &c, ca.clone()).is_empty() + !Pgp::valid_certifications_by(uid, &c, ca.clone()).is_empty() }) .map(|uid| uid.userid()) .cloned() diff --git a/openpgp-ca-lib/src/db/mod.rs b/openpgp-ca-lib/src/db/mod.rs index dee370f..b69b78b 100644 --- a/openpgp-ca-lib/src/db/mod.rs +++ b/openpgp-ca-lib/src/db/mod.rs @@ -24,7 +24,7 @@ pub struct OcaDb { impl OcaDb { pub fn new(db_url: &str) -> Result<Self> { - let conn = SqliteConnection::establish(&db_url) + let conn = SqliteConnection::establish(db_url) .context(format!("Error connecting to {}", db_url))?; // Enable handling of foreign key constraints in sqlite diff --git a/openpgp-ca-lib/src/export.rs b/openpgp-ca-lib/src/export.rs index dc356b7..5fa3757 100644 --- a/openpgp-ca-lib/src/export.rs +++ b/openpgp-ca-lib/src/export.rs @@ -190,7 +190,7 @@ pub fn export_keylist( // .. and add all user certs that were certified by this CA. for user in &oca.users_get_all()? { - for cert in oca.get_certs_by_user(&user)? { + for cert in oca.get_certs_by_user(user)? { // Create Keylist entry for each User ID that the CA has certified for uid in oca.cert_check_ca_sig(&cert)? { if let Ok(Some(email)) = uid.email() { diff --git a/openpgp-ca-lib/src/pgp.rs b/openpgp-ca-lib/src/pgp.rs index 4eafcc4..002e1e2 100644 --- a/openpgp-ca-lib/src/pgp.rs +++ b/openpgp-ca-lib/src/pgp.rs @@ -326,7 +326,7 @@ impl Pgp { signer: &Cert, pass: Option<&str>, ) -> Result<Cert> { - let mut cert_keys = Self::get_cert_keys(&signer, pass); + let mut cert_keys = Self::get_cert_keys(signer, pass); if cert_keys.is_empty() { return Err(anyhow::anyhow!( @@ -382,7 +382,7 @@ impl Pgp { // -------- helper functions pub fn print_cert_info(armored: &str) -> Result<()> { - let c = Pgp::armored_to_cert(&armored)?; + let c = Pgp::armored_to_cert(armored)?; for uid in c.userids() { println!("User ID: {}", uid.userid()); } @@ -464,7 +464,7 @@ impl Pgp { .filter(|&s| { // check if the apparent certification by `certifier` is valid certifier_keys.iter().any(|signer| { - s.clone().verify_userid_binding(&signer, &pk, &uid).is_ok() + s.clone().verify_userid_binding(signer, &pk, uid).is_ok() }) }) .cloned() diff --git a/openpgp-ca-lib/src/revocation.rs b/openpgp-ca-lib/src/revocation.rs index 0fa2d97..d703a93 100644 --- a/openpgp-ca-lib/src/revocation.rs +++ b/openpgp-ca-lib/src/revocation.rs @@ -56,7 +56,7 @@ pub fn revocation_add(oca: &OpenpgpCa, revocation: &str) -> Result<()> { } // 2) If match by fingerprint failed: test revocation for each cert if cert.is_none() { - cert = search_revocable_cert_by_keyid(&oca, &mut revocation)?; + cert = search_revocable_cert_by_keyid(oca, &mut revocation)?; } if let Some(cert) = cert { @@ -64,7 +64,7 @@ pub fn revocation_add(oca: &OpenpgpCa, revocation: &str) -> Result<()> { // verify that revocation certificate validates with cert if validate_revocation(&c, &mut revocation)? { - if !check_for_equivalent_revocation(&oca, &revocation, &cert)? { + if !check_for_equivalent_revocation(oca, &revocation, &cert)? { // update sig in DB let armored = Pgp::revoc_to_armored(&revocation, None) .context("couldn't armor revocation cert")?; diff --git a/openpgp-ca-lib/src/update.rs b/openpgp-ca-lib/src/update.rs index ceb7358..c613e8d 100644 --- a/openpgp-ca-lib/src/update.rs +++ b/openpgp-ca-lib/src/update.rs @@ -26,7 +26,7 @@ use tokio::runtime::Runtime; pub fn update_from_wkd(oca: &OpenpgpCa, cert: &models::Cert) -> Result<bool> { let mut rt = Runtime::new()?; - let emails = oca.emails_get(&cert)?; + let emails = oca.emails_get(cert)?; // Collect all updates for 'cert' in 'merge' let orig = Pgp::armored_to_cert(&cert.pub_cert)?; diff --git a/openpgp-ca-lib/tests/test_gpg.rs b/openpgp-ca-lib/tests/test_gpg.rs index e3b79ed..435c74e 100644 --- a/openpgp-ca-lib/tests/test_gpg.rs +++ b/openpgp-ca-lib/tests/test_gpg.rs @@ -38,8 +38,8 @@ fn test_alice_authenticates_bob_centralized() -> Result<()> { ca.ca_init("example.org", None)?; // make CA users - ca.user_new(Some(&"Alice"), &["alice@example.org"], None, false, false)?; - ca.user_new(Some(&"Bob"), &["bob@example.org"], None, false, false)?; + ca.user_new(Some("Alice"), &["alice@example.org"], None, false, false)?; + ca.user_new(Some("Bob"), &["bob@example.org"], None, false, false)?; // ---- import keys from OpenPGP CA into GnuPG ---- @@ -139,8 +139,8 @@ fn test_alice_authenticates_bob_decentralized() -> Result<()> { gpg_bob.tsign(&ca_keyid, 1, 2).expect("tsign bob failed"); // export CA key from both contexts, import to CA - let alice_ca_key = gpg_alice.export(&"openpgp-ca@example.org"); - let bob_ca_key = gpg_bob.export(&"openpgp-ca@example.org"); + let alice_ca_key = gpg_alice.export("openpgp-ca@example.org"); + let bob_ca_key = gpg_bob.export("openpgp-ca@example.org"); ca.ca_import_tsig(&alice_ca_key) .context("import CA tsig from Alice failed")?; @@ -148,8 +148,8 @@ fn test_alice_authenticates_bob_decentralized() -> Result<()> { .context("import CA tsig from Bob failed")?; // get public keys for alice and bob from their gnupg contexts - let alice_key = gpg_alice.export(&"alice@example.org"); - let bob_key = gpg_bob.export(&"bob@example.org"); + let alice_key = gpg_alice.export("alice@example.org"); + let bob_key = gpg_bob.export("bob@example.org"); // import public keys for alice and bob into CA ca.cert_import_new( @@ -172,7 +172,7 @@ fn test_alice_authenticates_bob_decentralized() -> Result<()> { // export bob, CA-key from CA let ca_key = ca.ca_get_pubkey_armored()?; - let certs = ca.certs_by_email(&"bob@example.org")?; + let certs = ca.certs_by_email("bob@example.org")?; let bob = certs.first().unwrap(); // import bob+CA key into alice's GnuPG context @@ -239,7 +239,7 @@ fn test_bridge() -> Result<()> { // make CA user assert!(ca1 - .user_new(Some(&"Alice"), &["alice@some.org"], None, false, false) + .user_new(Some("Alice"), &["alice@some.org"], None, false, false) .is_ok()); // ---- populate second OpenPGP CA instance ---- @@ -248,10 +248,10 @@ fn test_bridge() -> Result<()> { ca2.ca_init("other.org", None)?; // make CA user - ca2.user_new(Some(&"Bob"), &["bob@other.org"], None, false, false)?; + ca2.user_new(Some("Bob"), &["bob@other.org"], None, false, false)?; // make CA user that is out of the domain scope for ca2 - ca2.user_new(Some(&"Carol"), &["carol@third.org"], None, false, false)?; + ca2.user_new(Some("Carol"), &["carol@third.org"], None, false, false)?; // ---- setup bridges: scoped trust between one.org and two.org --- @@ -372,13 +372,13 @@ fn test_multi_bridge() -> Result<()> { // ---- populate OpenPGP CA instances ---- ca1.ca_init("alpha.org", None)?; - ca1.user_new(Some(&"Alice"), &["alice@alpha.org"], None, false, false)?; + ca1.user_new(Some("Alice"), &["alice@alpha.org"], None, false, false)?; ca2.ca_init("beta.org", None)?; ca3.ca_init("gamma.org", None)?; - ca3.user_new(Some(&"Carol"), &["carol@gamma.org"], None, false, false)?; - ca3.user_new(Some(&"Bob"), &["bob@beta.org"], None, false, false)?; + ca3.user_new(Some("Carol"), &["carol@gamma.org"], None, false, false)?; + ca3.user_new(Some("Bob"), &["bob@beta.org"], None, false, false)?; // ---- set up bridges: scoped trust between alpha<->beta and beta<->gamma --- let ca2_file = format!("{}/ca2.pubkey", home_path); @@ -497,12 +497,12 @@ fn test_scoping() -> Result<()> { // ---- populate OpenPGP CA instances ---- ca1.ca_init("alpha.org", None)?; - ca1.user_new(Some(&"Alice"), &["alice@alpha.org"], None, false, false)?; + ca1.user_new(Some("Alice"), &["alice@alpha.org"], None, false, false)?; ca2.ca_init("beta.org", None)?; ca3.ca_init("other.org", None)?; - ca3.user_new(Some(&"Bob"), &["bob@beta.org"], None, false, false)?; + ca3.user_new(Some("Bob"), &["bob@beta.org"], None, false, false)?; // ---- set up bridges: scoped trust between alpha<->beta and beta<->gamma --- let ca2_file = format!("{}/ca2.pubkey", home_path); diff --git a/openpgp-ca-lib/tests/test_oca.rs b/openpgp-ca-lib/tests/test_oca.rs index 586c64d..2f7815e 100644 --- a/openpgp-ca-lib/tests/test_oca.rs +++ b/openpgp-ca-lib/tests/test_oca.rs @@ -44,7 +44,7 @@ fn test_ca() -> Result<()> { ca.ca_init("example.org", Some("Example Org OpenPGP CA Key"))?; // make CA user - ca.user_new(Some(&"Alice"), &["alice@example.org"], None, false, false)?; + ca.user_new(Some("Alice"), &["alice@example.org"], None, false, false)?; let certs = ca.user_certs_get_all()?; @@ -96,7 +96,7 @@ fn test_expiring_certification() -> Result<()> { // make CA user ca.user_new( - Some(&"Alice"), + Some("Alice"), &["alice@example.org"], Some(365), false, @@ -173,7 +173,7 @@ fn test_update_cert_key() -> Result<()> { // import key as new user gpg.create_user("alice@example.org"); - let alice1_key = gpg.export(&"alice@example.org"); + let alice1_key = gpg.export("alice@example.org"); ca.cert_import_new( &alice1_key, @@ -206,7 +206,7 @@ fn test_update_cert_key() -> Result<()> { // edit key with gpg, then import new version into CA gpg.edit_expire("alice@example.org", "5y")?; - let alice2_key = gpg.export(&"alice@example.org"); + let alice2_key = gpg.export("alice@example.org"); // get cert for alice let certs = ca.certs_by_email("alice@example.org")?; @@ -253,7 +253,7 @@ fn test_ca_import() -> Result<()> { // import key as new user gpg.create_user("alice@example.org"); - let alice1_key = gpg.export(&"alice@example.org"); + let alice1_key = gpg.export("alice@example.org"); ca.cert_import_new( &alice1_key, @@ -283,7 +283,7 @@ fn test_ca_import() -> Result<()> { // make a new key gpg.create_user("bob@example.org"); - let bob_key = gpg.export(&"bob@example.org"); + let bob_key = gpg.export("bob@example.org"); // call "cert_import_update" with a new key @@ -314,10 +314,10 @@ fn test_ca_insert_duplicate_email() -> Result<()> { assert!(ca.ca_init("example.org", None).is_ok()); // make CA user - ca.user_new(Some(&"Alice"), &["alice@example.org"], None, false, false)?; + ca.user_new(Some("Alice"), &["alice@example.org"], None, false, false)?; // make another CA user with the same email address - ca.user_new(Some(&"Alice"), &["alice@example.org"], None, false, false)?; + ca.user_new(Some("Alice"), &["alice@example.org"], None, false, false)?; let certs = ca.user_certs_get_all()?; @@ -325,7 +325,7 @@ fn test_ca_insert_duplicate_email() -> Result<()> { // ca cert should be tsigned by all user certs. for c in &certs { - let tsig = ca.cert_check_tsig_on_ca(&c)?; + let tsig = ca.cert_check_tsig_on_ca(c)?; assert!(tsig); } @@ -350,25 +350,25 @@ fn test_ca_export_wkd() -> Result<()> { let ca = OpenpgpCa::new(Some(&db))?; ca.ca_init("example.org", None)?; - ca.user_new(Some(&"Alice"), &["alice@example.org"], None, false, false)?; + ca.user_new(Some("Alice"), &["alice@example.org"], None, false, false)?; ca.user_new( - Some(&"Bob"), + Some("Bob"), &["bob@example.org", "bob@other.org"], None, false, false, )?; - ca.user_new(Some(&"Carol"), &["carol@other.org"], None, false, false)?; + ca.user_new(Some("Carol"), &["carol@other.org"], None, false, false)?; let wkd_dir = home_path + "/wkd/"; let wkd_path = Path::new(&wkd_dir); - ca.export_wkd("example.org", &wkd_path)?; + ca.export_wkd("example.org", wkd_path)?; // expect 3 exported keys (carol should not be in the export) let test_path = wkd_path.join(".well-known/openpgpkey/example.org/hu/"); - let paths: Vec<_> = fs::read_dir(test_path)?.collect(); - assert_eq!(paths.len(), 3); + let paths = fs::read_dir(test_path)?; + assert_eq!(paths.count(), 3); // check that both user keys have been written to files let test_path = wkd_path.join( @@ -459,7 +459,7 @@ fn test_ca_export_wkd_sequoia() -> Result<()> { let wkd_dir = home_path + "/wkd/"; let wkd_path = Path::new(&wkd_dir); - ca.export_wkd("sequoia-pgp.org", &wkd_path)?; + ca.export_wkd("sequoia-pgp.org", wkd_path)?; Ok(()) } @@ -485,7 +485,7 @@ fn test_ca_multiple_revocations() -> Result<()> { // gpg: make key for Alice gpg.create_user("Alice <alice@example.org>"); - let alice_key = gpg.export(&"alice@example.org"); + let alice_key = gpg.export("alice@example.org"); ca.cert_import_new( &alice_key, @@ -513,7 +513,7 @@ fn test_ca_multiple_revocations() -> Result<()> { let alice = &certs[0]; // check that name has been autodetected on CA import from the pubkey - let name = ca.cert_get_name(&alice)?; + let name = ca.cert_get_name(alice)?; assert_eq!(name, "Alice".to_string()); let emails = ca.emails_get(alice)?; @@ -551,7 +551,7 @@ fn test_ca_signatures() -> Result<()> { // create/import alice, CA signs alice's key gpg.create_user("alice@example.org"); - let alice_key = gpg.export(&"alice@example.org"); + let alice_key = gpg.export("alice@example.org"); ca.cert_import_new( &alice_key, @@ -564,7 +564,7 @@ fn test_ca_signatures() -> Result<()> { // create/import bob gpg.create_user("bob@example.org"); - let bob_key = gpg.export(&"bob@example.org"); + let bob_key = gpg.export("bob@example.org"); // CA does not signs bob's key because the "email" parameter is empty. // Only userids that are supplied in `email` are signed by the CA. @@ -573,7 +573,7 @@ fn test_ca_signatures() -> Result<()> { // create carol, CA will sign carol's key. // also, CA key gets a tsig by carol - ca.user_new(Some(&"Carol"), &["carol@example.org"], None, false, false)?; + ca.user_new(Some("Carol"), &["carol@example.org"], None, false, false)?; for user in ca.users_get_all()? { let certs = ca.get_certs_by_user(&user)?; @@ -620,7 +620,7 @@ fn test_apply_revocation() -> Result<()> { ca.ca_init("example.org", None)?; // make CA user - ca.user_new(Some(&"Alice"), &["alice@example.org"], None, false, false)?; + ca.user_new(Some("Alice"), &["alice@example.org"], None, false, false)?; let certs = ca.user_certs_get_all()?; @@ -668,7 +668,7 @@ fn test_import_signed_cert() -> Result<()> { gpg.sign("alice@example.org").expect("signing alice failed"); // import alice into OpenPGP CA - let alice_key = gpg.export(&"alice@example.org"); + let alice_key = gpg.export("alice@example.org"); ca.cert_import_new( &alice_key, vec![], @@ -739,11 +739,11 @@ fn test_revocation_no_fingerprint() -> Result<()> { ca.ca_init("example.org", None)?; // create Alice - ca.user_new(Some(&"Alice"), &["alice@example.org"], None, false, false)?; + ca.user_new(Some("Alice"), &["alice@example.org"], None, false, false)?; // gpg: make key for Bob gpg.create_user("Bob <bob@example.org>"); - let bob_key = gpg.export(&"bob@example.org"); + let bob_key = gpg.export("bob@example.org"); ca.cert_import_new(&bob_key, vec![], None, &[], None)?; // make a revocation certificate for bob ... @@ -756,7 +756,7 @@ fn test_revocation_no_fingerprint() -> Result<()> { let armored = if let openpgp::Packet::Signature(s) = p { // use Bob as a Signer - let bob_sec = gpg.export_secret(&"bob@example.org"); + let bob_sec = gpg.export_secret("bob@example.org"); let bob_cert = Cert::from_bytes(&bob_sec)?; let mut keypair = bob_cert .primary_key() @@ -825,7 +825,7 @@ fn test_revocation_no_fingerprint() -> Result<()> { let alice = certs .iter() .find(|c| { - ca.cert_get_users(&c) + ca.cert_get_users(c) .unwrap() .iter() .any(|u| u.name == Some("Alice".to_owned())) @@ -839,7 +839,7 @@ fn test_revocation_no_fingerprint() -> Result<()> { let bob = certs .iter() .find(|c| { - ca.cert_get_users(&c) + ca.cert_get_users(c) .unwrap() .iter() .any(|u| u.name == Some("Bob".to_owned())) @@ -867,7 +867,7 @@ fn test_create_user_with_pw() -> Result<()> { ca.ca_init("example.org", None)?; // make CA user - ca.user_new(Some(&"Alice"), &["alice@example.org"], None, true, false)?; + ca.user_new(Some("Alice"), &["alice@example.org"], None, true, false)?; let certs = ca.user_certs_get_all()?; assert_eq!(certs.len(), 1); @@ -900,16 +900,10 @@ fn test_refresh() -> Result<()> { let ca_fp = ca_cert.fingerprint(); // make CA user - ca.user_new( - Some(&"Alice"), - &["alice@example.org"], - Some(10), - true, - false, - )?; - ca.user_new(Some(&"Bob"), &["bob@example.org"], Some(365), true, false)?; - ca.user_new(Some(&"Carol"), &["carol@example.org"], None, true, false)?; - ca.user_new(Some(&"Dave"), &["dave@example.org"], Some(10), true, false)?; + ca.user_new(Some("Alice"), &["alice@example.org"], Some(10), true, false)?; + ca.user_new(Some("Bob"), &["bob@example.org"], Some(365), true, false)?; + ca.user_new(Some("Carol"), &["carol@example.org"], None, true, false)?; + ca.user_new(Some("Dave"), &["dave@example.org"], Some(10), true, false)?; // set dave to "inactive" let cert = ca.certs_by_email("dave@example.org")?; @@ -984,8 +978,8 @@ fn test_wkd_delist() -> Result<()> { ca.ca_init("example.org", None)?; // make CA users - ca.user_new(Some(&"Alice"), &["alice@example.org"], None, true, false)?; - ca.user_new(Some(&"Bob"), &["bob@example.org"], None, true, false)?; + ca.user_new(Some("Alice"), &["alice@example.org"], None, true, false)?; + ca.user_new(Some("Bob"), &["bob@example.org"], None, true, false)?; // set bob to "delisted" let cert = ca.certs_by_email("bob@example.org")?; @@ -998,12 +992,12 @@ fn test_wkd_delist() -> Result<()> { let wkd_dir = home_path + "/wkd/"; let wkd_path = Path::new(&wkd_dir); - ca.export_wkd("example.org", &wkd_path)?; + ca.export_wkd("example.org", wkd_path)?; // expect 3 exported keys (carol should not be in the export) let test_path = wkd_path.join(".well-known/openpgpkey/example.org/hu/"); - let paths: Vec<_> = fs::read_dir(test_path)?.collect(); - assert_eq!(paths.len(), 2); + let paths = fs::read_dir(test_path)?; + assert_eq!(paths.count(), 2); // check that Alice's and the CA's keys have been written to files |