From 28fc49ca3fff15dd5b6c0400198bf97a8e48d94a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Jul 2023 19:46:18 +0000 Subject: [PATCH 1/4] build(deps): bump mockito from 0.31.1 to 1.0.1 Bumps [mockito](https://github.com/lipanski/mockito) from 0.31.1 to 1.0.1. - [Release notes](https://github.com/lipanski/mockito/releases) - [Commits](https://github.com/lipanski/mockito/compare/0.31.1...1.0.1) --- updated-dependencies: - dependency-name: mockito dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- Cargo.lock | 20 +++++++++++++++++--- Cargo.toml | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 65a0b7c9..2413dcb0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1216,13 +1216,14 @@ dependencies = [ [[package]] name = "mockito" -version = "0.31.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80f9fece9bd97ab74339fe19f4bcaf52b76dcc18e5364c7977c1838f76b38de9" +checksum = "09c762b6267c4593555bb38f1df19e9318985bc4de60b5e8462890856a9a5b4c" dependencies = [ "assert-json-diff", "colored", - "httparse", + "futures", + "hyper", "lazy_static", "log", "rand", @@ -1230,6 +1231,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "similar", + "tokio", ] [[package]] @@ -2017,9 +2019,21 @@ dependencies = [ "pin-project-lite", "signal-hook-registry", "socket2", + "tokio-macros", "windows-sys 0.45.0", ] +[[package]] +name = "tokio-macros" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.104", +] + [[package]] name = "tokio-native-tls" version = "0.3.0" diff --git a/Cargo.toml b/Cargo.toml index be9449fb..5a168304 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,7 +51,7 @@ zbus = "3" [dev-dependencies] http = "0.2" -mockito = "0.31" +mockito = "1.1" proptest = "1.2" tempfile = "^3.7" From 2c7e9c9f33f2eea1b1a3394757be0c68c405b1da Mon Sep 17 00:00:00 2001 From: Steven Presti Date: Thu, 24 Aug 2023 13:41:08 -0400 Subject: [PATCH 2/4] mock_tests: change function calls to be consistent with mockito 1.x mockito's functions have moved around since .3, update the broken signatures. --- src/cincinnati/mock_tests.rs | 11 ++++++----- src/fleet_lock/mock_tests.rs | 21 +++++++++++++-------- src/rpm_ostree/mock_tests.rs | 10 ++++++---- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/cincinnati/mock_tests.rs b/src/cincinnati/mock_tests.rs index f1c2635e..3cc4bc9a 100644 --- a/src/cincinnati/mock_tests.rs +++ b/src/cincinnati/mock_tests.rs @@ -6,17 +6,18 @@ use tokio::runtime as rt; #[test] fn test_empty_graph() { + let mut server = mockito::Server::new(); let empty_graph = r#"{ "nodes": [], "edges": [] }"#; - let m_graph = mockito::mock("GET", Matcher::Regex(r"^/v1/graph?.+$".to_string())) - .match_header("accept", Matcher::Regex("application/json".to_string())) - .with_body(empty_graph) + let m_graph = server.mock("GET", Matcher::Regex(r"^/v1/graph?.+$".to_string())) .with_status(200) + .with_header("accept", "application/json") + .with_body(empty_graph) .create(); - + let runtime = rt::Runtime::new().unwrap(); let id = Identity::mock_default(); let client = Cincinnati { - base_url: mockito::server_url(), + base_url: server.url(), }; let update = runtime.block_on(client.next_update(&id, BTreeSet::new(), false)); m_graph.assert(); diff --git a/src/fleet_lock/mock_tests.rs b/src/fleet_lock/mock_tests.rs index 6e0e6e4b..0bb985a2 100644 --- a/src/fleet_lock/mock_tests.rs +++ b/src/fleet_lock/mock_tests.rs @@ -5,6 +5,7 @@ use tokio::runtime as rt; #[test] fn test_pre_reboot_lock() { + let mut server = mockito::Server::new(); let body = r#" { "client_params": { @@ -13,7 +14,8 @@ fn test_pre_reboot_lock() { } } "#; - let m_pre_reboot = mockito::mock("POST", Matcher::Exact(format!("/{}", V1_PRE_REBOOT))) + + let m_pre_reboot = server.mock("POST", Matcher::Exact(format!("/{}", V1_PRE_REBOOT))) .match_header("fleet-lock-protocol", "true") .match_body(Matcher::PartialJsonString(body.to_string())) .with_status(200) @@ -21,7 +23,7 @@ fn test_pre_reboot_lock() { let runtime = rt::Runtime::new().unwrap(); let id = Identity::mock_default(); - let client = ClientBuilder::new(mockito::server_url(), &id) + let client = ClientBuilder::new(server.url(), &id) .build() .unwrap(); let res = runtime.block_on(client.pre_reboot()); @@ -33,13 +35,14 @@ fn test_pre_reboot_lock() { #[test] fn test_pre_reboot_error() { + let mut server = mockito::Server::new(); let body = r#" { "kind": "f1", "value": "pre-reboot failure" } "#; - let m_pre_reboot = mockito::mock("POST", Matcher::Exact(format!("/{}", V1_PRE_REBOOT))) + let m_pre_reboot = server.mock("POST", Matcher::Exact(format!("/{}", V1_PRE_REBOOT))) .match_header("fleet-lock-protocol", "true") .with_status(404) .with_body(body) @@ -47,7 +50,7 @@ fn test_pre_reboot_error() { let runtime = rt::Runtime::new().unwrap(); let id = Identity::mock_default(); - let client = ClientBuilder::new(mockito::server_url(), &id) + let client = ClientBuilder::new(server.url(), &id) .build() .unwrap(); let res = runtime.block_on(client.pre_reboot()); @@ -58,6 +61,7 @@ fn test_pre_reboot_error() { #[test] fn test_steady_state_lock() { + let mut server = mockito::Server::new(); let body = r#" { "client_params": { @@ -66,7 +70,7 @@ fn test_steady_state_lock() { } } "#; - let m_steady_state = mockito::mock("POST", Matcher::Exact(format!("/{}", V1_STEADY_STATE))) + let m_steady_state = server.mock("POST", Matcher::Exact(format!("/{}", V1_STEADY_STATE))) .match_header("fleet-lock-protocol", "true") .match_body(Matcher::PartialJsonString(body.to_string())) .with_status(200) @@ -74,7 +78,7 @@ fn test_steady_state_lock() { let runtime = rt::Runtime::new().unwrap(); let id = Identity::mock_default(); - let client = ClientBuilder::new(mockito::server_url(), &id) + let client = ClientBuilder::new(server.url(), &id) .build() .unwrap(); let res = runtime.block_on(client.steady_state()); @@ -86,13 +90,14 @@ fn test_steady_state_lock() { #[test] fn test_steady_state_error() { + let mut server = mockito::Server::new(); let body = r#" { "kind": "f1", "value": "pre-reboot failure" } "#; - let m_steady_state = mockito::mock("POST", Matcher::Exact(format!("/{}", V1_STEADY_STATE))) + let m_steady_state = server.mock("POST", Matcher::Exact(format!("/{}", V1_STEADY_STATE))) .match_header("fleet-lock-protocol", "true") .with_status(404) .with_body(body) @@ -100,7 +105,7 @@ fn test_steady_state_error() { let runtime = rt::Runtime::new().unwrap(); let id = Identity::mock_default(); - let client = ClientBuilder::new(mockito::server_url(), &id) + let client = ClientBuilder::new(server.url(), &id) .build() .unwrap(); let res = runtime.block_on(client.steady_state()); diff --git a/src/rpm_ostree/mock_tests.rs b/src/rpm_ostree/mock_tests.rs index 7c63e72a..38ad57f4 100644 --- a/src/rpm_ostree/mock_tests.rs +++ b/src/rpm_ostree/mock_tests.rs @@ -6,6 +6,7 @@ use tokio::runtime as rt; #[test] fn test_simple_graph() { + let mut server = mockito::Server::new(); let simple_graph = r#" { "nodes": [ @@ -35,7 +36,7 @@ fn test_simple_graph() { } "#; - let m_graph = mockito::mock("GET", Matcher::Regex(r"^/v1/graph?.+$".to_string())) + let m_graph = server.mock("GET", Matcher::Regex(r"^/v1/graph?.+$".to_string())) .match_header("accept", Matcher::Regex("application/json".to_string())) .with_body(simple_graph) .with_status(200) @@ -44,7 +45,7 @@ fn test_simple_graph() { let runtime = rt::Runtime::new().unwrap(); let id = Identity::mock_default(); let client = Cincinnati { - base_url: mockito::server_url(), + base_url: server.url(), }; let update = runtime.block_on(client.fetch_update_hint(&id, BTreeSet::new(), false)); m_graph.assert(); @@ -55,6 +56,7 @@ fn test_simple_graph() { #[test] fn test_downgrade() { + let mut server = mockito::Server::new(); let simple_graph = r#" { "nodes": [ @@ -84,7 +86,7 @@ fn test_downgrade() { } "#; - let m_graph = mockito::mock("GET", Matcher::Regex(r"^/v1/graph?.+$".to_string())) + let m_graph = server.mock("GET", Matcher::Regex(r"^/v1/graph?.+$".to_string())) .match_header("accept", Matcher::Regex("application/json".to_string())) .with_body(simple_graph) .with_status(200) @@ -94,7 +96,7 @@ fn test_downgrade() { let runtime = rt::Runtime::new().unwrap(); let id = Identity::mock_default(); let client = Cincinnati { - base_url: mockito::server_url(), + base_url: server.url(), }; // Downgrades denied. From 3dbadc682c730692c9fb9247954fa42c2b43ec8e Mon Sep 17 00:00:00 2001 From: Steven Presti Date: Thu, 24 Aug 2023 13:49:47 -0400 Subject: [PATCH 3/4] mock_tests: correctly format test --- src/cincinnati/mock_tests.rs | 5 +++-- src/fleet_lock/mock_tests.rs | 28 ++++++++++++---------------- src/rpm_ostree/mock_tests.rs | 6 ++++-- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/cincinnati/mock_tests.rs b/src/cincinnati/mock_tests.rs index 3cc4bc9a..fdb54f50 100644 --- a/src/cincinnati/mock_tests.rs +++ b/src/cincinnati/mock_tests.rs @@ -8,12 +8,13 @@ use tokio::runtime as rt; fn test_empty_graph() { let mut server = mockito::Server::new(); let empty_graph = r#"{ "nodes": [], "edges": [] }"#; - let m_graph = server.mock("GET", Matcher::Regex(r"^/v1/graph?.+$".to_string())) + let m_graph = server + .mock("GET", Matcher::Regex(r"^/v1/graph?.+$".to_string())) .with_status(200) .with_header("accept", "application/json") .with_body(empty_graph) .create(); - + let runtime = rt::Runtime::new().unwrap(); let id = Identity::mock_default(); let client = Cincinnati { diff --git a/src/fleet_lock/mock_tests.rs b/src/fleet_lock/mock_tests.rs index 0bb985a2..914cf166 100644 --- a/src/fleet_lock/mock_tests.rs +++ b/src/fleet_lock/mock_tests.rs @@ -15,7 +15,8 @@ fn test_pre_reboot_lock() { } "#; - let m_pre_reboot = server.mock("POST", Matcher::Exact(format!("/{}", V1_PRE_REBOOT))) + let m_pre_reboot = server + .mock("POST", Matcher::Exact(format!("/{}", V1_PRE_REBOOT))) .match_header("fleet-lock-protocol", "true") .match_body(Matcher::PartialJsonString(body.to_string())) .with_status(200) @@ -23,9 +24,7 @@ fn test_pre_reboot_lock() { let runtime = rt::Runtime::new().unwrap(); let id = Identity::mock_default(); - let client = ClientBuilder::new(server.url(), &id) - .build() - .unwrap(); + let client = ClientBuilder::new(server.url(), &id).build().unwrap(); let res = runtime.block_on(client.pre_reboot()); m_pre_reboot.assert(); @@ -42,7 +41,8 @@ fn test_pre_reboot_error() { "value": "pre-reboot failure" } "#; - let m_pre_reboot = server.mock("POST", Matcher::Exact(format!("/{}", V1_PRE_REBOOT))) + let m_pre_reboot = server + .mock("POST", Matcher::Exact(format!("/{}", V1_PRE_REBOOT))) .match_header("fleet-lock-protocol", "true") .with_status(404) .with_body(body) @@ -50,9 +50,7 @@ fn test_pre_reboot_error() { let runtime = rt::Runtime::new().unwrap(); let id = Identity::mock_default(); - let client = ClientBuilder::new(server.url(), &id) - .build() - .unwrap(); + let client = ClientBuilder::new(server.url(), &id).build().unwrap(); let res = runtime.block_on(client.pre_reboot()); m_pre_reboot.assert(); @@ -70,7 +68,8 @@ fn test_steady_state_lock() { } } "#; - let m_steady_state = server.mock("POST", Matcher::Exact(format!("/{}", V1_STEADY_STATE))) + let m_steady_state = server + .mock("POST", Matcher::Exact(format!("/{}", V1_STEADY_STATE))) .match_header("fleet-lock-protocol", "true") .match_body(Matcher::PartialJsonString(body.to_string())) .with_status(200) @@ -78,9 +77,7 @@ fn test_steady_state_lock() { let runtime = rt::Runtime::new().unwrap(); let id = Identity::mock_default(); - let client = ClientBuilder::new(server.url(), &id) - .build() - .unwrap(); + let client = ClientBuilder::new(server.url(), &id).build().unwrap(); let res = runtime.block_on(client.steady_state()); m_steady_state.assert(); @@ -97,7 +94,8 @@ fn test_steady_state_error() { "value": "pre-reboot failure" } "#; - let m_steady_state = server.mock("POST", Matcher::Exact(format!("/{}", V1_STEADY_STATE))) + let m_steady_state = server + .mock("POST", Matcher::Exact(format!("/{}", V1_STEADY_STATE))) .match_header("fleet-lock-protocol", "true") .with_status(404) .with_body(body) @@ -105,9 +103,7 @@ fn test_steady_state_error() { let runtime = rt::Runtime::new().unwrap(); let id = Identity::mock_default(); - let client = ClientBuilder::new(server.url(), &id) - .build() - .unwrap(); + let client = ClientBuilder::new(server.url(), &id).build().unwrap(); let res = runtime.block_on(client.steady_state()); m_steady_state.assert(); diff --git a/src/rpm_ostree/mock_tests.rs b/src/rpm_ostree/mock_tests.rs index 38ad57f4..6a9b760e 100644 --- a/src/rpm_ostree/mock_tests.rs +++ b/src/rpm_ostree/mock_tests.rs @@ -36,7 +36,8 @@ fn test_simple_graph() { } "#; - let m_graph = server.mock("GET", Matcher::Regex(r"^/v1/graph?.+$".to_string())) + let m_graph = server + .mock("GET", Matcher::Regex(r"^/v1/graph?.+$".to_string())) .match_header("accept", Matcher::Regex("application/json".to_string())) .with_body(simple_graph) .with_status(200) @@ -86,7 +87,8 @@ fn test_downgrade() { } "#; - let m_graph = server.mock("GET", Matcher::Regex(r"^/v1/graph?.+$".to_string())) + let m_graph = server + .mock("GET", Matcher::Regex(r"^/v1/graph?.+$".to_string())) .match_header("accept", Matcher::Regex("application/json".to_string())) .with_body(simple_graph) .with_status(200) From 7226b7a8153bdeaa617f408d99cfbc221ff2ddeb Mon Sep 17 00:00:00 2001 From: Steven Presti Date: Thu, 24 Aug 2023 15:10:06 -0400 Subject: [PATCH 4/4] cargo: update MSRV to 1.65 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 5a168304..ae4f00fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ keywords = ["cincinnati", "coreos", "fedora", "rpm-ostree"] authors = ["Luca Bruno "] repository = "https://github.com/coreos/zincati" edition = "2021" -rust-version = "1.64.0" +rust-version = "1.65.0" [dependencies] actix = "0.13"