db,hagridctl: Autofix clippy issues
This commit is contained in:
parent
1802cc6811
commit
e00cae5a4e
|
@ -837,24 +837,25 @@ mod tests {
|
|||
.unwrap()
|
||||
.0;
|
||||
|
||||
assert!(db.merge(k1).unwrap().into_tpk_status().email_status.len() > 0);
|
||||
assert!(
|
||||
db.merge(k2.clone())
|
||||
.unwrap()
|
||||
.into_tpk_status()
|
||||
.email_status
|
||||
.len()
|
||||
> 0
|
||||
);
|
||||
assert!(!db
|
||||
.merge(k1)
|
||||
.unwrap()
|
||||
.into_tpk_status()
|
||||
.email_status
|
||||
.is_empty());
|
||||
assert!(!db
|
||||
.merge(k2.clone())
|
||||
.unwrap()
|
||||
.into_tpk_status()
|
||||
.email_status
|
||||
.is_empty());
|
||||
assert!(!db.merge(k2).unwrap().into_tpk_status().email_status.len() > 0);
|
||||
assert!(
|
||||
db.merge(k3.clone())
|
||||
.unwrap()
|
||||
.into_tpk_status()
|
||||
.email_status
|
||||
.len()
|
||||
> 0
|
||||
);
|
||||
assert!(!db
|
||||
.merge(k3.clone())
|
||||
.unwrap()
|
||||
.into_tpk_status()
|
||||
.email_status
|
||||
.is_empty());
|
||||
assert!(
|
||||
!db.merge(k3.clone())
|
||||
.unwrap()
|
||||
|
|
|
@ -100,7 +100,7 @@ pub fn test_uid_verification(db: &mut impl Database, log_path: &Path) {
|
|||
let raw = db.by_fpr(&fpr).unwrap();
|
||||
let key = Cert::from_bytes(raw.as_bytes()).unwrap();
|
||||
|
||||
assert!(key.userids().skip(1).next().is_none());
|
||||
assert!(key.userids().nth(1).is_none());
|
||||
assert!(key.user_attributes().next().is_none());
|
||||
assert!(key.keys().subkeys().next().is_none());
|
||||
|
||||
|
@ -128,7 +128,7 @@ pub fn test_uid_verification(db: &mut impl Database, log_path: &Path) {
|
|||
let raw = db.by_fpr(&fpr).unwrap();
|
||||
let key = Cert::from_bytes(raw.as_bytes()).unwrap();
|
||||
|
||||
assert!(key.userids().skip(1).next().is_none());
|
||||
assert!(key.userids().nth(1).is_none());
|
||||
assert!(key.user_attributes().next().is_none());
|
||||
assert!(key.keys().subkeys().next().is_none());
|
||||
|
||||
|
@ -161,7 +161,7 @@ pub fn test_uid_verification(db: &mut impl Database, log_path: &Path) {
|
|||
assert!(key.keys().subkeys().next().is_none());
|
||||
|
||||
let myuid1 = key.userids().next().unwrap().userid().clone();
|
||||
let myuid2 = key.userids().skip(1).next().unwrap().userid().clone();
|
||||
let myuid2 = key.userids().nth(1).unwrap().userid().clone();
|
||||
|
||||
assert_eq!(db.by_email(&email1).unwrap(), raw);
|
||||
assert_eq!(db.by_email(&email2).unwrap(), raw);
|
||||
|
@ -208,7 +208,7 @@ pub fn test_uid_verification(db: &mut impl Database, log_path: &Path) {
|
|||
assert!(key.keys().subkeys().next().is_none());
|
||||
|
||||
let myuid1 = key.userids().next().unwrap().userid().clone();
|
||||
let myuid2 = key.userids().skip(1).next().unwrap().userid().clone();
|
||||
let myuid2 = key.userids().nth(1).unwrap().userid().clone();
|
||||
|
||||
assert_eq!(db.by_email(&email1).unwrap(), raw);
|
||||
assert_eq!(db.by_email(&email2).unwrap(), raw);
|
||||
|
@ -1331,7 +1331,7 @@ pub fn attested_key_signatures(db: &mut impl Database, log_path: &Path) -> Resul
|
|||
|
||||
// Have Alice certify the binding between "bob@bar.com" and
|
||||
// Bob's key.
|
||||
let alice_certifies_bob = bob.userids().nth(0).unwrap().userid().bind(
|
||||
let alice_certifies_bob = bob.userids().next().unwrap().userid().bind(
|
||||
&mut alice_signer,
|
||||
&bob,
|
||||
SignatureBuilder::new(SignatureType::GenericCertification)
|
||||
|
@ -1361,7 +1361,7 @@ pub fn attested_key_signatures(db: &mut impl Database, log_path: &Path) -> Resul
|
|||
check_log_entry(log_path, &bobs_fp);
|
||||
let bob_ = Cert::from_bytes(&db.by_fpr(&bobs_fp).unwrap())?;
|
||||
assert_eq!(bob_.bad_signatures().count(), 0);
|
||||
assert_eq!(bob_.userids().nth(0).unwrap().certifications().count(), 0);
|
||||
assert_eq!(bob_.userids().next().unwrap().certifications().count(), 0);
|
||||
|
||||
// Add the attestation, merge into the db, check that the
|
||||
// certification is now included.
|
||||
|
@ -1370,11 +1370,11 @@ pub fn attested_key_signatures(db: &mut impl Database, log_path: &Path) -> Resul
|
|||
check_log_entry(log_path, &bobs_fp);
|
||||
let bob_ = Cert::from_bytes(&db.by_fpr(&bobs_fp).unwrap())?;
|
||||
assert_eq!(bob_.bad_signatures().count(), 0);
|
||||
assert_eq!(bob_.userids().nth(0).unwrap().certifications().count(), 1);
|
||||
assert_eq!(bob_.userids().next().unwrap().certifications().count(), 1);
|
||||
assert_eq!(
|
||||
bob_.with_policy(&POLICY, None)?
|
||||
.userids()
|
||||
.nth(0)
|
||||
.next()
|
||||
.unwrap()
|
||||
.attestation_key_signatures()
|
||||
.count(),
|
||||
|
@ -1383,7 +1383,7 @@ pub fn attested_key_signatures(db: &mut impl Database, log_path: &Path) -> Resul
|
|||
assert_eq!(
|
||||
bob_.with_policy(&POLICY, None)?
|
||||
.userids()
|
||||
.nth(0)
|
||||
.next()
|
||||
.unwrap()
|
||||
.attested_certifications()
|
||||
.count(),
|
||||
|
@ -1396,7 +1396,7 @@ pub fn attested_key_signatures(db: &mut impl Database, log_path: &Path) -> Resul
|
|||
check_log_entry(log_path, &bobs_fp);
|
||||
let bob_ = Cert::from_bytes(&db.by_fpr(&bobs_fp).unwrap())?;
|
||||
assert_eq!(bob_.bad_signatures().count(), 0);
|
||||
assert_eq!(bob_.userids().nth(0).unwrap().certifications().count(), 1);
|
||||
assert_eq!(bob_.userids().next().unwrap().certifications().count(), 1);
|
||||
|
||||
// Finally, withdraw consent by overriding the attestation, merge
|
||||
// into the db, check that the certification is now gone.
|
||||
|
@ -1409,11 +1409,11 @@ pub fn attested_key_signatures(db: &mut impl Database, log_path: &Path) -> Resul
|
|||
let clear_attestation = attestations[0].clone();
|
||||
|
||||
let bob = bob.insert_packets(vec![clear_attestation])?;
|
||||
assert_eq!(bob.userids().nth(0).unwrap().certifications().count(), 1);
|
||||
assert_eq!(bob.userids().next().unwrap().certifications().count(), 1);
|
||||
assert_eq!(
|
||||
bob.with_policy(&POLICY, None)?
|
||||
.userids()
|
||||
.nth(0)
|
||||
.next()
|
||||
.unwrap()
|
||||
.attestation_key_signatures()
|
||||
.count(),
|
||||
|
@ -1422,7 +1422,7 @@ pub fn attested_key_signatures(db: &mut impl Database, log_path: &Path) -> Resul
|
|||
assert_eq!(
|
||||
bob.with_policy(&POLICY, None)?
|
||||
.userids()
|
||||
.nth(0)
|
||||
.next()
|
||||
.unwrap()
|
||||
.attested_certifications()
|
||||
.count(),
|
||||
|
@ -1433,11 +1433,11 @@ pub fn attested_key_signatures(db: &mut impl Database, log_path: &Path) -> Resul
|
|||
check_log_entry(log_path, &bobs_fp);
|
||||
let bob_ = Cert::from_bytes(&db.by_fpr(&bobs_fp).unwrap())?;
|
||||
assert_eq!(bob_.bad_signatures().count(), 0);
|
||||
assert_eq!(bob_.userids().nth(0).unwrap().certifications().count(), 0);
|
||||
assert_eq!(bob_.userids().next().unwrap().certifications().count(), 0);
|
||||
assert_eq!(
|
||||
bob_.with_policy(&POLICY, None)?
|
||||
.userids()
|
||||
.nth(0)
|
||||
.next()
|
||||
.unwrap()
|
||||
.attestation_key_signatures()
|
||||
.count(),
|
||||
|
@ -1446,7 +1446,7 @@ pub fn attested_key_signatures(db: &mut impl Database, log_path: &Path) -> Resul
|
|||
assert_eq!(
|
||||
bob_.with_policy(&POLICY, None)?
|
||||
.userids()
|
||||
.nth(0)
|
||||
.next()
|
||||
.unwrap()
|
||||
.attested_certifications()
|
||||
.count(),
|
||||
|
|
|
@ -151,20 +151,14 @@ fn import_from_file(db: &KeyDatabase, input: &Path, multi_progress: &MultiProgre
|
|||
|
||||
read_file_to_tpks(input_reader, &mut |acc| {
|
||||
let primary_key = acc[0].clone();
|
||||
let result = import_key(&db, acc);
|
||||
let result = import_key(db, acc);
|
||||
if let Err(ref e) = result {
|
||||
let key_fpr = match primary_key {
|
||||
Packet::PublicKey(key) => key.fingerprint().to_hex(),
|
||||
Packet::SecretKey(key) => key.fingerprint().to_hex(),
|
||||
_ => "Unknown".to_owned(),
|
||||
};
|
||||
let error = format!(
|
||||
"{}:{:05}:{}: {}",
|
||||
filename,
|
||||
stats.count_total,
|
||||
key_fpr,
|
||||
e.to_string()
|
||||
);
|
||||
let error = format!("{}:{:05}:{}: {}", filename, stats.count_total, key_fpr, e);
|
||||
progress_bar.println(error);
|
||||
}
|
||||
stats.update(result);
|
||||
|
@ -176,7 +170,7 @@ fn import_from_file(db: &KeyDatabase, input: &Path, multi_progress: &MultiProgre
|
|||
|
||||
fn read_file_to_tpks(
|
||||
reader: impl Read + Send + Sync,
|
||||
callback: &mut impl FnMut(Vec<Packet>) -> (),
|
||||
callback: &mut impl FnMut(Vec<Packet>),
|
||||
) -> Result<()> {
|
||||
let mut ppr = PacketParser::from_reader(reader)?;
|
||||
let mut acc = Vec::new();
|
||||
|
|
|
@ -46,7 +46,7 @@ impl<'a> RegenerateStats<'a> {
|
|||
}
|
||||
match result {
|
||||
Err(e) => {
|
||||
self.progress.println(format!("{}: {}", fpr, e.to_string()));
|
||||
self.progress.println(format!("{}: {}", fpr, e));
|
||||
self.count_err += 1;
|
||||
}
|
||||
Ok(RegenerateResult::Updated) => self.count_updated += 1,
|
||||
|
|
Loading…
Reference in New Issue