mirror of
https://github.com/trailofbits/buttercup
synced 2026-06-21 14:11:39 +00:00
e3d0d29356
Apply automated fixes from ruff (import ordering, formatting) to all test files across all components: - Reorder imports according to isort/ruff rules - Remove unnecessary imports - Consistent formatting Components affected: - fuzzer/tests/ - orchestrator/test/ - patcher/tests/ - program-model/tests/ - seed-gen/test/ Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
33 lines
1021 B
Python
33 lines
1021 B
Python
import os
|
|
import tempfile
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from buttercup.seed_gen.sandbox.sandbox import sandbox_exec_funcs
|
|
|
|
expected_seeds = [
|
|
b"GET / HTTP/1.1\r\nHost: localhost\r\nCookie: uid=shortcookie\r\nAccept: */*\r\n\r\n",
|
|
b"GET / HTTP/1.1\r\nHost: localhost\r\nCookie: uid=invalid_base64_cookie\r\nAccept: */*\r\n\r\n", # noqa: E501
|
|
]
|
|
|
|
|
|
def read_seeds(outdir: Path) -> list[bytes]:
|
|
return [file.read_bytes() for file in outdir.iterdir()]
|
|
|
|
|
|
@pytest.mark.skipif(
|
|
not os.environ.get("PYTHON_WASM_BUILD_PATH"),
|
|
reason="PYTHON_WASM_BUILD_PATH environment variable not set",
|
|
)
|
|
def test_sandbox_exec_funcs():
|
|
file_path = os.path.abspath(__file__)
|
|
test_file = Path(file_path).parent / "data/example_seed_funcs.py"
|
|
expected_seeds.sort()
|
|
with tempfile.TemporaryDirectory() as outdir_str:
|
|
outdir = Path(outdir_str)
|
|
sandbox_exec_funcs(test_file.read_text(), outdir)
|
|
seeds = read_seeds(outdir)
|
|
seeds.sort()
|
|
assert seeds == expected_seeds
|