Skip to content

Commit e868ce8

Browse files
committed
Refresh token
1 parent abb11ff commit e868ce8

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/uv/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ requirements-txt = { path = "../requirements-txt" }
3939

4040
anstream = { workspace = true }
4141
anyhow = { workspace = true }
42+
base64 = { workspace = true }
4243
chrono = { workspace = true }
4344
clap = { workspace = true, features = ["derive"] }
4445
clap_complete_command = { workspace = true }

crates/uv/tests/pip_install.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::process::Command;
55
use anyhow::Result;
66
use assert_cmd::prelude::*;
77
use assert_fs::prelude::*;
8+
use base64::{prelude::BASE64_STANDARD as base64, Engine};
89
use indoc::indoc;
910
use url::Url;
1011

@@ -14,6 +15,14 @@ use crate::common::get_bin;
1415

1516
mod common;
1617

18+
// This is a fine-grained token that only has read-only access to the `uv-private-pypackage` repository
19+
const READ_ONLY_GITHUB_TOKEN: &str = "Z2l0aHViX3BhdF8xMUJHSVpBN1EwYUVRbW1sZnRSNEx0X3hUcjlWUjBrMWczYXNlcDRwVDYxS01WTW90YjF5Ym15VHIxRjI0TkdHZDBHQ0NOSUpIUUhZNVh4V3d1";
20+
21+
fn decode_token<'a>(content: &'a str) -> String {
22+
let decoded = base64.decode(content).unwrap();
23+
std::str::from_utf8(decoded.as_slice()).unwrap().to_string()
24+
}
25+
1726
/// Create a `pip install` command with options shared across scenarios.
1827
fn command(context: &TestContext) -> Command {
1928
let mut command = Command::new(get_bin());
@@ -734,9 +743,7 @@ fn install_git_public_https() {
734743
#[test]
735744
fn install_git_private_https_pat_no_username() {
736745
let context = TestContext::new("3.8");
737-
738-
// This is a fine-grained token that only has read-only access to the `uv-private-pypackage` repository
739-
let token = "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";
746+
let token = decode_token(READ_ONLY_GITHUB_TOKEN);
740747

741748
uv_snapshot!(command(&context)
742749
.arg(format!("uv-private-pypackage @ git+https://{token}@github.com/astral-test/uv-private-pypackage"))
@@ -749,7 +756,7 @@ fn install_git_private_https_pat_no_username() {
749756
Resolved 1 package in [TIME]
750757
Downloaded 1 package in [TIME]
751758
Installed 1 package in [TIME]
752-
+ uv-private-pypackage==0.1.0 (from git+https://:github_pat_[SIZE]GIZA7Q0qxQCNd[SIZE]VVCf_8ZeenAddxUYnR82xy7geDJo5DsazrjdVjfh3TH[TIME]nE3IXVTWKSJ9DInbt@github.com/astral-test/uv-private-pypackage@c44e30b5d3e49dab7dbbe543a331fbf0e4dc3b37)
759+
+ uv-private-pypackage==0.1.0 (from git+https://:github_pat_[SIZE]GIZA7Q0aEQmmlftR4Lt_xTr9VR0k1g3asep4pT61KMVMotb1ybmyTr1F24NGGd0GCCNIJHQHY5XxWwu@github.com/astral-test/uv-private-pypackage@c44e30b5d3e49dab7dbbe543a331fbf0e4dc3b37)
753760
"###);
754761

755762
context.assert_installed("uv_private_pypackage", "0.1.0");
@@ -759,26 +766,21 @@ fn install_git_private_https_pat_no_username() {
759766
#[test]
760767
fn install_git_private_https_pat() {
761768
let context = TestContext::new("3.8");
762-
763-
// This is a fine-grained token that only has read-only access to the `uv-private-pypackage` repository
764-
let token = "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";
769+
let token = decode_token(READ_ONLY_GITHUB_TOKEN);
765770
let user = "astral-test-bot";
766771

767772
uv_snapshot!(command(&context)
768773
.arg(format!("uv-private-pypackage @ git+https://{user}:{token}@github.com/astral-test/uv-private-pypackage"))
769774
, @r###"
770-
success: false
771-
exit_code: 2
775+
success: true
776+
exit_code: 0
772777
----- stdout -----
773778
774779
----- stderr -----
775-
error: Failed to download and build: uv-private-pypackage @ git+https://astral-test-bot:github_pat_[SIZE]GIZA7Q0qxQCNd[SIZE]VVCf_8ZeenAddxUYnR82xy7geDJo5DsazrjdVjfh3TH[TIME][email protected]/astral-test/uv-private-pypackage
776-
Caused by: Git operation failed
777-
Caused by: failed to clone into: /private/var/folders/bc/qlsk3t6x7c9fhhbvvcg68k9c0000gp/T/.tmpijslxX/git-v0/db/732d1383ce6d692d
778-
Caused by: failed to authenticate when downloading repository
779-
780-
* attempted to find username/password via git's `credential.helper` support, but failed
781-
Caused by: failed to acquire username/password from local configuration
780+
Resolved 1 package in [TIME]
781+
Downloaded 1 package in [TIME]
782+
Installed 1 package in [TIME]
783+
+ uv-private-pypackage==0.1.0 (from git+https://astral-test-bot:github_pat_[SIZE]GIZA7Q0aEQmmlftR4Lt_xTr9VR0k1g3asep4pT61KMVMotb1ybmyTr1F24NGGd0GCCNIJHQHY5XxWwu@github.com/astral-test/uv-private-pypackage@c44e30b5d3e49dab7dbbe543a331fbf0e4dc3b37)
782784
"###);
783785

784786
context.assert_installed("uv_private_pypackage", "0.1.0");

0 commit comments

Comments
 (0)