aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/google-auth/py3/tests/compute_engine/test_credentials.py
diff options
context:
space:
mode:
authorAlexSm <alex@ydb.tech>2023-12-27 23:31:58 +0100
committerGitHub <noreply@github.com>2023-12-27 23:31:58 +0100
commitd67bfb4b4b7549081543e87a31bc6cb5c46ac973 (patch)
tree8674f2f1570877cb653e7ddcff37ba00288de15a /contrib/python/google-auth/py3/tests/compute_engine/test_credentials.py
parent1f6bef05ed441c3aa2d565ac792b26cded704ac7 (diff)
downloadydb-d67bfb4b4b7549081543e87a31bc6cb5c46ac973.tar.gz
Import libs 4 (#758)
Diffstat (limited to 'contrib/python/google-auth/py3/tests/compute_engine/test_credentials.py')
-rw-r--r--contrib/python/google-auth/py3/tests/compute_engine/test_credentials.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/contrib/python/google-auth/py3/tests/compute_engine/test_credentials.py b/contrib/python/google-auth/py3/tests/compute_engine/test_credentials.py
index 507fea9fcc..5d6ccdcdec 100644
--- a/contrib/python/google-auth/py3/tests/compute_engine/test_credentials.py
+++ b/contrib/python/google-auth/py3/tests/compute_engine/test_credentials.py
@@ -208,6 +208,30 @@ class TestCredentials(object):
assert headers["authorization"] == "Bearer token"
assert headers["x-goog-api-client"] == "cred-type/mds"
+ @mock.patch(
+ "google.auth.compute_engine._metadata.get_universe_domain",
+ return_value="fake_universe_domain",
+ )
+ def test_universe_domain(self, get_universe_domain):
+ self.credentials._universe_domain_cached = False
+ self.credentials._universe_domain = "googleapis.com"
+
+ # calling the universe_domain property should trigger a call to
+ # get_universe_domain to fetch the value. The value should be cached.
+ assert self.credentials.universe_domain == "fake_universe_domain"
+ assert self.credentials._universe_domain == "fake_universe_domain"
+ assert self.credentials._universe_domain_cached
+ get_universe_domain.assert_called_once_with(
+ self.credentials._universe_domain_request
+ )
+
+ # calling the universe_domain property the second time should use the
+ # cached value instead of calling get_universe_domain
+ assert self.credentials.universe_domain == "fake_universe_domain"
+ get_universe_domain.assert_called_once_with(
+ self.credentials._universe_domain_request
+ )
+
class TestIDTokenCredentials(object):
credentials = None