Skip to content

Commit 9c10174

Browse files
committed
Add Windows custom-base SSH cleanup tests (apache#69813)
1 parent e8423e5 commit 9c10174

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎providers/ssh/tests/unit/ssh/utils/test_remote_job.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,15 @@ def test_windows_cleanup(self):
412412
assert "Remove-Item" in decoded_script
413413
assert "-Recurse" in decoded_script
414414

415+
def test_windows_cleanup_with_custom_base(self):
416+
"""Test Windows cleanup under a custom base directory."""
417+
cmd = build_windows_cleanup_command(
418+
"$env:TEMP\\custom-airflow-ssh-jobs\\job_123",
419+
expected_base="$env:TEMP\\custom-airflow-ssh-jobs",
420+
)
421+
assert "powershell.exe" in cmd
422+
assert "-EncodedCommand" in cmd
423+
415424
def test_posix_cleanup_rejects_invalid_path(self):
416425
"""Test POSIX cleanup rejects paths outside expected base directory."""
417426
with pytest.raises(ValueError, match="Invalid job directory"):
@@ -428,3 +437,11 @@ def test_windows_cleanup_rejects_invalid_path(self):
428437
"""Test Windows cleanup rejects paths outside expected base directory."""
429438
with pytest.raises(ValueError, match="Invalid job directory"):
430439
build_windows_cleanup_command("C:\\temp\\other_dir")
440+
441+
def test_windows_cleanup_rejects_path_outside_custom_base(self):
442+
"""Test Windows cleanup rejects paths outside a custom base directory."""
443+
with pytest.raises(ValueError, match="Invalid job directory"):
444+
build_windows_cleanup_command(
445+
"$env:TEMP\\airflow-ssh-jobs\\job_123",
446+
expected_base="$env:TEMP\\custom-airflow-ssh-jobs",
447+
)

0 commit comments

Comments
 (0)