fmt: fix clippy warnings on all targets
Drop an unused test fixture constant, move download_trust_ppa_key above the test module that precedes it, and simplify two test borrows.
This commit is contained in:
+31
-31
@@ -198,37 +198,6 @@ fn validate_keyring_dir(dir_uid: u32, mode: u32, euid: u32) -> Result<(), String
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_validate_keyring_dir_accepts_private_dir_owned_by_current_user() {
|
|
||||||
assert!(validate_keyring_dir(1000, 0o700, 1000).is_ok());
|
|
||||||
assert!(validate_keyring_dir(1000, 0o750, 1000).is_ok());
|
|
||||||
assert!(validate_keyring_dir(1000, 0o1744, 1000).is_ok());
|
|
||||||
assert!(validate_keyring_dir(0, 0o700, 0).is_ok());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_validate_keyring_dir_rejects_foreign_owner() {
|
|
||||||
let err = validate_keyring_dir(1000, 0o700, 1001).unwrap_err();
|
|
||||||
assert!(err.contains("owned by uid 1000"));
|
|
||||||
let err = validate_keyring_dir(1001, 0o700, 1000).unwrap_err();
|
|
||||||
assert!(err.contains("owned by uid 1001"));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_validate_keyring_dir_rejects_group_or_other_writable() {
|
|
||||||
assert!(validate_keyring_dir(1000, 0o770, 1000).is_err());
|
|
||||||
assert!(validate_keyring_dir(1000, 0o706, 1000).is_err());
|
|
||||||
assert!(validate_keyring_dir(1000, 0o707, 1000).is_err());
|
|
||||||
assert!(validate_keyring_dir(1000, 0o777, 1000).is_err());
|
|
||||||
// Sticky bit does not neutralize the group/other write bits.
|
|
||||||
assert!(validate_keyring_dir(1000, 0o1777, 1000).is_err());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Download and import a PPA key using Launchpad API
|
/// Download and import a PPA key using Launchpad API
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
@@ -332,3 +301,34 @@ pub async fn download_trust_ppa_key(
|
|||||||
);
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_validate_keyring_dir_accepts_private_dir_owned_by_current_user() {
|
||||||
|
assert!(validate_keyring_dir(1000, 0o700, 1000).is_ok());
|
||||||
|
assert!(validate_keyring_dir(1000, 0o750, 1000).is_ok());
|
||||||
|
assert!(validate_keyring_dir(1000, 0o1744, 1000).is_ok());
|
||||||
|
assert!(validate_keyring_dir(0, 0o700, 0).is_ok());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_validate_keyring_dir_rejects_foreign_owner() {
|
||||||
|
let err = validate_keyring_dir(1000, 0o700, 1001).unwrap_err();
|
||||||
|
assert!(err.contains("owned by uid 1000"));
|
||||||
|
let err = validate_keyring_dir(1001, 0o700, 1000).unwrap_err();
|
||||||
|
assert!(err.contains("owned by uid 1001"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_validate_keyring_dir_rejects_group_or_other_writable() {
|
||||||
|
assert!(validate_keyring_dir(1000, 0o770, 1000).is_err());
|
||||||
|
assert!(validate_keyring_dir(1000, 0o706, 1000).is_err());
|
||||||
|
assert!(validate_keyring_dir(1000, 0o707, 1000).is_err());
|
||||||
|
assert!(validate_keyring_dir(1000, 0o777, 1000).is_err());
|
||||||
|
// Sticky bit does not neutralize the group/other write bits.
|
||||||
|
assert!(validate_keyring_dir(1000, 0o1777, 1000).is_err());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+2
-4
@@ -1080,8 +1080,6 @@ EwQbAcFaKe4rlLx9e/EXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLE
|
|||||||
|
|
||||||
/// sha256(b"test")
|
/// sha256(b"test")
|
||||||
const SHA256_TEST: &str = "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08";
|
const SHA256_TEST: &str = "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08";
|
||||||
/// sha256(b"")
|
|
||||||
const SHA256_EMPTY: &str = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
|
|
||||||
|
|
||||||
fn verified_noble() -> VerifiedRelease {
|
fn verified_noble() -> VerifiedRelease {
|
||||||
let body = split_clearsigned(NOBLE_INRELEASE).unwrap();
|
let body = split_clearsigned(NOBLE_INRELEASE).unwrap();
|
||||||
@@ -1241,9 +1239,9 @@ garbage
|
|||||||
// reported as GpgvMissing, distinct from a signature failure
|
// reported as GpgvMissing, distinct from a signature failure
|
||||||
let status = run_gpgv(
|
let status = run_gpgv(
|
||||||
"/nonexistent/pkh-test-gpgv",
|
"/nonexistent/pkh-test-gpgv",
|
||||||
&Path::new("/unused/scratch").to_path_buf(),
|
Path::new("/unused/scratch"),
|
||||||
&[PathBuf::from("/unused/keyring.gpg")],
|
&[PathBuf::from("/unused/keyring.gpg")],
|
||||||
&Path::new("/unused/InRelease"),
|
Path::new("/unused/InRelease"),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
assert!(matches!(status, GpgvStatus::GpgvMissing(_)));
|
assert!(matches!(status, GpgvStatus::GpgvMissing(_)));
|
||||||
|
|||||||
Reference in New Issue
Block a user