@@ -6342,7 +6342,6 @@ fn lock_redact_git_pep508() -> Result<()> {
63426342 Ok(())
63436343}
63446344
6345- /// However, we don't currently avoid persisting Git credentials in `uv.lock`.
63466345#[test]
63476346fn lock_redact_git_sources() -> Result<()> {
63486347 let context = TestContext::new("3.12").with_filtered_link_mode_warning();
@@ -6439,6 +6438,206 @@ fn lock_redact_git_sources() -> Result<()> {
64396438 Ok(())
64406439}
64416440
6441+ #[test]
6442+ fn lock_redact_index_sources() -> Result<()> {
6443+ let context = TestContext::new("3.12").with_filtered_link_mode_warning();
6444+ let token = decode_token(common::READ_ONLY_GITHUB_TOKEN);
6445+
6446+ let filters: Vec<_> = [(token.as_str(), "***")]
6447+ .into_iter()
6448+ .chain(context.filters())
6449+ .collect();
6450+
6451+ let pyproject_toml = context.temp_dir.child("pyproject.toml");
6452+ pyproject_toml.write_str(
6453+ r#"
6454+ [project]
6455+ name = "foo"
6456+ version = "0.1.0"
6457+ requires-python = ">=3.12"
6458+ dependencies = ["iniconfig>=2"]
6459+
6460+ [build-system]
6461+ requires = ["setuptools>=42"]
6462+ build-backend = "setuptools.build_meta"
6463+
6464+ [[tool.uv.index]]
6465+ name = "private"
6466+ url = "https://public:
[email protected] /basic-auth/simple"
6467+
6468+ [tool.uv.sources]
6469+ iniconfig = { index = "private" }
6470+ "#,
6471+ )?;
6472+
6473+ uv_snapshot!(&filters, context.lock(), @r###"
6474+ success: true
6475+ exit_code: 0
6476+ ----- stdout -----
6477+
6478+ ----- stderr -----
6479+ Resolved 2 packages in [TIME]
6480+ "###);
6481+
6482+ let lock = context.read("uv.lock");
6483+
6484+ insta::with_settings!({
6485+ filters => filters.clone(),
6486+ }, {
6487+ assert_snapshot!(
6488+ lock, @r###"
6489+ version = 1
6490+ requires-python = ">=3.12"
6491+
6492+ [options]
6493+ exclude-newer = "2024-03-25T00:00:00Z"
6494+
6495+ [[package]]
6496+ name = "foo"
6497+ version = "0.1.0"
6498+ source = { editable = "." }
6499+ dependencies = [
6500+ { name = "iniconfig" },
6501+ ]
6502+
6503+ [package.metadata]
6504+ requires-dist = [{ name = "iniconfig", specifier = ">=2", index = "https://public:
[email protected] /basic-auth/simple" }]
6505+
6506+ [[package]]
6507+ name = "iniconfig"
6508+ version = "2.0.0"
6509+ source = { registry = "https://pypi-proxy.fly.dev/basic-auth/simple" }
6510+ sdist = { url = "https://pypi-proxy.fly.dev/basic-auth/files/packages/d7/4b/cbd8e699e64a6f16ca3a8220661b5f83792b3017d0f79807cb8708d33913/iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3", size = 4646 }
6511+ wheels = [
6512+ { url = "https://pypi-proxy.fly.dev/basic-auth/files/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374", size = 5892 },
6513+ ]
6514+ "###
6515+ );
6516+ });
6517+
6518+ // Re-run with `--locked`.
6519+ uv_snapshot!(&filters, context.lock().arg("--locked"), @r###"
6520+ success: true
6521+ exit_code: 0
6522+ ----- stdout -----
6523+
6524+ ----- stderr -----
6525+ Resolved 2 packages in [TIME]
6526+ "###);
6527+
6528+ // Install from the lockfile.
6529+ uv_snapshot!(&filters, context.sync().arg("--frozen").arg("--reinstall").arg("--no-cache"), @r###"
6530+ success: true
6531+ exit_code: 0
6532+ ----- stdout -----
6533+
6534+ ----- stderr -----
6535+ Prepared 2 packages in [TIME]
6536+ Installed 2 packages in [TIME]
6537+ + foo==0.1.0 (from file://[TEMP_DIR]/)
6538+ + iniconfig==2.0.0
6539+ "###);
6540+
6541+ Ok(())
6542+ }
6543+
6544+ /// We don't currently redact credentials from direct URLs, though.
6545+ #[test]
6546+ fn lock_redact_url_sources() -> Result<()> {
6547+ let context = TestContext::new("3.12").with_filtered_link_mode_warning();
6548+ let token = decode_token(common::READ_ONLY_GITHUB_TOKEN);
6549+
6550+ let filters: Vec<_> = [(token.as_str(), "***")]
6551+ .into_iter()
6552+ .chain(context.filters())
6553+ .collect();
6554+
6555+ let pyproject_toml = context.temp_dir.child("pyproject.toml");
6556+ pyproject_toml.write_str(r#"
6557+ [project]
6558+ name = "foo"
6559+ version = "0.1.0"
6560+ requires-python = ">=3.12"
6561+ dependencies = ["iniconfig>=2"]
6562+
6563+ [build-system]
6564+ requires = ["setuptools>=42"]
6565+ build-backend = "setuptools.build_meta"
6566+
6567+ [tool.uv.sources]
6568+ iniconfig = { url = "https://public:
[email protected] /basic-auth/files/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl" }
6569+ "#)?;
6570+
6571+ uv_snapshot!(&filters, context.lock(), @r###"
6572+ success: true
6573+ exit_code: 0
6574+ ----- stdout -----
6575+
6576+ ----- stderr -----
6577+ Resolved 2 packages in [TIME]
6578+ "###);
6579+
6580+ let lock = context.read("uv.lock");
6581+
6582+ insta::with_settings!({
6583+ filters => filters.clone(),
6584+ }, {
6585+ assert_snapshot!(
6586+ lock, @r###"
6587+ version = 1
6588+ requires-python = ">=3.12"
6589+
6590+ [options]
6591+ exclude-newer = "2024-03-25T00:00:00Z"
6592+
6593+ [[package]]
6594+ name = "foo"
6595+ version = "0.1.0"
6596+ source = { editable = "." }
6597+ dependencies = [
6598+ { name = "iniconfig" },
6599+ ]
6600+
6601+ [package.metadata]
6602+ requires-dist = [{ name = "iniconfig", url = "https://public:
[email protected] /basic-auth/files/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl" }]
6603+
6604+ [[package]]
6605+ name = "iniconfig"
6606+ version = "2.0.0"
6607+ source = { url = "https://public:
[email protected] /basic-auth/files/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl" }
6608+ wheels = [
6609+ { url = "https://public:
[email protected] /basic-auth/files/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374" },
6610+ ]
6611+ "###
6612+ );
6613+ });
6614+
6615+ // Re-run with `--locked`.
6616+ uv_snapshot!(&filters, context.lock().arg("--locked"), @r###"
6617+ success: true
6618+ exit_code: 0
6619+ ----- stdout -----
6620+
6621+ ----- stderr -----
6622+ Resolved 2 packages in [TIME]
6623+ "###);
6624+
6625+ // Install from the lockfile.
6626+ uv_snapshot!(&filters, context.sync().arg("--frozen").arg("--reinstall").arg("--no-cache"), @r###"
6627+ success: true
6628+ exit_code: 0
6629+ ----- stdout -----
6630+
6631+ ----- stderr -----
6632+ Prepared 2 packages in [TIME]
6633+ Installed 2 packages in [TIME]
6634+ + foo==0.1.0 (from file://[TEMP_DIR]/)
6635+ + iniconfig==2.0.0 (from https://public:
[email protected] /basic-auth/files/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl)
6636+ "###);
6637+
6638+ Ok(())
6639+ }
6640+
64426641/// Pass credentials for a named index via environment variables.
64436642#[test]
64446643fn lock_env_credentials() -> Result<()> {
0 commit comments