Skip to content

Commit 7912839

Browse files
Expand parsed URL component type regression coverage
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 39192a0 commit 7912839

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/test_config.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,56 @@ def port(self):
644644
ClientConfig.normalize_base_url("https://example.local")
645645

646646

647+
def test_client_config_normalize_base_url_rejects_boolean_port_values(
648+
monkeypatch: pytest.MonkeyPatch,
649+
):
650+
class _ParsedURL:
651+
scheme = "https"
652+
netloc = "example.local"
653+
hostname = "example.local"
654+
query = ""
655+
fragment = ""
656+
username = None
657+
password = None
658+
path = "/api"
659+
660+
@property
661+
def port(self):
662+
return True
663+
664+
monkeypatch.setattr(config_module, "urlparse", lambda _value: _ParsedURL())
665+
666+
with pytest.raises(
667+
HyperbrowserError, match="base_url parser returned invalid URL components"
668+
):
669+
ClientConfig.normalize_base_url("https://example.local")
670+
671+
672+
def test_client_config_normalize_base_url_rejects_invalid_query_component_types(
673+
monkeypatch: pytest.MonkeyPatch,
674+
):
675+
class _ParsedURL:
676+
scheme = "https"
677+
netloc = "example.local"
678+
hostname = "example.local"
679+
query = object()
680+
fragment = ""
681+
username = None
682+
password = None
683+
path = "/api"
684+
685+
@property
686+
def port(self) -> int:
687+
return 443
688+
689+
monkeypatch.setattr(config_module, "urlparse", lambda _value: _ParsedURL())
690+
691+
with pytest.raises(
692+
HyperbrowserError, match="base_url parser returned invalid URL components"
693+
):
694+
ClientConfig.normalize_base_url("https://example.local")
695+
696+
647697
def test_client_config_normalize_base_url_rejects_out_of_range_port_values(
648698
monkeypatch: pytest.MonkeyPatch,
649699
):

0 commit comments

Comments
 (0)