File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,14 +33,15 @@ def get_default_mtls_endpoint(api_endpoint: Optional[str]) -> Optional[str]:
3333 Returns:
3434 Optional[str]: converted mTLS api endpoint.
3535 """
36- if not api_endpoint or ".mtls." in api_endpoint :
36+ if not api_endpoint or ".mtls." in api_endpoint . lower () :
3737 return api_endpoint
3838
39- if api_endpoint .endswith (".sandbox.googleapis.com" ):
39+ lowered_endpoint = api_endpoint .lower ()
40+ if lowered_endpoint .endswith (".sandbox.googleapis.com" ):
4041 # len(".sandbox.googleapis.com") == 23
4142 return api_endpoint [:- 23 ] + ".mtls.sandbox.googleapis.com"
4243
43- if api_endpoint .endswith (".googleapis.com" ):
44+ if lowered_endpoint .endswith (".googleapis.com" ):
4445 # len(".googleapis.com") == 15
4546 return api_endpoint [:- 15 ] + ".mtls.googleapis.com"
4647
Original file line number Diff line number Diff line change @@ -39,6 +39,15 @@ def test_get_default_mtls_endpoint():
3939 get_default_mtls_endpoint ("foo.sandbox.googleapis.com" )
4040 == "foo.mtls.sandbox.googleapis.com"
4141 )
42+ # Test case-insensitivity
43+ assert (
44+ get_default_mtls_endpoint ("foo.GoogleAPIs.com" )
45+ == "foo.mtls.googleapis.com"
46+ )
47+ assert (
48+ get_default_mtls_endpoint ("foo.Sandbox.GoogleAPIs.com" )
49+ == "foo.mtls.sandbox.googleapis.com"
50+ )
4251
4352 # Test endpoints that shouldn't be converted
4453 assert (
You can’t perform that action at this time.
0 commit comments