mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-03 09:50:45 +08:00
test: scope POSIX-only sandbox fallback and file-mode checks
This commit is contained in:
@@ -10,6 +10,7 @@ filename.
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -82,6 +83,7 @@ def test_a_preferences_file_cannot_be_addressed_outside_its_directory(owner: str
|
||||
prefs_path(owner)
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform == "win32", reason="POSIX file modes")
|
||||
def test_the_tree_is_created_owner_only(cli_app_roots: Path) -> None:
|
||||
root = ensure_root()
|
||||
assert root.is_dir()
|
||||
@@ -99,7 +101,10 @@ def test_an_executable_path_cannot_escape_the_app_directory(entry_point: str) ->
|
||||
def test_an_executable_resolves_inside_its_own_app_directory() -> None:
|
||||
path = executable_path("demo", AppRuntime.PYTHON, "cli-anything-demo")
|
||||
assert path.is_relative_to(app_dir("demo"))
|
||||
assert path.name == "cli-anything-demo"
|
||||
# A Windows Python venv writes the console script as ``<name>.exe``.
|
||||
assert path.name == (
|
||||
"cli-anything-demo.exe" if sys.platform == "win32" else "cli-anything-demo"
|
||||
)
|
||||
|
||||
|
||||
def test_each_app_gets_its_own_environment() -> None:
|
||||
|
||||
@@ -11,6 +11,7 @@ import asyncio
|
||||
import json
|
||||
from pathlib import Path
|
||||
import stat
|
||||
import sys
|
||||
from urllib.parse import parse_qs, urlsplit
|
||||
|
||||
import pytest
|
||||
@@ -252,6 +253,7 @@ def test_the_store_is_outside_every_sandbox_mounted_tree(roots: Path) -> None:
|
||||
assert not path.is_relative_to(roots / "user" / "workspace")
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform == "win32", reason="POSIX file modes")
|
||||
def test_the_store_file_is_owner_only(roots: Path) -> None:
|
||||
asyncio.run(_store("u_ada", "notion"))
|
||||
path = oauth._store_path("u_ada", "notion")
|
||||
|
||||
@@ -143,10 +143,22 @@ def test_the_local_backend_passes_a_hostile_argument_through_untouched(argument:
|
||||
assert result.stdout == argument
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
sys.platform == "win32",
|
||||
reason=(
|
||||
"the compatibility string is shlex-joined for the Linux runner image; "
|
||||
"PowerShell cannot parse POSIX quoting and argv is what Windows runs"
|
||||
),
|
||||
)
|
||||
@pytest.mark.parametrize("argument", HOSTILE_ARGS)
|
||||
def test_the_shell_fallback_is_quoted_well_enough_to_be_equivalent(argument: str) -> None:
|
||||
"""The compatibility path has to be *correct*, not merely present: on an old
|
||||
runner image this string is what actually executes."""
|
||||
runner image this string is what actually executes.
|
||||
|
||||
That runner image is Linux-only. Windows has no pre-``argv`` runner: the
|
||||
local backend execs the vector itself, and a POSIX-quoted string handed to
|
||||
PowerShell is a parse error rather than a different execution.
|
||||
"""
|
||||
request = ExecRequest.of_argv(
|
||||
["/usr/bin/env", "python3", "-c", "import sys; print(sys.argv[1], end='')", argument]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user