Skyvern/tests/unit/test_strip_query_params.py
Andrew Neilson b7aee473e8
feat(SKY-8879) copilot-stack/12: wire-up (flag + dispatch + frontend) (#5531)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 17:25:07 -07:00

29 lines
1.2 KiB
Python

from __future__ import annotations
import pytest # type: ignore[import-not-found]
from skyvern.utils.url_validators import strip_query_params
@pytest.mark.parametrize(
"url,expected",
[
("https://example.com/path?token=secret&id=1", "https://example.com/path"),
("https://example.com/path#fragment", "https://example.com/path"),
("https://example.com/path?q=1#frag", "https://example.com/path"),
("https://example.com/", "https://example.com/"),
("https://example.com", "https://example.com"),
("http://localhost:8000/api/v1/tasks", "http://localhost:8000/api/v1/tasks"),
# Credentials in URL — must be stripped to prevent PII leakage
("https://user:password@example.com/path?token=x", "https://example.com/path"),
("https://admin:secret@host.com:8443/api", "https://host.com:8443/api"),
# Edge cases that should return empty string
("", ""),
("example.com/path", ""),
("not-a-url", ""),
("/relative/path", ""),
("://missing-scheme", ""),
],
)
def test_strip_query_params(url: str, expected: str) -> None:
assert strip_query_params(url) == expected