Skip to content

Commit

Permalink
Add test case for multiple indexes on the same realm
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed Jan 29, 2025
1 parent 2ca5150 commit d43ebb4
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions crates/uv/tests/it/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8305,6 +8305,56 @@ fn lock_env_credentials() -> Result<()> {
Ok(())
}

/// Test solving for packages that are pinned to separate indexes in the same realm.
/// This requires the credentials to be cached at the URL-level instead of the realm-level, or
/// credentials for one index will be used for both indexes and the request will fail.
#[test]
fn lock_multiple_indexes_same_realm_different_credentials() -> Result<()> {
let context = TestContext::new("3.12");

let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(
r#"
[project]
name = "foo"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = ["iniconfig", "anyio"]

[tool.uv.sources]
iniconfig = { index = "internal-proxy-heron" }
anyio = { index = "internal-proxy-eagle" }

[[tool.uv.index]]
name = "internal-proxy-heron"
url = "https://pypi-proxy.fly.dev/basic-auth-heron/simple"

[[tool.uv.index]]
name = "internal-proxy-eagle"
url = "https://pypi-proxy.fly.dev/basic-auth-eagle/simple"
"#,
)?;

// Provide credentials via environment variables.
uv_snapshot!(context.filters(), context.lock()
.env(EnvVars::index_username("INTERNAL_PROXY_HERON"), "public")
.env(EnvVars::index_password("INTERNAL_PROXY_HERON"), "heron")
.env(EnvVars::index_username("INTERNAL_PROXY_EAGLE"), "public")
.env(EnvVars::index_password("INTERNAL_PROXY_EAGLE"), "eagle"), @r###"
success: false
exit_code: 2
----- stdout -----

----- stderr -----
warning: Missing version constraint (e.g., a lower bound) for `iniconfig`
warning: Missing version constraint (e.g., a lower bound) for `anyio`
error: Failed to fetch: `https://pypi-proxy.fly.dev/basic-auth-heron/files/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl.metadata`
Caused by: HTTP status client error (401 Unauthorized) for url (https://pypi-proxy.fly.dev/basic-auth-heron/files/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl.metadata)
"###);

Ok(())
}

/// Resolve against an index that uses relative links.
#[test]
fn lock_relative_index() -> Result<()> {
Expand Down

0 comments on commit d43ebb4

Please sign in to comment.