Files
soxoj--maigret/tests/test_sanitize_username.py
wehub-resource-sync e52ddb7dd4
CodeQL / Analyze (python) (push) Failing after 1s
Linting and testing / build (3.11) (push) Failing after 0s
Package exe with PyInstaller - Windows / build (push) Failing after 2s
Linting and testing / build (3.10) (push) Failing after 1s
Linting and testing / minimal-install (push) Failing after 1s
Update sites rating and statistics / build (push) Failing after 1s
Build docker image and push to DockerHub / docker (push) Failing after 1s
Linting and testing / build (3.12) (push) Failing after 1s
Linting and testing / build (3.14) (push) Failing after 1s
Linting and testing / build (3.13) (push) Failing after 2s
chore: import upstream snapshot with attribution
2026-07-13 12:10:17 +08:00

29 lines
793 B
Python

import pytest
from maigret.web.app import sanitize_username_for_path
@pytest.mark.parametrize(
"input_username, expected",
[
("../../tmp/x", "_.._tmp_x"),
("..", "_"),
("....", "_"),
("foo/bar", "foo_bar"),
("\0foo", "_foo"),
("normaluser123", "normaluser123"),
],
)
def test_sanitize_username_for_path(input_username, expected):
result = sanitize_username_for_path(input_username)
assert result == expected
# Verify no path separators or null bytes remain
assert "/" not in result
assert "\\" not in result
assert "\0" not in result
# Verify result is not empty
assert len(result) > 0
# Verify no leading/trailing dots
assert not result.startswith(".")
assert not result.endswith(".")