mirror of
git://git.proxmox.com/git/proxmox-backup.git
synced 2025-02-25 17:57:35 +03:00
clippy fixes
and one additional API fn "allow many parameters" addition. Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
c36c901172
commit
f097eaa80f
@ -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(())
|
||||
|
@ -391,6 +391,7 @@ async fn list(
|
||||
}
|
||||
)]
|
||||
/// Restore files from a backup snapshot.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn extract(
|
||||
ns: Option<BackupNamespace>,
|
||||
snapshot: String,
|
||||
|
@ -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
|
||||
|
@ -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(())
|
||||
|
@ -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(()),
|
||||
};
|
||||
|
@ -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(())
|
||||
|
@ -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(())
|
||||
}
|
||||
|
@ -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"),
|
||||
|
@ -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<PathBuf> = 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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user