Fix multiple_dots test for Windows path resolution

On Windows, ....//secrets.yaml escapes the base directory (403),
while on Unix it stays inside (404). Use sys.platform to set the
expected status code per platform.
This commit is contained in:
J. Nick Koston
2026-02-08 07:22:08 -06:00
parent 803b9a7a18
commit e362e6fe2f

View File

@@ -8,6 +8,7 @@ import gzip
import json
import os
from pathlib import Path
import sys
from unittest.mock import AsyncMock, MagicMock, Mock, patch
import pytest
@@ -535,7 +536,11 @@ async def test_download_binary_handler_subdirectory_file_url_encoded(
pytest.param("zephyr/../../../secrets.yaml", 403, id="traversal_with_prefix"),
pytest.param("/etc/passwd", 403, id="absolute_path"),
pytest.param("//etc/passwd", 403, id="double_slash_absolute"),
pytest.param("....//secrets.yaml", 404, id="multiple_dots"),
pytest.param(
"....//secrets.yaml",
403 if sys.platform == "win32" else 404,
id="multiple_dots",
),
],
)
async def test_download_binary_handler_path_traversal_protection(