@@ -509,6 +509,81 @@ def port(self) -> int:
509509 ClientConfig .normalize_base_url ("https://example.local" )
510510
511511
512+ def test_client_config_normalize_base_url_rejects_invalid_username_types (
513+ monkeypatch : pytest .MonkeyPatch ,
514+ ):
515+ class _ParsedURL :
516+ scheme = "https"
517+ netloc = "example.local"
518+ hostname = "example.local"
519+ query = ""
520+ fragment = ""
521+ username = object ()
522+ password = None
523+ path = "/api"
524+
525+ @property
526+ def port (self ) -> int :
527+ return 443
528+
529+ monkeypatch .setattr (config_module , "urlparse" , lambda _value : _ParsedURL ())
530+
531+ with pytest .raises (
532+ HyperbrowserError , match = "base_url parser returned invalid URL components"
533+ ):
534+ ClientConfig .normalize_base_url ("https://example.local" )
535+
536+
537+ def test_client_config_normalize_base_url_rejects_invalid_password_types (
538+ monkeypatch : pytest .MonkeyPatch ,
539+ ):
540+ class _ParsedURL :
541+ scheme = "https"
542+ netloc = "example.local"
543+ hostname = "example.local"
544+ query = ""
545+ fragment = ""
546+ username = None
547+ password = object ()
548+ path = "/api"
549+
550+ @property
551+ def port (self ) -> int :
552+ return 443
553+
554+ monkeypatch .setattr (config_module , "urlparse" , lambda _value : _ParsedURL ())
555+
556+ with pytest .raises (
557+ HyperbrowserError , match = "base_url parser returned invalid URL components"
558+ ):
559+ ClientConfig .normalize_base_url ("https://example.local" )
560+
561+
562+ def test_client_config_normalize_base_url_rejects_invalid_port_types (
563+ monkeypatch : pytest .MonkeyPatch ,
564+ ):
565+ class _ParsedURL :
566+ scheme = "https"
567+ netloc = "example.local"
568+ hostname = "example.local"
569+ query = ""
570+ fragment = ""
571+ username = None
572+ password = None
573+ path = "/api"
574+
575+ @property
576+ def port (self ):
577+ return "443"
578+
579+ monkeypatch .setattr (config_module , "urlparse" , lambda _value : _ParsedURL ())
580+
581+ with pytest .raises (
582+ HyperbrowserError , match = "base_url parser returned invalid URL components"
583+ ):
584+ ClientConfig .normalize_base_url ("https://example.local" )
585+
586+
512587def test_client_config_normalize_base_url_wraps_hostname_access_errors (
513588 monkeypatch : pytest .MonkeyPatch ,
514589):
0 commit comments