From 10abeae3c6b6bda6d92fa185bb90a1f4b4dcbae2 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Fri, 15 Mar 2024 09:50:04 -0500 Subject: [PATCH] Add test case for URL with basic authentication (#2463) Closes https://github.com/astral-sh/uv/issues/2447 --- crates/uv/tests/pip_install.rs | 81 ++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/crates/uv/tests/pip_install.rs b/crates/uv/tests/pip_install.rs index e8978555e..05819d851 100644 --- a/crates/uv/tests/pip_install.rs +++ b/crates/uv/tests/pip_install.rs @@ -2762,3 +2762,84 @@ requires-python = "<=3.8" Ok(()) } + +/// Install a package from an index that requires authentication +#[test] +fn install_package_basic_auth_from_url() { + let context = TestContext::new("3.12"); + + uv_snapshot!(command(&context) + .arg("anyio") + .arg("--index-url") + .arg("https://public:heron@pypi-proxy.fly.dev/basic-auth/simple") + .arg("--strict"), @r###" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + Resolved 3 packages in [TIME] + Downloaded 3 packages in [TIME] + Installed 3 packages in [TIME] + + anyio==4.0.0 + + idna==3.4 + + sniffio==1.3.0 + "### + ); + + context.assert_command("import anyio").success(); +} + +/// Install a package from an index that provides relative links +#[test] +fn install_index_with_relative_links() { + let context = TestContext::new("3.12"); + + uv_snapshot!(command(&context) + .arg("anyio") + .arg("--index-url") + .arg("https://pypi-proxy.fly.dev/relative/simple") + .arg("--strict"), @r###" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + Resolved 3 packages in [TIME] + Downloaded 3 packages in [TIME] + Installed 3 packages in [TIME] + + anyio==4.0.0 + + idna==3.4 + + sniffio==1.3.0 + "### + ); + + context.assert_command("import anyio").success(); +} + +/// Install a package from an index that provides relative links and requires authentication +#[test] +fn install_index_with_relative_links_authenticated() { + let context = TestContext::new("3.12"); + + uv_snapshot!(command(&context) + .arg("anyio") + .arg("--index-url") + .arg("https://public:heron@pypi-proxy.fly.dev/basic-auth/relative/simple") + .arg("--strict"), @r###" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + Resolved 3 packages in [TIME] + Downloaded 3 packages in [TIME] + Installed 3 packages in [TIME] + + anyio==4.0.0 + + idna==3.4 + + sniffio==1.3.0 + "### + ); + + context.assert_command("import anyio").success(); +}