Skip to content

Commit a748336

Browse files
authored
Follow-up #13814, git+ssh test case (#13839)
Follow-ups to review on #13814
1 parent e7c066c commit a748336

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

crates/uv/tests/it/common/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1626,7 +1626,7 @@ pub const READ_ONLY_GITHUB_TOKEN_2: &[&str] = &[
16261626
"SHIzUG1tRVZRSHMzQTl2a3NiVnB4Tmk0eTR3R2JVYklLck1qY05naHhMSFVMTDZGVElIMXNYeFhYN2gK",
16271627
];
16281628

1629-
pub const SSH_DEPLOY_KEY: &str = "LS0tLS1CRUdJTiBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLS0KYjNCbGJuTnphQzFyWlhrdGRqRUFBQUFBQkc1dmJtVUFBQUFFYm05dVpRQUFBQUFBQUFBQkFBQUFNd0FBQUF0emMyZ3RaVwpReU5UVXhPUUFBQUNBeTF1SnNZK1JXcWp1NkdIY3Z6a3AwS21yWDEwdmo3RUZqTkpNTkRqSGZPZ0FBQUpqWUpwVnAyQ2FWCmFRQUFBQXR6YzJndFpXUXlOVFV4T1FBQUFDQXkxdUpzWStSV3FqdTZHSGN2emtwMEttclgxMHZqN0VGak5KTU5EakhmT2cKQUFBRUMwbzBnd1BxbGl6TFBJOEFXWDVaS2dVZHJyQ2ptMDhIQm9FenB4VDg3MXBqTFc0bXhqNUZhcU83b1lkeS9PU25RcQphdGZYUytQc1FXTTBrdzBPTWQ4NkFBQUFFR3R2Ym5OMGFVQmhjM1J5WVd3dWMyZ0JBZ01FQlE9PQotLS0tLUVORCBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLS0K";
1629+
pub const READ_ONLY_GITHUB_SSH_DEPLOY_KEY: &str = "LS0tLS1CRUdJTiBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLS0KYjNCbGJuTnphQzFyWlhrdGRqRUFBQUFBQkc1dmJtVUFBQUFFYm05dVpRQUFBQUFBQUFBQkFBQUFNd0FBQUF0emMyZ3RaVwpReU5UVXhPUUFBQUNBeTF1SnNZK1JXcWp1NkdIY3Z6a3AwS21yWDEwdmo3RUZqTkpNTkRqSGZPZ0FBQUpqWUpwVnAyQ2FWCmFRQUFBQXR6YzJndFpXUXlOVFV4T1FBQUFDQXkxdUpzWStSV3FqdTZHSGN2emtwMEttclgxMHZqN0VGak5KTU5EakhmT2cKQUFBRUMwbzBnd1BxbGl6TFBJOEFXWDVaS2dVZHJyQ2ptMDhIQm9FenB4VDg3MXBqTFc0bXhqNUZhcU83b1lkeS9PU25RcQphdGZYUytQc1FXTTBrdzBPTWQ4NkFBQUFFR3R2Ym5OMGFVQmhjM1J5WVd3dWMyZ0JBZ01FQlE9PQotLS0tLUVORCBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLS0K";
16301630

16311631
/// Decode a split, base64 encoded authentication token.
16321632
/// We split and encode the token to bypass revoke by GitHub's secret scanning

crates/uv/tests/it/export.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#![allow(clippy::disallowed_types)]
22

33
use crate::common::{
4-
READ_ONLY_GITHUB_TOKEN, SSH_DEPLOY_KEY, TestContext, apply_filters, decode_token, uv_snapshot,
4+
READ_ONLY_GITHUB_SSH_DEPLOY_KEY, READ_ONLY_GITHUB_TOKEN, TestContext, apply_filters,
5+
decode_token, uv_snapshot,
56
};
67
use anyhow::{Ok, Result};
78
use assert_cmd::assert::OutputAssertExt;
@@ -1176,12 +1177,14 @@ fn requirements_txt_https_git_credentials() -> Result<()> {
11761177
Ok(())
11771178
}
11781179

1179-
/// SSH blocks too permissive key files.
1180-
fn reduce_key_permissions(key_file: &Path) -> Result<()> {
1180+
/// SSH blocks too permissive key files, so we need to scope permissions for the file to the current
1181+
/// user.
1182+
fn reduce_ssh_key_file_permissions(key_file: &Path) -> Result<()> {
11811183
#[cfg(unix)]
11821184
{
11831185
use std::fs::Permissions;
11841186
use std::os::unix::fs::PermissionsExt;
1187+
11851188
fs_err::set_permissions(key_file, Permissions::from_mode(0o400))?;
11861189
}
11871190
#[cfg(windows)]
@@ -1223,9 +1226,10 @@ fn requirements_txt_ssh_git_username() -> Result<()> {
12231226

12241227
let fake_deploy_key = context.temp_dir.child("fake_deploy_key");
12251228
fake_deploy_key.write_str("not a key")?;
1226-
reduce_key_permissions(&fake_deploy_key)?;
1229+
reduce_ssh_key_file_permissions(&fake_deploy_key)?;
12271230

1228-
// Ensure that we're loading the key and fail if it isn't present
1231+
// Ensure that we fail without passing the correct key (and don't go to the dev machine's
1232+
// credential helper).
12291233
let failing_git_ssh_command = format!(
12301234
"ssh -i {} -o IdentitiesOnly=yes -F /dev/null -o StrictHostKeyChecking=no",
12311235
fake_deploy_key.portable_display()
@@ -1266,8 +1270,8 @@ fn requirements_txt_ssh_git_username() -> Result<()> {
12661270
"#);
12671271

12681272
let ssh_deploy_key = context.temp_dir.child("uv_test_key");
1269-
ssh_deploy_key.write_str((decode_token(&[SSH_DEPLOY_KEY]) + "\n").as_str())?;
1270-
reduce_key_permissions(&ssh_deploy_key)?;
1273+
ssh_deploy_key.write_str((decode_token(&[READ_ONLY_GITHUB_SSH_DEPLOY_KEY]) + "\n").as_str())?;
1274+
reduce_ssh_key_file_permissions(&ssh_deploy_key)?;
12711275

12721276
// Use the specified SSH key, and only that key, ignore `~/.ssh/config`, disable host key
12731277
// verification for Windows.

0 commit comments

Comments
 (0)