mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-08-23 23:37:05 +00:00
Resolve individual and bulk download paths from the filesystem root so authenticated operators can download every path exposed by the File Browser and editor.\n\nKeep the existing authentication, CSRF, path normalization, and archive behavior, and cover downloads outside the Agent Zero runtime directory with a regression test.
21 lines
764 B
Python
21 lines
764 B
Python
from pathlib import Path
|
|
import zipfile
|
|
|
|
from api.download_work_dir_file import resolve_download_path
|
|
from api.download_work_dir_files import create_selected_zip
|
|
|
|
|
|
def test_download_resolvers_match_file_browser_root(tmp_path: Path) -> None:
|
|
file_path = tmp_path / "outside-a0.txt"
|
|
file_path.write_text("downloadable", encoding="utf-8")
|
|
|
|
assert resolve_download_path(str(file_path)) == str(file_path.resolve())
|
|
|
|
archive_path = Path(create_selected_zip([str(file_path)], "/"))
|
|
try:
|
|
with zipfile.ZipFile(archive_path) as archive:
|
|
name = str(file_path).lstrip("/")
|
|
assert archive.namelist() == [name]
|
|
assert archive.read(name) == b"downloadable"
|
|
finally:
|
|
archive_path.unlink(missing_ok=True)
|