|
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | 15 | import pytest |
| 16 | +from google.auth.exceptions import MutualTLSChannelError |
16 | 17 |
|
17 | 18 | from google.api_core import universe |
18 | | -from google.auth.exceptions import MutualTLSChannelError |
19 | 19 |
|
20 | 20 |
|
21 | 21 | class _Fake_Credentials: |
@@ -114,13 +114,19 @@ def test_get_universe_domain(): |
114 | 114 |
|
115 | 115 | def test_get_default_mtls_endpoint(): |
116 | 116 | # Test valid API endpoints |
117 | | - assert universe.get_default_mtls_endpoint("foo.googleapis.com") == "foo.mtls.googleapis.com" |
| 117 | + assert ( |
| 118 | + universe.get_default_mtls_endpoint("foo.googleapis.com") |
| 119 | + == "foo.mtls.googleapis.com" |
| 120 | + ) |
118 | 121 | assert ( |
119 | 122 | universe.get_default_mtls_endpoint("foo.sandbox.googleapis.com") |
120 | 123 | == "foo.mtls.sandbox.googleapis.com" |
121 | 124 | ) |
122 | 125 | # Test case-insensitivity |
123 | | - assert universe.get_default_mtls_endpoint("foo.GoogleAPIs.com") == "foo.mtls.googleapis.com" |
| 126 | + assert ( |
| 127 | + universe.get_default_mtls_endpoint("foo.GoogleAPIs.com") |
| 128 | + == "foo.mtls.googleapis.com" |
| 129 | + ) |
124 | 130 | assert ( |
125 | 131 | universe.get_default_mtls_endpoint("foo.Sandbox.GoogleAPIs.com") |
126 | 132 | == "foo.mtls.sandbox.googleapis.com" |
@@ -167,6 +173,10 @@ def test_get_default_mtls_endpoint(): |
167 | 173 | assert universe.get_default_mtls_endpoint("") == "" |
168 | 174 | assert universe.get_default_mtls_endpoint(None) is None |
169 | 175 |
|
| 176 | + # Test endpoints without host |
| 177 | + assert universe.get_default_mtls_endpoint("http://") == "http://" |
| 178 | + assert universe.get_default_mtls_endpoint("https://") == "https://" |
| 179 | + |
170 | 180 |
|
171 | 181 | @pytest.mark.parametrize( |
172 | 182 | "api_override,universe_domain,default_universe,default_mtls_endpoint,default_endpoint_template,use_mtls,expected", |
@@ -249,4 +259,3 @@ def test_get_api_endpoint( |
249 | 259 | ) |
250 | 260 | == expected |
251 | 261 | ) |
252 | | - |
|
0 commit comments