From 237beaed93fb9130cb4eacc34020f2fc42f6daa4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fabian=20Gr=C3=BCnbichler?= Date: Mon, 10 Oct 2022 09:54:18 +0200 Subject: [PATCH] cargo fmt MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabian Grünbichler --- pbs-client/src/http_client.rs | 2 +- src/api2/config/sync.rs | 140 +++++++++++++++------------ src/bin/proxmox-daily-update.rs | 2 +- src/tape/test/compute_media_state.rs | 42 +++----- tests/prune.rs | 12 +-- 5 files changed, 93 insertions(+), 105 deletions(-) diff --git a/pbs-client/src/http_client.rs b/pbs-client/src/http_client.rs index 491b603b..9c1ca3e0 100644 --- a/pbs-client/src/http_client.rs +++ b/pbs-client/src/http_client.rs @@ -23,8 +23,8 @@ use proxmox_sys::linux::tty; use proxmox_async::broadcast_future::BroadcastFuture; use proxmox_http::client::{HttpsConnector, RateLimiter}; -use proxmox_http::ProxyConfig; use proxmox_http::uri::{build_authority, json_object_to_query}; +use proxmox_http::ProxyConfig; use pbs_api_types::percent_encoding::DEFAULT_ENCODE_SET; use pbs_api_types::{Authid, RateLimitConfig, Userid}; diff --git a/src/api2/config/sync.rs b/src/api2/config/sync.rs index 504fd893..6f39b239 100644 --- a/src/api2/config/sync.rs +++ b/src/api2/config/sync.rs @@ -511,44 +511,40 @@ acl:1:/remote/remote1/remotestore1:write@pbs:RemoteSyncOperator }; // should work without ACLs - assert!( - check_sync_job_read_access(&user_info, root_auth_id, &job) - ); - assert!( - check_sync_job_modify_access(&user_info, root_auth_id, &job) - ); + assert!(check_sync_job_read_access(&user_info, root_auth_id, &job)); + assert!(check_sync_job_modify_access(&user_info, root_auth_id, &job)); // user without permissions must fail - assert!( - !check_sync_job_read_access(&user_info, &no_perm_auth_id, &job) - ); - assert!( - !check_sync_job_modify_access(&user_info, &no_perm_auth_id, &job) - ); + assert!(!check_sync_job_read_access( + &user_info, + &no_perm_auth_id, + &job + )); + 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!( - !check_sync_job_read_access(&user_info, &read_auth_id, &job) - ); + 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!( - !check_sync_job_read_access(&user_info, &read_auth_id, &job) - ); + 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!( - !check_sync_job_read_access(&user_info, &read_auth_id, &job) - ); + 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!( - !check_sync_job_modify_access(&user_info, &write_auth_id, &job) - ); + assert!(!check_sync_job_modify_access( + &user_info, + &write_auth_id, + &job + )); // writing without proper write permissions on local end must fail job.remote = "remote1".to_string(); @@ -556,72 +552,90 @@ 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!( - !check_sync_job_modify_access(&user_info, &write_auth_id, &job) - ); + 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!( - check_sync_job_read_access(&user_info, &read_auth_id, &job) - ); + assert!(check_sync_job_read_access(&user_info, &read_auth_id, &job)); job.owner = Some(read_auth_id.clone()); - assert!( - !check_sync_job_modify_access(&user_info, &read_auth_id, &job) - ); + assert!(!check_sync_job_modify_access( + &user_info, + &read_auth_id, + &job + )); job.owner = None; - assert!( - !check_sync_job_modify_access(&user_info, &read_auth_id, &job) - ); + assert!(!check_sync_job_modify_access( + &user_info, + &read_auth_id, + &job + )); job.owner = Some(write_auth_id.clone()); - assert!( - !check_sync_job_modify_access(&user_info, &read_auth_id, &job) - ); + assert!(!check_sync_job_modify_access( + &user_info, + &read_auth_id, + &job + )); // user with simple write permission can modify/run - assert!( - check_sync_job_read_access(&user_info, &write_auth_id, &job) - ); - assert!( - check_sync_job_modify_access(&user_info, &write_auth_id, &job) - ); + assert!(check_sync_job_read_access(&user_info, &write_auth_id, &job)); + 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!( - !check_sync_job_modify_access(&user_info, &write_auth_id, &job) - ); + 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!( - check_sync_job_modify_access(&user_info, &write_auth_id, &job) - ); + 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!( - !check_sync_job_modify_access(&user_info, &write_auth_id, &job) - ); + assert!(!check_sync_job_modify_access( + &user_info, + &write_auth_id, + &job + )); // also not to the default 'root@pam' job.owner = None; - assert!( - !check_sync_job_modify_access(&user_info, &write_auth_id, &job) - ); + 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!( - check_sync_job_modify_access(&user_info, &write_auth_id, &job) - ); + assert!(check_sync_job_modify_access( + &user_info, + &write_auth_id, + &job + )); job.owner = None; - assert!( - check_sync_job_modify_access(&user_info, &write_auth_id, &job) - ); + assert!(check_sync_job_modify_access( + &user_info, + &write_auth_id, + &job + )); Ok(()) } diff --git a/src/bin/proxmox-daily-update.rs b/src/bin/proxmox-daily-update.rs index 5332e217..2b5f7a98 100644 --- a/src/bin/proxmox-daily-update.rs +++ b/src/bin/proxmox-daily-update.rs @@ -38,7 +38,7 @@ async fn do_update(rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> { Err(err) => { log::error!("Error reading subscription - {}", err); false - }, + } }; let param = json!({ diff --git a/src/tape/test/compute_media_state.rs b/src/tape/test/compute_media_state.rs index 3db0ac83..1af06efe 100644 --- a/src/tape/test/compute_media_state.rs +++ b/src/tape/test/compute_media_state.rs @@ -118,37 +118,17 @@ fn test_media_expire_time() -> Result<(), Error> { &MediaStatus::Writable ); - assert!( - !pool.media_is_expired(&pool.lookup_media(&tape0_uuid)?, 0) - ); - assert!( - !pool.media_is_expired(&pool.lookup_media(&tape0_uuid)?, 60) - ); - assert!( - !pool.media_is_expired(&pool.lookup_media(&tape0_uuid)?, 120) - ); - assert!( - pool.media_is_expired(&pool.lookup_media(&tape0_uuid)?, 180) - ); - - assert!( - !pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 0) - ); - assert!( - !pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 60) - ); - assert!( - !pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 120) - ); - assert!( - !pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 180) - ); - assert!( - !pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 190) - ); - assert!( - pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 240) - ); + assert!(!pool.media_is_expired(&pool.lookup_media(&tape0_uuid)?, 0)); + assert!(!pool.media_is_expired(&pool.lookup_media(&tape0_uuid)?, 60)); + assert!(!pool.media_is_expired(&pool.lookup_media(&tape0_uuid)?, 120)); + assert!(pool.media_is_expired(&pool.lookup_media(&tape0_uuid)?, 180)); + + assert!(!pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 0)); + assert!(!pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 60)); + assert!(!pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 120)); + assert!(!pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 180)); + assert!(!pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 190)); + assert!(pool.media_is_expired(&pool.lookup_media(&tape1_uuid)?, 240)); Ok(()) } diff --git a/tests/prune.rs b/tests/prune.rs index 87087f98..3b320969 100644 --- a/tests/prune.rs +++ b/tests/prune.rs @@ -53,16 +53,10 @@ fn create_info_protected(snapshot: &str, partial: bool) -> BackupInfo { #[test] fn test_prune_protected() -> Result<(), Error> { let orig_list = vec![ - create_info_protected( - "host/elsa/2019-11-15T09:39:15Z", - false, - ), + 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, - ), + create_info_protected("host/elsa/2019-11-15T10:59:15Z", false), ]; eprintln!("{:?}", orig_list); @@ -194,7 +188,7 @@ fn test_prune_simple() -> Result<(), Error> { 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(); -- 2.39.5