From ffb3906eff89f32c347f521a3bc54505967ed111 Mon Sep 17 00:00:00 2001 From: Colin Casey Date: Thu, 27 Feb 2025 15:56:35 -0400 Subject: [PATCH 1/3] Changes required for ureq update from v2 to v3 --- libcnb-test/Cargo.toml | 2 +- libcnb-test/README.md | 16 ++++++++++++---- libcnb-test/tests/integration_test.rs | 4 ++-- libherokubuildpack/Cargo.toml | 2 +- libherokubuildpack/src/download.rs | 2 +- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/libcnb-test/Cargo.toml b/libcnb-test/Cargo.toml index 5c23f233..fb0c471b 100644 --- a/libcnb-test/Cargo.toml +++ b/libcnb-test/Cargo.toml @@ -27,4 +27,4 @@ thiserror = "2.0.11" [dev-dependencies] indoc = "2.0.5" libcnb.workspace = true -ureq = { version = "2.12.1", default-features = false } +ureq = { version = "3.0.7", default-features = false } diff --git a/libcnb-test/README.md b/libcnb-test/README.md index a6aeb42e..7db6680b 100644 --- a/libcnb-test/README.md +++ b/libcnb-test/README.md @@ -3,6 +3,7 @@ An integration testing framework for Cloud Native Buildpacks written in Rust with [libcnb.rs](https://github.com/heroku/libcnb.rs). The framework: + - Automatically cross-compiles and packages the buildpack under test - Performs a build with specified configuration using `pack build` - Supports starting containers using the resultant application image @@ -16,7 +17,8 @@ Integration tests require the following to be available on the host: - [Docker](https://docs.docker.com/engine/install/) - [Pack CLI](https://buildpacks.io/docs/install-pack/) v0.35.1+ -- [Cross-compilation prerequisites](https://docs.rs/libcnb/latest/libcnb/#cross-compilation-prerequisites) (however `libcnb-cargo` itself is not required) +- [Cross-compilation prerequisites](https://docs.rs/libcnb/latest/libcnb/#cross-compilation-prerequisites) (however + `libcnb-cargo` itself is not required) Only local Docker daemons are fully supported. As such, if you are using Circle CI you must use the [`machine` executor](https://circleci.com/docs/2.0/executor-types/#using-machine) rather than the @@ -103,7 +105,8 @@ fn run_shell_command() { } ``` -Starting a container using the default process with an exposed port to test a web server, using [`TestContext::start_container`]: +Starting a container using the default process with an exposed port to test a web server, using [ +`TestContext::start_container`]: ```rust,no_run use libcnb_test::{assert_contains, assert_empty, BuildConfig, ContainerConfig, TestRunner}; @@ -136,8 +139,8 @@ fn starting_web_server_container() { &format!("Listening on port {TEST_PORT}") ); - let response = ureq::get(&url).call().unwrap(); - let body = response.into_string().unwrap(); + let mut response = ureq::get(&url).call().unwrap(); + let body = response.body_mut().read_to_string().unwrap(); assert_contains!(body, "Expected response substring"); }, ); @@ -223,8 +226,13 @@ fn additional_buildpacks() { - If you wish to assert against multi-line log output, see the [indoc](https://crates.io/crates/indoc) crate. [Docs]: https://img.shields.io/docsrs/libcnb-test + [docs.rs]: https://docs.rs/libcnb-test/latest/libcnb_test/ + [Latest Version]: https://img.shields.io/crates/v/libcnb-test.svg + [crates.io]: https://crates.io/crates/libcnb-test + [MSRV]: https://img.shields.io/badge/MSRV-rustc_1.76+-lightgray.svg + [install-rust]: https://www.rust-lang.org/tools/install diff --git a/libcnb-test/tests/integration_test.rs b/libcnb-test/tests/integration_test.rs index 1fa1a667..2dad3fcc 100644 --- a/libcnb-test/tests/integration_test.rs +++ b/libcnb-test/tests/integration_test.rs @@ -473,7 +473,7 @@ fn starting_containers() { // Retries needed since the server takes a moment to start up. let mut attempts_remaining = 5; - let response = loop { + let mut response = loop { let response = ureq::get(&url).call(); if response.is_ok() || attempts_remaining == 0 { break response; @@ -483,7 +483,7 @@ fn starting_containers() { } .unwrap(); - let body = response.into_string().unwrap(); + let body = response.body_mut().read_to_string().unwrap(); assert_contains!(body, "Directory listing for /"); let server_log_output = container.logs_now(); diff --git a/libherokubuildpack/Cargo.toml b/libherokubuildpack/Cargo.toml index 822328fc..8948b4bd 100644 --- a/libherokubuildpack/Cargo.toml +++ b/libherokubuildpack/Cargo.toml @@ -50,7 +50,7 @@ tar = { version = "0.4.44", default-features = false, optional = true } termcolor = { version = "1.4.1", optional = true } thiserror = { version = "2.0.11", optional = true } toml = { workspace = true, optional = true } -ureq = { version = "2.12.1", default-features = false, features = ["tls"], optional = true } +ureq = { version = "3.0.7", default-features = false, features = ["rustls"], optional = true } [dev-dependencies] serde_test = "1.0.177" diff --git a/libherokubuildpack/src/download.rs b/libherokubuildpack/src/download.rs index 14d36543..e590d328 100644 --- a/libherokubuildpack/src/download.rs +++ b/libherokubuildpack/src/download.rs @@ -32,7 +32,7 @@ pub fn download_file( destination: impl AsRef, ) -> Result<(), DownloadError> { let response = ureq::get(uri.as_ref()).call().map_err(Box::new)?; - let mut reader = response.into_reader(); + let mut reader = response.into_body().into_reader(); let mut file = fs::File::create(destination.as_ref())?; io::copy(&mut reader, &mut file)?; From 7d10e3b6c5531265d14b53089a57feb92e872328 Mon Sep 17 00:00:00 2001 From: Colin Casey Date: Thu, 27 Feb 2025 16:00:09 -0400 Subject: [PATCH 2/3] Changes required for ureq update from v2 to v3 --- libcnb-test/README.md | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/libcnb-test/README.md b/libcnb-test/README.md index 7db6680b..a6aeb42e 100644 --- a/libcnb-test/README.md +++ b/libcnb-test/README.md @@ -3,7 +3,6 @@ An integration testing framework for Cloud Native Buildpacks written in Rust with [libcnb.rs](https://github.com/heroku/libcnb.rs). The framework: - - Automatically cross-compiles and packages the buildpack under test - Performs a build with specified configuration using `pack build` - Supports starting containers using the resultant application image @@ -17,8 +16,7 @@ Integration tests require the following to be available on the host: - [Docker](https://docs.docker.com/engine/install/) - [Pack CLI](https://buildpacks.io/docs/install-pack/) v0.35.1+ -- [Cross-compilation prerequisites](https://docs.rs/libcnb/latest/libcnb/#cross-compilation-prerequisites) (however - `libcnb-cargo` itself is not required) +- [Cross-compilation prerequisites](https://docs.rs/libcnb/latest/libcnb/#cross-compilation-prerequisites) (however `libcnb-cargo` itself is not required) Only local Docker daemons are fully supported. As such, if you are using Circle CI you must use the [`machine` executor](https://circleci.com/docs/2.0/executor-types/#using-machine) rather than the @@ -105,8 +103,7 @@ fn run_shell_command() { } ``` -Starting a container using the default process with an exposed port to test a web server, using [ -`TestContext::start_container`]: +Starting a container using the default process with an exposed port to test a web server, using [`TestContext::start_container`]: ```rust,no_run use libcnb_test::{assert_contains, assert_empty, BuildConfig, ContainerConfig, TestRunner}; @@ -139,8 +136,8 @@ fn starting_web_server_container() { &format!("Listening on port {TEST_PORT}") ); - let mut response = ureq::get(&url).call().unwrap(); - let body = response.body_mut().read_to_string().unwrap(); + let response = ureq::get(&url).call().unwrap(); + let body = response.into_string().unwrap(); assert_contains!(body, "Expected response substring"); }, ); @@ -226,13 +223,8 @@ fn additional_buildpacks() { - If you wish to assert against multi-line log output, see the [indoc](https://crates.io/crates/indoc) crate. [Docs]: https://img.shields.io/docsrs/libcnb-test - [docs.rs]: https://docs.rs/libcnb-test/latest/libcnb_test/ - [Latest Version]: https://img.shields.io/crates/v/libcnb-test.svg - [crates.io]: https://crates.io/crates/libcnb-test - [MSRV]: https://img.shields.io/badge/MSRV-rustc_1.76+-lightgray.svg - [install-rust]: https://www.rust-lang.org/tools/install From d0feee0f72a63fe44af3aa0a86949f4289c6b77a Mon Sep 17 00:00:00 2001 From: Colin Casey Date: Thu, 27 Feb 2025 16:01:14 -0400 Subject: [PATCH 3/3] Update README.md --- libcnb-test/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libcnb-test/README.md b/libcnb-test/README.md index a6aeb42e..75688551 100644 --- a/libcnb-test/README.md +++ b/libcnb-test/README.md @@ -136,8 +136,8 @@ fn starting_web_server_container() { &format!("Listening on port {TEST_PORT}") ); - let response = ureq::get(&url).call().unwrap(); - let body = response.into_string().unwrap(); + let mut response = ureq::get(&url).call().unwrap(); + let body = response.body_mut().read_to_string().unwrap(); assert_contains!(body, "Expected response substring"); }, );