File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
packages/google-auth/system_tests/system_tests_sync Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 1414
1515from datetime import datetime
1616
17+ import os
1718import pytest
1819
1920import google .auth
2930
3031@pytest .fixture (autouse = True )
3132def check_gce_environment (http_request ):
33+ # 1. Verify we are actually on a GCE instance
3234 try :
3335 _metadata .get_service_account_info (http_request )
3436 except exceptions .TransportError :
3537 pytest .skip ("Compute Engine metadata service is not available." )
3638
39+ # 2. Prevent local Service Account key from overriding GCE credentials
40+ original_creds = os .environ .get ("GOOGLE_APPLICATION_CREDENTIALS" )
41+ if "GOOGLE_APPLICATION_CREDENTIALS" in os .environ :
42+ del os .environ ["GOOGLE_APPLICATION_CREDENTIALS" ]
43+
44+ yield
45+
46+ # 3. Restore environment after the test
47+ if original_creds is not None :
48+ os .environ ["GOOGLE_APPLICATION_CREDENTIALS" ] = original_creds
49+
3750
3851def test_refresh (http_request , token_info ):
3952 credentials = compute_engine .Credentials ()
You can’t perform that action at this time.
0 commit comments