fix(tests): resolve all clippy warnings for CI compliance
- Remove needless borrows on format!() in set_body_string() calls (needless_borrows_for_generic_args) - Replace assert!(false, ...) with collected assertion (assertions_on_constants + never_loop) - Use direct Method::POST comparison instead of to_string() (cmp_owned) - Simplify negated equality to != operator (nonminimal_bool) CI pipeline now passes with -D warnings enabled
This commit is contained in:
@ -120,7 +120,7 @@ async fn test_full_enrollment_flow_happy_path() {
|
||||
.and(path("/api/v1/enroll"))
|
||||
.respond_with(
|
||||
ResponseTemplate::new(202)
|
||||
.set_body_string(&format!(r#"{{"polling_token": "{}"}}"#, TEST_TOKEN)),
|
||||
.set_body_string(format!(r#"{{"polling_token": "{}"}}"#, TEST_TOKEN)),
|
||||
)
|
||||
.named("enroll_registration")
|
||||
.mount(&server)
|
||||
@ -135,7 +135,7 @@ async fn test_full_enrollment_flow_happy_path() {
|
||||
ResponseTemplate::new(200).set_body_string(r#"{"status": "pending"}"#)
|
||||
} else {
|
||||
// Second poll returns approved with full PKI bundle
|
||||
ResponseTemplate::new(200).set_body_string(&format!(
|
||||
ResponseTemplate::new(200).set_body_string(format!(
|
||||
r#"{{
|
||||
"status": "approved",
|
||||
"ca_crt": {},
|
||||
@ -414,7 +414,7 @@ async fn test_certificate_permission_verification() {
|
||||
|
||||
Mock::given(method("GET"))
|
||||
.and(path_regex(r"/api/v1/enroll/status/.+"))
|
||||
.respond_with(ResponseTemplate::new(200).set_body_string(&format!(
|
||||
.respond_with(ResponseTemplate::new(200).set_body_string(format!(
|
||||
r#"{{
|
||||
"status": "approved",
|
||||
"ca_crt": {},
|
||||
@ -529,7 +529,7 @@ async fn test_whitelist_append_verification() {
|
||||
|
||||
Mock::given(method("GET"))
|
||||
.and(path_regex(r"/api/v1/enroll/status/.+"))
|
||||
.respond_with(ResponseTemplate::new(200).set_body_string(&format!(
|
||||
.respond_with(ResponseTemplate::new(200).set_body_string(format!(
|
||||
r#"{{
|
||||
"status": "approved",
|
||||
"ca_crt": {},
|
||||
@ -663,14 +663,15 @@ async fn test_signal_handling_during_polling() {
|
||||
);
|
||||
|
||||
// Verify: cleanup of any partial state (no leftover files)
|
||||
for entry in std::fs::read_dir(cert_dir.path()).unwrap() {
|
||||
let entry = entry.unwrap();
|
||||
assert!(
|
||||
false,
|
||||
"No partial files should remain after graceful shutdown: {}",
|
||||
entry.file_name().to_string_lossy()
|
||||
);
|
||||
}
|
||||
let remaining: Vec<_> = std::fs::read_dir(cert_dir.path())
|
||||
.unwrap()
|
||||
.map(|e| e.unwrap().file_name().to_string_lossy().to_string())
|
||||
.collect();
|
||||
assert!(
|
||||
remaining.is_empty(),
|
||||
"No partial files should remain after graceful shutdown: {:?}",
|
||||
remaining
|
||||
);
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
@ -703,7 +704,7 @@ async fn test_whitelist_yaml_format_preservation() {
|
||||
|
||||
Mock::given(method("GET"))
|
||||
.and(path_regex(r"/api/v1/enroll/status/.+"))
|
||||
.respond_with(ResponseTemplate::new(200).set_body_string(&format!(
|
||||
.respond_with(ResponseTemplate::new(200).set_body_string(format!(
|
||||
r#"{{
|
||||
"status": "approved",
|
||||
"ca_crt": {},
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
|
||||
use linux_patch_api::enroll::client::EnrollmentClient;
|
||||
use serial_test::serial;
|
||||
use wiremock::http::Method;
|
||||
use wiremock::{
|
||||
matchers::{method, path, path_regex},
|
||||
Mock, MockServer, ResponseTemplate,
|
||||
@ -417,7 +418,7 @@ async fn test_registration_payload_structure() {
|
||||
let requests = server.received_requests().await.unwrap();
|
||||
let post_request = requests
|
||||
.iter()
|
||||
.find(|r| r.method.to_string() == "POST")
|
||||
.find(|r| r.method == Method::POST)
|
||||
.expect("Should have received a POST request");
|
||||
|
||||
let body_str = std::str::from_utf8(&post_request.body).expect("Body should be valid UTF-8");
|
||||
|
||||
@ -245,7 +245,7 @@ fn test_ip_addresses_are_unicast() {
|
||||
|
||||
// Not unspecified (0.0.0.0)
|
||||
assert!(
|
||||
!(parts == vec![0, 0, 0, 0]),
|
||||
parts != vec![0, 0, 0, 0],
|
||||
"Address '{}' is unspecified",
|
||||
addr
|
||||
);
|
||||
@ -492,7 +492,7 @@ fn test_cross_distro_os_release_parsing() {
|
||||
parsed.contains_key("NAME"),
|
||||
"os-release must contain NAME field"
|
||||
);
|
||||
assert!(parsed["NAME"].ne(&""), "NAME should not be empty");
|
||||
assert!(!parsed["NAME"].is_empty(), "NAME should not be empty");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user