aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorchenyumic <chenyumic@google.com>2020-06-04 10:14:05 -0700
committerGitHub <noreply@github.com>2020-06-04 17:14:05 +0000
commit8ffb4d3e832607869026444e5a071c5f3e225fd2 (patch)
treeb237e32022c55917b204f60758997a3fda4ddf45 /tests
parent9d5a9a9884fecbd698a602d2a9fd9bec6b987de7 (diff)
downloadgoogle-auth-library-python-8ffb4d3e832607869026444e5a071c5f3e225fd2.tar.gz
fix: replace environment variable GCE_METADATA_ROOT with GCE_METADATA_HOST (#433)
…_HOST * keeps consistent naming across auth packages of all languages. The package will now check GCE_METADATA_HOST (the new name) first; if not present, it falls back to GCE_METADATA_ROOT (the old name), then the default value. closes [#339](https://github.com/googleapis/google-auth-library-python/issues/339).
Diffstat (limited to 'tests')
-rw-r--r--tests/compute_engine/test__metadata.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/compute_engine/test__metadata.py b/tests/compute_engine/test__metadata.py
index 8b5eece..d9b039a 100644
--- a/tests/compute_engine/test__metadata.py
+++ b/tests/compute_engine/test__metadata.py
@@ -155,7 +155,27 @@ def test_get_success_text():
assert result == data
-def test_get_success_custom_root():
+def test_get_success_custom_root_new_variable():
+ request = make_request("{}", headers={"content-type": "application/json"})
+
+ fake_root = "another.metadata.service"
+ os.environ[environment_vars.GCE_METADATA_HOST] = fake_root
+ reload_module(_metadata)
+
+ try:
+ _metadata.get(request, PATH)
+ finally:
+ del os.environ[environment_vars.GCE_METADATA_HOST]
+ reload_module(_metadata)
+
+ request.assert_called_once_with(
+ method="GET",
+ url="http://{}/computeMetadata/v1/{}".format(fake_root, PATH),
+ headers=_metadata._METADATA_HEADERS,
+ )
+
+
+def test_get_success_custom_root_old_variable():
request = make_request("{}", headers={"content-type": "application/json"})
fake_root = "another.metadata.service"