@@ -696,7 +696,9 @@ def test_accepts_idn_hosts_and_preserves_the_supplied_representation(
696696 assert str (options ) == f"chronicle://id:****@{ host } :35000"
697697
698698
699- @pytest .mark .parametrize ("host" , ["PRIVATE_HOST\ud800 .example" , "é" * 58 + ".example" , "münchen.xn--" ])
699+ @pytest .mark .parametrize (
700+ "host" , ["PRIVATE_HOST\ud800 .example" , "é" * 58 + ".example" , "münchen.xn--" , "münchen.XN--.example" ]
701+ )
700702def test_idna_conversion_failures_raise_a_chain_free_host_error (host : str ) -> None :
701703 connection_string = f"chronicle://PRIVATE_CLIENT:PRIVATE_SECRET@{ host } "
702704 with pytest .raises (InvalidHostError ) as caught :
@@ -712,7 +714,17 @@ def test_idna_conversion_failures_raise_a_chain_free_host_error(host: str) -> No
712714
713715
714716@pytest .mark .parametrize (
715- "host" , ["example.com" , "127.0.0.1" , "ex\u034f ample.com" , "x\u2024 y.é" , "faß.de" ]
717+ "host" ,
718+ [
719+ "example.com" ,
720+ "127.0.0.1" ,
721+ "ex\u034f ample.com" ,
722+ "x\u2024 y.é" ,
723+ "faß.de" ,
724+ "xς.example" ,
725+ "fi.example" ,
726+ "Dž.example" ,
727+ ],
716728)
717729@pytest .mark .parametrize ("trailing_dot" , ["" , "." ])
718730def test_rejects_idna_mappings_that_change_the_supplied_host (host : str , trailing_dot : str ) -> None :
@@ -729,6 +741,28 @@ def test_rejects_idna_mappings_that_change_the_supplied_host(host: str, trailing
729741 assert caught .value .__context__ is None
730742
731743
744+ @pytest .mark .parametrize (
745+ "host" ,
746+ [
747+ "münchen.xn--mnchen-3ya" ,
748+ "例え.xn--zckzah" ,
749+ "bücher.xn--r8jz45g.example" ,
750+ "münchen.XN--MNCHEN-3YA.example" ,
751+ ],
752+ )
753+ @pytest .mark .parametrize ("host_case" , ["supplied" , "upper" ])
754+ @pytest .mark .parametrize ("trailing_dot" , ["" , "." ])
755+ def test_accepts_mixed_unicode_and_punycode_labels (host : str , host_case : str , trailing_dot : str ) -> None :
756+ if host_case == "upper" :
757+ host = host .upper ()
758+ host += trailing_dot
759+ options = parse_connection_string (f"chronicle://id:secret@{ host } " )
760+
761+ assert options .host == host
762+ assert str (options ) == f"chronicle://id:****@{ host } :35000"
763+ assert parse_connection_string (str (options ).replace ("****" , "secret" )) == options
764+
765+
732766@pytest .mark .parametrize ("trailing_dot" , ["" , "." ])
733767def test_accepts_unicode_hosts_at_the_encoded_dns_length_limits (trailing_dot : str ) -> None :
734768 host = "." .join (["é" * 57 ] * 3 + ["a" * 61 ]) + trailing_dot
0 commit comments