diff options
Diffstat (limited to 'tests/test_external_account.py')
-rw-r--r-- | tests/test_external_account.py | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/tests/test_external_account.py b/tests/test_external_account.py index 97f1564..3c34f99 100644 --- a/tests/test_external_account.py +++ b/tests/test_external_account.py @@ -13,12 +13,12 @@ # limitations under the License. import datetime -import http.client import json -import urllib import mock import pytest +from six.moves import http_client +from six.moves import urllib from google.auth import _helpers from google.auth import exceptions @@ -208,7 +208,7 @@ class TestCredentials(object): @classmethod def make_mock_request( cls, - status=http.client.OK, + status=http_client.OK, data=None, impersonation_status=None, impersonation_data=None, @@ -605,7 +605,7 @@ class TestCredentials(object): "subject_token": "subject_token_0", "subject_token_type": self.SUBJECT_TOKEN_TYPE, } - request = self.make_mock_request(status=http.client.OK, data=response) + request = self.make_mock_request(status=http_client.OK, data=response) credentials = self.make_credentials() credentials.refresh(request) @@ -635,7 +635,7 @@ class TestCredentials(object): json.dumps({"userProject": self.WORKFORCE_POOL_USER_PROJECT}) ), } - request = self.make_mock_request(status=http.client.OK, data=response) + request = self.make_mock_request(status=http_client.OK, data=response) credentials = self.make_workforce_pool_credentials( workforce_pool_user_project=self.WORKFORCE_POOL_USER_PROJECT ) @@ -667,7 +667,7 @@ class TestCredentials(object): "subject_token": "subject_token_0", "subject_token_type": self.WORKFORCE_SUBJECT_TOKEN_TYPE, } - request = self.make_mock_request(status=http.client.OK, data=response) + request = self.make_mock_request(status=http_client.OK, data=response) # Client Auth will have higher priority over workforce_pool_user_project. credentials = self.make_workforce_pool_credentials( client_id=CLIENT_ID, @@ -704,7 +704,7 @@ class TestCredentials(object): "subject_token": "subject_token_0", "subject_token_type": self.WORKFORCE_SUBJECT_TOKEN_TYPE, } - request = self.make_mock_request(status=http.client.OK, data=response) + request = self.make_mock_request(status=http_client.OK, data=response) # Client Auth will be sufficient for user project determination. credentials = self.make_workforce_pool_credentials( client_id=CLIENT_ID, @@ -754,9 +754,9 @@ class TestCredentials(object): # Initialize mock request to handle token exchange and service account # impersonation request. request = self.make_mock_request( - status=http.client.OK, + status=http_client.OK, data=token_response, - impersonation_status=http.client.OK, + impersonation_status=http_client.OK, impersonation_data=impersonation_response, ) # Initialize credentials with service account impersonation. @@ -821,9 +821,9 @@ class TestCredentials(object): # Initialize mock request to handle token exchange and service account # impersonation request. request = self.make_mock_request( - status=http.client.OK, + status=http_client.OK, data=token_response, - impersonation_status=http.client.OK, + impersonation_status=http_client.OK, impersonation_data=impersonation_response, ) # Initialize credentials with service account impersonation. @@ -865,7 +865,7 @@ class TestCredentials(object): "subject_token_type": self.SUBJECT_TOKEN_TYPE, } request = self.make_mock_request( - status=http.client.OK, data=self.SUCCESS_RESPONSE + status=http_client.OK, data=self.SUCCESS_RESPONSE ) credentials = self.make_credentials( scopes=["scope1", "scope2"], @@ -893,7 +893,7 @@ class TestCredentials(object): "subject_token_type": self.SUBJECT_TOKEN_TYPE, } request = self.make_mock_request( - status=http.client.OK, data=self.SUCCESS_RESPONSE + status=http_client.OK, data=self.SUCCESS_RESPONSE ) credentials = self.make_credentials( scopes=None, @@ -911,7 +911,7 @@ class TestCredentials(object): def test_refresh_without_client_auth_error(self): request = self.make_mock_request( - status=http.client.BAD_REQUEST, data=self.ERROR_RESPONSE + status=http_client.BAD_REQUEST, data=self.ERROR_RESPONSE ) credentials = self.make_credentials() @@ -926,9 +926,9 @@ class TestCredentials(object): def test_refresh_impersonation_without_client_auth_error(self): request = self.make_mock_request( - status=http.client.OK, + status=http_client.OK, data=self.SUCCESS_RESPONSE, - impersonation_status=http.client.BAD_REQUEST, + impersonation_status=http_client.BAD_REQUEST, impersonation_data=self.IMPERSONATION_ERROR_RESPONSE, ) credentials = self.make_credentials( @@ -956,7 +956,7 @@ class TestCredentials(object): "subject_token_type": self.SUBJECT_TOKEN_TYPE, } request = self.make_mock_request( - status=http.client.OK, data=self.SUCCESS_RESPONSE + status=http_client.OK, data=self.SUCCESS_RESPONSE ) credentials = self.make_credentials( client_id=CLIENT_ID, client_secret=CLIENT_SECRET @@ -1006,9 +1006,9 @@ class TestCredentials(object): # Initialize mock request to handle token exchange and service account # impersonation request. request = self.make_mock_request( - status=http.client.OK, + status=http_client.OK, data=token_response, - impersonation_status=http.client.OK, + impersonation_status=http_client.OK, impersonation_data=impersonation_response, ) # Initialize credentials with service account impersonation and basic auth. @@ -1077,9 +1077,9 @@ class TestCredentials(object): # Initialize mock request to handle token exchange and service account # impersonation request. request = self.make_mock_request( - status=http.client.OK, + status=http_client.OK, data=token_response, - impersonation_status=http.client.OK, + impersonation_status=http_client.OK, impersonation_data=impersonation_response, ) # Initialize credentials with service account impersonation and basic auth. @@ -1114,7 +1114,7 @@ class TestCredentials(object): def test_apply_without_quota_project_id(self): headers = {} request = self.make_mock_request( - status=http.client.OK, data=self.SUCCESS_RESPONSE + status=http_client.OK, data=self.SUCCESS_RESPONSE ) credentials = self.make_credentials() @@ -1128,7 +1128,7 @@ class TestCredentials(object): def test_apply_workforce_without_quota_project_id(self): headers = {} request = self.make_mock_request( - status=http.client.OK, data=self.SUCCESS_RESPONSE + status=http_client.OK, data=self.SUCCESS_RESPONSE ) credentials = self.make_workforce_pool_credentials( workforce_pool_user_project=self.WORKFORCE_POOL_USER_PROJECT @@ -1153,9 +1153,9 @@ class TestCredentials(object): # Initialize mock request to handle token exchange and service account # impersonation request. request = self.make_mock_request( - status=http.client.OK, + status=http_client.OK, data=self.SUCCESS_RESPONSE.copy(), - impersonation_status=http.client.OK, + impersonation_status=http_client.OK, impersonation_data=impersonation_response, ) # Initialize credentials with service account impersonation. @@ -1175,7 +1175,7 @@ class TestCredentials(object): def test_apply_with_quota_project_id(self): headers = {"other": "header-value"} request = self.make_mock_request( - status=http.client.OK, data=self.SUCCESS_RESPONSE + status=http_client.OK, data=self.SUCCESS_RESPONSE ) credentials = self.make_credentials(quota_project_id=self.QUOTA_PROJECT_ID) @@ -1200,9 +1200,9 @@ class TestCredentials(object): # Initialize mock request to handle token exchange and service account # impersonation request. request = self.make_mock_request( - status=http.client.OK, + status=http_client.OK, data=self.SUCCESS_RESPONSE.copy(), - impersonation_status=http.client.OK, + impersonation_status=http_client.OK, impersonation_data=impersonation_response, ) # Initialize credentials with service account impersonation. @@ -1225,7 +1225,7 @@ class TestCredentials(object): def test_before_request(self): headers = {"other": "header-value"} request = self.make_mock_request( - status=http.client.OK, data=self.SUCCESS_RESPONSE + status=http_client.OK, data=self.SUCCESS_RESPONSE ) credentials = self.make_credentials() @@ -1248,7 +1248,7 @@ class TestCredentials(object): def test_before_request_workforce(self): headers = {"other": "header-value"} request = self.make_mock_request( - status=http.client.OK, data=self.SUCCESS_RESPONSE + status=http_client.OK, data=self.SUCCESS_RESPONSE ) credentials = self.make_workforce_pool_credentials( workforce_pool_user_project=self.WORKFORCE_POOL_USER_PROJECT @@ -1282,9 +1282,9 @@ class TestCredentials(object): # Initialize mock request to handle token exchange and service account # impersonation request. request = self.make_mock_request( - status=http.client.OK, + status=http_client.OK, data=self.SUCCESS_RESPONSE.copy(), - impersonation_status=http.client.OK, + impersonation_status=http_client.OK, impersonation_data=impersonation_response, ) headers = {"other": "header-value"} @@ -1312,7 +1312,7 @@ class TestCredentials(object): def test_before_request_expired(self, utcnow): headers = {} request = self.make_mock_request( - status=http.client.OK, data=self.SUCCESS_RESPONSE + status=http_client.OK, data=self.SUCCESS_RESPONSE ) credentials = self.make_credentials() credentials.token = "token" @@ -1360,9 +1360,9 @@ class TestCredentials(object): # Initialize mock request to handle token exchange and service account # impersonation request. request = self.make_mock_request( - status=http.client.OK, + status=http_client.OK, data=self.SUCCESS_RESPONSE.copy(), - impersonation_status=http.client.OK, + impersonation_status=http_client.OK, impersonation_data=impersonation_response, ) credentials = self.make_credentials( @@ -1491,11 +1491,11 @@ class TestCredentials(object): # Initialize mock request to handle token exchange, service account # impersonation and cloud resource manager request. request = self.make_mock_request( - status=http.client.OK, + status=http_client.OK, data=self.SUCCESS_RESPONSE.copy(), - impersonation_status=http.client.OK, + impersonation_status=http_client.OK, impersonation_data=impersonation_response, - cloud_resource_manager_status=http.client.OK, + cloud_resource_manager_status=http_client.OK, cloud_resource_manager_data=self.CLOUD_RESOURCE_MANAGER_SUCCESS_RESPONSE, ) credentials = self.make_credentials( @@ -1562,9 +1562,9 @@ class TestCredentials(object): # Initialize mock request to handle token exchange and cloud resource # manager request. request = self.make_mock_request( - status=http.client.OK, + status=http_client.OK, data=self.SUCCESS_RESPONSE.copy(), - cloud_resource_manager_status=http.client.OK, + cloud_resource_manager_status=http_client.OK, cloud_resource_manager_data=self.CLOUD_RESOURCE_MANAGER_SUCCESS_RESPONSE, ) credentials = self.make_workforce_pool_credentials( @@ -1611,9 +1611,9 @@ class TestCredentials(object): # Simulate resource doesn't have sufficient permissions to access # cloud resource manager. request = self.make_mock_request( - status=http.client.OK, + status=http_client.OK, data=self.SUCCESS_RESPONSE.copy(), - cloud_resource_manager_status=http.client.UNAUTHORIZED, + cloud_resource_manager_status=http_client.UNAUTHORIZED, ) credentials = self.make_credentials(scopes=self.SCOPES) |