diff --git a/pbs-api-types/src/human_byte.rs b/pbs-api-types/src/human_byte.rs index 37a74f77..f9ac6d53 100644 --- a/pbs-api-types/src/human_byte.rs +++ b/pbs-api-types/src/human_byte.rs @@ -246,7 +246,7 @@ fn test_human_byte_parser() -> Result<(), Error> { } let new = h.to_string(); - if &new != as_str { + if new != *as_str { bail!("to_string failed for '{}' ({:?} != {:?})", v, new, as_str); } Ok(()) diff --git a/proxmox-file-restore/src/main.rs b/proxmox-file-restore/src/main.rs index a64ea936..105dc079 100644 --- a/proxmox-file-restore/src/main.rs +++ b/proxmox-file-restore/src/main.rs @@ -391,6 +391,7 @@ async fn list( } )] /// Restore files from a backup snapshot. +#[allow(clippy::too_many_arguments)] async fn extract( ns: Option, snapshot: String, diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index 7b103fb7..e66e1c0b 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -490,7 +490,7 @@ unsafe fn list_snapshots_blocking( .filter_map(|backup_type| { let group = datastore.backup_group_from_parts(ns.clone(), backup_type, backup_id.clone()); - group.exists().then(move || group) + group.exists().then_some(group) }) .collect(), // FIXME: Recursion diff --git a/src/api2/config/sync.rs b/src/api2/config/sync.rs index 7b9e9542..504fd893 100644 --- a/src/api2/config/sync.rs +++ b/src/api2/config/sync.rs @@ -511,51 +511,43 @@ acl:1:/remote/remote1/remotestore1:write@pbs:RemoteSyncOperator }; // should work without ACLs - assert_eq!( - check_sync_job_read_access(&user_info, root_auth_id, &job), - true + assert!( + check_sync_job_read_access(&user_info, root_auth_id, &job) ); - assert_eq!( - check_sync_job_modify_access(&user_info, root_auth_id, &job), - true + assert!( + check_sync_job_modify_access(&user_info, root_auth_id, &job) ); // user without permissions must fail - assert_eq!( - check_sync_job_read_access(&user_info, &no_perm_auth_id, &job), - false + assert!( + !check_sync_job_read_access(&user_info, &no_perm_auth_id, &job) ); - assert_eq!( - check_sync_job_modify_access(&user_info, &no_perm_auth_id, &job), - false + assert!( + !check_sync_job_modify_access(&user_info, &no_perm_auth_id, &job) ); // reading without proper read permissions on either remote or local must fail - assert_eq!( - check_sync_job_read_access(&user_info, &read_auth_id, &job), - false + assert!( + !check_sync_job_read_access(&user_info, &read_auth_id, &job) ); // reading without proper read permissions on local end must fail job.remote = "remote1".to_string(); - assert_eq!( - check_sync_job_read_access(&user_info, &read_auth_id, &job), - false + assert!( + !check_sync_job_read_access(&user_info, &read_auth_id, &job) ); // reading without proper read permissions on remote end must fail job.remote = "remote0".to_string(); job.store = "localstore1".to_string(); - assert_eq!( - check_sync_job_read_access(&user_info, &read_auth_id, &job), - false + assert!( + !check_sync_job_read_access(&user_info, &read_auth_id, &job) ); // writing without proper write permissions on either end must fail job.store = "localstore0".to_string(); - assert_eq!( - check_sync_job_modify_access(&user_info, &write_auth_id, &job), - false + assert!( + !check_sync_job_modify_access(&user_info, &write_auth_id, &job) ); // writing without proper write permissions on local end must fail @@ -564,84 +556,71 @@ acl:1:/remote/remote1/remotestore1:write@pbs:RemoteSyncOperator // writing without proper write permissions on remote end must fail job.remote = "remote0".to_string(); job.store = "localstore1".to_string(); - assert_eq!( - check_sync_job_modify_access(&user_info, &write_auth_id, &job), - false + assert!( + !check_sync_job_modify_access(&user_info, &write_auth_id, &job) ); // reset remote to one where users have access job.remote = "remote1".to_string(); // user with read permission can only read, but not modify/run - assert_eq!( - check_sync_job_read_access(&user_info, &read_auth_id, &job), - true + assert!( + check_sync_job_read_access(&user_info, &read_auth_id, &job) ); job.owner = Some(read_auth_id.clone()); - assert_eq!( - check_sync_job_modify_access(&user_info, &read_auth_id, &job), - false + assert!( + !check_sync_job_modify_access(&user_info, &read_auth_id, &job) ); job.owner = None; - assert_eq!( - check_sync_job_modify_access(&user_info, &read_auth_id, &job), - false + assert!( + !check_sync_job_modify_access(&user_info, &read_auth_id, &job) ); job.owner = Some(write_auth_id.clone()); - assert_eq!( - check_sync_job_modify_access(&user_info, &read_auth_id, &job), - false + assert!( + !check_sync_job_modify_access(&user_info, &read_auth_id, &job) ); // user with simple write permission can modify/run - assert_eq!( - check_sync_job_read_access(&user_info, &write_auth_id, &job), - true + assert!( + check_sync_job_read_access(&user_info, &write_auth_id, &job) ); - assert_eq!( - check_sync_job_modify_access(&user_info, &write_auth_id, &job), - true + assert!( + check_sync_job_modify_access(&user_info, &write_auth_id, &job) ); // but can't modify/run with deletion job.remove_vanished = Some(true); - assert_eq!( - check_sync_job_modify_access(&user_info, &write_auth_id, &job), - false + assert!( + !check_sync_job_modify_access(&user_info, &write_auth_id, &job) ); // unless they have Datastore.Prune as well job.store = "localstore2".to_string(); - assert_eq!( - check_sync_job_modify_access(&user_info, &write_auth_id, &job), - true + assert!( + check_sync_job_modify_access(&user_info, &write_auth_id, &job) ); // changing owner is not possible job.owner = Some(read_auth_id.clone()); - assert_eq!( - check_sync_job_modify_access(&user_info, &write_auth_id, &job), - false + assert!( + !check_sync_job_modify_access(&user_info, &write_auth_id, &job) ); // also not to the default 'root@pam' job.owner = None; - assert_eq!( - check_sync_job_modify_access(&user_info, &write_auth_id, &job), - false + assert!( + !check_sync_job_modify_access(&user_info, &write_auth_id, &job) ); // unless they have Datastore.Modify as well job.store = "localstore3".to_string(); job.owner = Some(read_auth_id); - assert_eq!( - check_sync_job_modify_access(&user_info, &write_auth_id, &job), - true + assert!( + check_sync_job_modify_access(&user_info, &write_auth_id, &job) ); job.owner = None; - assert_eq!( - check_sync_job_modify_access(&user_info, &write_auth_id, &job), - true + assert!( + check_sync_job_modify_access(&user_info, &write_auth_id, &job) ); Ok(()) diff --git a/src/server/email_notifications.rs b/src/server/email_notifications.rs index 8d97623a..560b48a8 100644 --- a/src/server/email_notifications.rs +++ b/src/server/email_notifications.rs @@ -420,7 +420,7 @@ pub fn send_prune_status( jobname: &str, result: &Result<(), Error>, ) -> Result<(), Error> { - let (email, notify) = match lookup_datastore_notify_settings(&store) { + let (email, notify) = match lookup_datastore_notify_settings(store) { (Some(email), notify) => (email, notify), (None, _) => return Ok(()), }; diff --git a/src/tape/test/compute_media_state.rs b/src/tape/test/compute_media_state.rs index 4844202f..3db0ac83 100644 --- a/src/tape/test/compute_media_state.rs +++ b/src/tape/test/compute_media_state.rs @@ -118,46 +118,36 @@ fn test_media_expire_time() -> Result<(), Error> { &MediaStatus::Writable ); - assert_eq!( - pool.media_is_expired(&pool.lookup_media(&tape0_uuid)?, 0), - false + assert!( + !pool.media_is_expired(&pool.lookup_media(&tape0_uuid)?, 0) ); - assert_eq!( - pool.media_is_expired(&pool.lookup_media(&tape0_uuid)?, 60), - false + assert!( + !pool.media_is_expired(&pool.lookup_media(&tape0_uuid)?, 60) ); - assert_eq!( - pool.media_is_expired(&pool.lookup_media(&tape0_uuid)?, 120), - false + assert!( + !pool.media_is_expired(&pool.lookup_media(&tape0_uuid)?, 120) ); - assert_eq!( - pool.media_is_expired(&pool.lookup_media(&tape0_uuid)?, 180), - true + assert!( + pool.media_is_expired(&pool.lookup_media(&tape0_uuid)?, 180) ); - assert_eq!( - pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 0), - false + assert!( + !pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 0) ); - assert_eq!( - pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 60), - false + assert!( + !pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 60) ); - assert_eq!( - pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 120), - false + assert!( + !pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 120) ); - assert_eq!( - pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 180), - false + assert!( + !pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 180) ); - assert_eq!( - pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 190), - false + assert!( + !pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 190) ); - assert_eq!( - pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 240), - true + assert!( + pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 240) ); Ok(()) diff --git a/src/tape/test/current_set_usable.rs b/src/tape/test/current_set_usable.rs index 9a8683a0..2cf2fe94 100644 --- a/src/tape/test/current_set_usable.rs +++ b/src/tape/test/current_set_usable.rs @@ -38,7 +38,7 @@ fn test_current_set_usable_1() -> Result<(), Error> { false, )?; - assert_eq!(pool.current_set_usable()?, false); + assert!(!pool.current_set_usable()?); Ok(()) } @@ -64,7 +64,7 @@ fn test_current_set_usable_2() -> Result<(), Error> { false, )?; - assert_eq!(pool.current_set_usable()?, false); + assert!(!pool.current_set_usable()?); Ok(()) } @@ -92,7 +92,7 @@ fn test_current_set_usable_3() -> Result<(), Error> { false, )?; - assert_eq!(pool.current_set_usable()?, false); + assert!(!pool.current_set_usable()?); Ok(()) } @@ -120,7 +120,7 @@ fn test_current_set_usable_4() -> Result<(), Error> { false, )?; - assert_eq!(pool.current_set_usable()?, true); + assert!(pool.current_set_usable()?); Ok(()) } @@ -150,7 +150,7 @@ fn test_current_set_usable_5() -> Result<(), Error> { false, )?; - assert_eq!(pool.current_set_usable()?, true); + assert!(pool.current_set_usable()?); Ok(()) } diff --git a/src/tape/test/inventory.rs b/src/tape/test/inventory.rs index 2393e1a1..53df2558 100644 --- a/src/tape/test/inventory.rs +++ b/src/tape/test/inventory.rs @@ -94,13 +94,13 @@ fn test_list_pool_media() -> Result<(), Error> { let tape2 = list .iter() - .find(|media_id| &media_id.label.uuid == &tape2_uuid) + .find(|media_id| media_id.label.uuid == tape2_uuid) .unwrap(); assert!(tape2.media_set_label.is_none()); let tape3 = list .iter() - .find(|media_id| &media_id.label.uuid == &tape3_uuid) + .find(|media_id| media_id.label.uuid == tape3_uuid) .unwrap(); match tape3.media_set_label { None => bail!("missing media set label"), diff --git a/tests/prune.rs b/tests/prune.rs index 85fd8f7d..87087f98 100644 --- a/tests/prune.rs +++ b/tests/prune.rs @@ -52,18 +52,18 @@ fn create_info_protected(snapshot: &str, partial: bool) -> BackupInfo { #[test] fn test_prune_protected() -> Result<(), Error> { - let mut orig_list = Vec::new(); - - orig_list.push(create_info_protected( - "host/elsa/2019-11-15T09:39:15Z", - false, - )); - orig_list.push(create_info("host/elsa/2019-11-15T10:39:15Z", false)); - orig_list.push(create_info("host/elsa/2019-11-15T10:49:15Z", false)); - orig_list.push(create_info_protected( - "host/elsa/2019-11-15T10:59:15Z", - false, - )); + let orig_list = vec![ + create_info_protected( + "host/elsa/2019-11-15T09:39:15Z", + false, + ), + create_info("host/elsa/2019-11-15T10:39:15Z", false), + create_info("host/elsa/2019-11-15T10:49:15Z", false), + create_info_protected( + "host/elsa/2019-11-15T10:59:15Z", + false, + ), + ]; eprintln!("{:?}", orig_list); @@ -75,7 +75,7 @@ fn test_prune_protected() -> Result<(), Error> { let mut options = PruneJobOptions::default(); options.keep.keep_hourly = Some(1); - let remove_list = get_prune_list(orig_list.clone(), false, &options); + let remove_list = get_prune_list(orig_list, false, &options); let expect: Vec = vec![PathBuf::from("host/elsa/2019-11-15T10:39:15Z")]; assert_eq!(remove_list, expect); Ok(()) @@ -83,14 +83,14 @@ fn test_prune_protected() -> Result<(), Error> { #[test] fn test_prune_hourly() -> Result<(), Error> { - let mut orig_list = Vec::new(); - - orig_list.push(create_info("host/elsa/2019-11-15T09:39:15Z", false)); - orig_list.push(create_info("host/elsa/2019-11-15T10:49:15Z", false)); - orig_list.push(create_info("host/elsa/2019-11-15T10:59:15Z", false)); - orig_list.push(create_info("host/elsa/2019-11-15T11:39:15Z", false)); - orig_list.push(create_info("host/elsa/2019-11-15T11:49:15Z", false)); - orig_list.push(create_info("host/elsa/2019-11-15T11:59:15Z", false)); + let orig_list = vec![ + create_info("host/elsa/2019-11-15T09:39:15Z", false), + create_info("host/elsa/2019-11-15T10:49:15Z", false), + create_info("host/elsa/2019-11-15T10:59:15Z", false), + create_info("host/elsa/2019-11-15T11:39:15Z", false), + create_info("host/elsa/2019-11-15T11:49:15Z", false), + create_info("host/elsa/2019-11-15T11:59:15Z", false), + ]; let list = orig_list.clone(); let mut options = PruneJobOptions::default(); @@ -118,17 +118,17 @@ fn test_prune_hourly() -> Result<(), Error> { #[test] fn test_prune_simple2() -> Result<(), Error> { - let mut orig_list = Vec::new(); - - orig_list.push(create_info("host/elsa/2018-11-15T11:59:15Z", false)); - orig_list.push(create_info("host/elsa/2019-11-15T11:59:15Z", false)); - orig_list.push(create_info("host/elsa/2019-11-21T11:59:15Z", false)); - orig_list.push(create_info("host/elsa/2019-11-22T11:59:15Z", false)); - orig_list.push(create_info("host/elsa/2019-11-29T11:59:15Z", false)); - orig_list.push(create_info("host/elsa/2019-12-01T11:59:15Z", false)); - orig_list.push(create_info("host/elsa/2019-12-02T11:59:15Z", false)); - orig_list.push(create_info("host/elsa/2019-12-03T11:59:15Z", false)); - orig_list.push(create_info("host/elsa/2019-12-04T11:59:15Z", false)); + let orig_list = vec![ + create_info("host/elsa/2018-11-15T11:59:15Z", false), + create_info("host/elsa/2019-11-15T11:59:15Z", false), + create_info("host/elsa/2019-11-21T11:59:15Z", false), + create_info("host/elsa/2019-11-22T11:59:15Z", false), + create_info("host/elsa/2019-11-29T11:59:15Z", false), + create_info("host/elsa/2019-12-01T11:59:15Z", false), + create_info("host/elsa/2019-12-02T11:59:15Z", false), + create_info("host/elsa/2019-12-03T11:59:15Z", false), + create_info("host/elsa/2019-12-04T11:59:15Z", false), + ]; let list = orig_list.clone(); let mut options = PruneJobOptions::default(); @@ -188,13 +188,13 @@ fn test_prune_simple2() -> Result<(), Error> { #[test] fn test_prune_simple() -> Result<(), Error> { - let mut orig_list = Vec::new(); - - orig_list.push(create_info("host/elsa/2019-12-02T11:59:15Z", false)); - orig_list.push(create_info("host/elsa/2019-12-03T11:59:15Z", false)); - orig_list.push(create_info("host/elsa/2019-12-04T11:59:15Z", false)); - orig_list.push(create_info("host/elsa/2019-12-04T12:59:15Z", false)); - + let orig_list = vec![ + create_info("host/elsa/2019-12-02T11:59:15Z", false), + create_info("host/elsa/2019-12-03T11:59:15Z", false), + create_info("host/elsa/2019-12-04T11:59:15Z", false), + create_info("host/elsa/2019-12-04T12:59:15Z", false), + ]; + // keep-last tests let list = orig_list.clone();