@@ -644,6 +644,33 @@ def test_accepts_rfc6874_zone_characters(zone: str, delimiter: str) -> None:
644644 assert options .host == f"fe80::1%{ zone } "
645645
646646
647+ @pytest .mark .parametrize ("codepoint" , [0x0378 , 0x0890 , 0x0891 , * range (0x13439 , 0x13440 )])
648+ @pytest .mark .parametrize ("field" , ["client_id" , "client_secret" ])
649+ def test_rejects_raw_unassigned_or_newly_assigned_format_characters (codepoint : int , field : str ) -> None :
650+ character = chr (codepoint )
651+ client_id = "id" + (character if field == "client_id" else "" )
652+ client_secret = "secret" + (character if field == "client_secret" else "" )
653+ connection_string = f"chronicle://{ client_id } :{ client_secret } @localhost"
654+ with pytest .raises (MalformedConnectionStringError ) as caught :
655+ parse_connection_string (connection_string )
656+
657+ assert caught .value .__cause__ is None
658+ assert caught .value .__context__ is None
659+
660+
661+ @pytest .mark .parametrize ("codepoint" , [0x0378 , 0x0890 , 0x0891 , * range (0x13439 , 0x13440 )])
662+ @pytest .mark .parametrize ("field" , ["client_id" , "client_secret" ])
663+ def test_preserves_percent_encoded_unassigned_or_newly_assigned_format_characters (codepoint : int , field : str ) -> None :
664+ character = chr (codepoint )
665+ client_id = "id" + (quote (character ) if field == "client_id" else "" )
666+ client_secret = "secret" + (quote (character ) if field == "client_secret" else "" )
667+ options = parse_connection_string (f"chronicle://{ client_id } :{ client_secret } @localhost" )
668+
669+ assert options .client_id == "id" + (character if field == "client_id" else "" )
670+ assert options .client_secret == "secret" + (character if field == "client_secret" else "" )
671+ assert str (options )
672+
673+
647674def test_an_invalid_ipv6_host_error_does_not_retain_the_input_in_its_chain () -> None :
648675 secret = "super-secret"
649676 with pytest .raises (InvalidHostError ) as caught :
0 commit comments