Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions codex-rs/exec-server/tests/file_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,11 @@ async fn file_system_copy_rejects_directory_without_recursive(use_remote: bool)
Ok(())
}

#[test_case(false ; "local")]
#[test_case(true ; "remote")]
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn file_system_sandboxed_read_allows_readable_root() -> Result<()> {
let context = create_file_system_context(/*use_remote*/ false).await?;
async fn file_system_sandboxed_read_allows_readable_root(use_remote: bool) -> Result<()> {
let context = create_file_system_context(use_remote).await?;
let file_system = context.file_system;

let tmp = TempDir::new()?;
Expand All @@ -391,7 +393,8 @@ async fn file_system_sandboxed_read_allows_readable_root() -> Result<()> {

let contents = file_system
.read_file(&absolute_path(file_path), Some(&sandbox))
.await?;
.await
.with_context(|| format!("mode={use_remote}"))?;
assert_eq!(contents, b"sandboxed hello");

Ok(())
Expand Down Expand Up @@ -520,9 +523,13 @@ async fn file_system_sandboxed_read_rejects_symlink_escape(use_remote: bool) ->
Ok(())
}

#[test_case(false ; "local")]
#[test_case(true ; "remote")]
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn file_system_sandboxed_read_rejects_symlink_parent_dotdot_escape() -> Result<()> {
let context = create_file_system_context(/*use_remote*/ false).await?;
async fn file_system_sandboxed_read_rejects_symlink_parent_dotdot_escape(
use_remote: bool,
) -> Result<()> {
let context = create_file_system_context(use_remote).await?;
let file_system = context.file_system;

let tmp = TempDir::new()?;
Expand Down Expand Up @@ -680,9 +687,11 @@ async fn file_system_copy_rejects_symlink_escape_destination(use_remote: bool) -
Ok(())
}

#[test_case(false ; "local")]
#[test_case(true ; "remote")]
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn file_system_remove_removes_symlink_not_target() -> Result<()> {
let context = create_file_system_context(/*use_remote*/ false).await?;
async fn file_system_remove_removes_symlink_not_target(use_remote: bool) -> Result<()> {
let context = create_file_system_context(use_remote).await?;
let file_system = context.file_system;

let tmp = TempDir::new()?;
Expand All @@ -705,7 +714,8 @@ async fn file_system_remove_removes_symlink_not_target() -> Result<()> {
},
Some(&sandbox),
)
.await?;
.await
.with_context(|| format!("mode={use_remote}"))?;

assert!(!symlink_path.exists());
assert!(outside_file.exists());
Expand All @@ -714,9 +724,11 @@ async fn file_system_remove_removes_symlink_not_target() -> Result<()> {
Ok(())
}

#[test_case(false ; "local")]
#[test_case(true ; "remote")]
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn file_system_copy_preserves_symlink_source() -> Result<()> {
let context = create_file_system_context(/*use_remote*/ false).await?;
async fn file_system_copy_preserves_symlink_source(use_remote: bool) -> Result<()> {
let context = create_file_system_context(use_remote).await?;
let file_system = context.file_system;

let tmp = TempDir::new()?;
Expand All @@ -738,7 +750,8 @@ async fn file_system_copy_preserves_symlink_source() -> Result<()> {
CopyOptions { recursive: false },
Some(&sandbox),
)
.await?;
.await
.with_context(|| format!("mode={use_remote}"))?;

let copied_metadata = std::fs::symlink_metadata(&copied_symlink)?;
assert!(copied_metadata.file_type().is_symlink());
Expand Down
Loading