@@ -5,6 +5,7 @@ use std::process::Command;
5
5
use anyhow:: Result ;
6
6
use assert_cmd:: prelude:: * ;
7
7
use assert_fs:: prelude:: * ;
8
+ use base64:: { prelude:: BASE64_STANDARD as base64, Engine } ;
8
9
use indoc:: indoc;
9
10
use url:: Url ;
10
11
@@ -14,6 +15,14 @@ use crate::common::get_bin;
14
15
15
16
mod common;
16
17
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
+
17
26
/// Create a `pip install` command with options shared across scenarios.
18
27
fn command ( context : & TestContext ) -> Command {
19
28
let mut command = Command :: new ( get_bin ( ) ) ;
@@ -734,9 +743,7 @@ fn install_git_public_https() {
734
743
#[ test]
735
744
fn install_git_private_https_pat_no_username ( ) {
736
745
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 ) ;
740
747
741
748
uv_snapshot ! ( command( & context)
742
749
. 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() {
749
756
Resolved 1 package in [TIME]
750
757
Downloaded 1 package in [TIME]
751
758
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)
753
760
"### ) ;
754
761
755
762
context. assert_installed ( "uv_private_pypackage" , "0.1.0" ) ;
@@ -759,26 +766,21 @@ fn install_git_private_https_pat_no_username() {
759
766
#[ test]
760
767
fn install_git_private_https_pat ( ) {
761
768
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 ) ;
765
770
let user = "astral-test-bot" ;
766
771
767
772
uv_snapshot ! ( command( & context)
768
773
. arg( format!( "uv-private-pypackage @ git+https://{user}:{token}@github.com/astral-test/uv-private-pypackage" ) )
769
774
, @r###"
770
- success: false
771
- exit_code: 2
775
+ success: true
776
+ exit_code: 0
772
777
----- stdout -----
773
778
774
779
----- 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)
782
784
"### ) ;
783
785
784
786
context. assert_installed ( "uv_private_pypackage" , "0.1.0" ) ;
0 commit comments