2626from google .auth import transport
2727
2828
29- METRICS_HEADER_VALUE = "gl-python/3.7 auth/1.1 auth-request-type/at cred-type/imp"
29+ IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE = (
30+ "gl-python/3.7 auth/1.1 auth-request-type/at cred-type/imp"
31+ )
3032
3133CLIENT_ID = "username"
3234CLIENT_SECRET = "password"
@@ -755,7 +757,7 @@ def test_refresh_workforce_with_client_auth_and_no_workforce_project_success(
755757
756758 @mock .patch (
757759 "google.auth.metrics.token_request_access_token_impersonate" ,
758- return_value = METRICS_HEADER_VALUE ,
760+ return_value = IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE ,
759761 )
760762 def test_refresh_impersonation_without_client_auth_success (
761763 self , mock_metrics_header_value
@@ -784,7 +786,7 @@ def test_refresh_impersonation_without_client_auth_success(
784786 impersonation_headers = {
785787 "Content-Type" : "application/json" ,
786788 "authorization" : "Bearer {}" .format (token_response ["access_token" ]),
787- "x-goog-api-client" : METRICS_HEADER_VALUE ,
789+ "x-goog-api-client" : IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE ,
788790 }
789791 impersonation_request_data = {
790792 "delegates" : None ,
@@ -826,7 +828,7 @@ def test_refresh_impersonation_without_client_auth_success(
826828
827829 @mock .patch (
828830 "google.auth.metrics.token_request_access_token_impersonate" ,
829- return_value = METRICS_HEADER_VALUE ,
831+ return_value = IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE ,
830832 )
831833 def test_refresh_workforce_impersonation_without_client_auth_success (
832834 self , mock_metrics_header_value
@@ -858,7 +860,7 @@ def test_refresh_workforce_impersonation_without_client_auth_success(
858860 impersonation_headers = {
859861 "Content-Type" : "application/json" ,
860862 "authorization" : "Bearer {}" .format (token_response ["access_token" ]),
861- "x-goog-api-client" : METRICS_HEADER_VALUE ,
863+ "x-goog-api-client" : IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE ,
862864 }
863865 impersonation_request_data = {
864866 "delegates" : None ,
@@ -1018,7 +1020,7 @@ def test_refresh_with_client_auth_success(self):
10181020
10191021 @mock .patch (
10201022 "google.auth.metrics.token_request_access_token_impersonate" ,
1021- return_value = METRICS_HEADER_VALUE ,
1023+ return_value = IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE ,
10221024 )
10231025 def test_refresh_impersonation_with_client_auth_success_ignore_default_scopes (
10241026 self , mock_metrics_header_value
@@ -1050,7 +1052,7 @@ def test_refresh_impersonation_with_client_auth_success_ignore_default_scopes(
10501052 impersonation_headers = {
10511053 "Content-Type" : "application/json" ,
10521054 "authorization" : "Bearer {}" .format (token_response ["access_token" ]),
1053- "x-goog-api-client" : METRICS_HEADER_VALUE ,
1055+ "x-goog-api-client" : IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE ,
10541056 }
10551057 impersonation_request_data = {
10561058 "delegates" : None ,
@@ -1096,7 +1098,7 @@ def test_refresh_impersonation_with_client_auth_success_ignore_default_scopes(
10961098
10971099 @mock .patch (
10981100 "google.auth.metrics.token_request_access_token_impersonate" ,
1099- return_value = METRICS_HEADER_VALUE ,
1101+ return_value = IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE ,
11001102 )
11011103 def test_refresh_impersonation_with_client_auth_success_use_default_scopes (
11021104 self , mock_metrics_header_value
@@ -1128,7 +1130,7 @@ def test_refresh_impersonation_with_client_auth_success_use_default_scopes(
11281130 impersonation_headers = {
11291131 "Content-Type" : "application/json" ,
11301132 "authorization" : "Bearer {}" .format (token_response ["access_token" ]),
1131- "x-goog-api-client" : METRICS_HEADER_VALUE ,
1133+ "x-goog-api-client" : IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE ,
11321134 }
11331135 impersonation_request_data = {
11341136 "delegates" : None ,
@@ -1520,7 +1522,7 @@ def test_project_id_without_scopes(self):
15201522
15211523 @mock .patch (
15221524 "google.auth.metrics.token_request_access_token_impersonate" ,
1523- return_value = METRICS_HEADER_VALUE ,
1525+ return_value = IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE ,
15241526 )
15251527 def test_get_project_id_cloud_resource_manager_success (
15261528 self , mock_metrics_header_value
@@ -1549,7 +1551,7 @@ def test_get_project_id_cloud_resource_manager_success(
15491551 "Content-Type" : "application/json" ,
15501552 "x-goog-user-project" : self .QUOTA_PROJECT_ID ,
15511553 "authorization" : "Bearer {}" .format (token_response ["access_token" ]),
1552- "x-goog-api-client" : METRICS_HEADER_VALUE ,
1554+ "x-goog-api-client" : IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE ,
15531555 }
15541556 impersonation_request_data = {
15551557 "delegates" : None ,
@@ -1677,7 +1679,7 @@ def test_workforce_pool_get_project_id_cloud_resource_manager_success(self):
16771679
16781680 @mock .patch (
16791681 "google.auth.metrics.token_request_access_token_impersonate" ,
1680- return_value = METRICS_HEADER_VALUE ,
1682+ return_value = IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE ,
16811683 )
16821684 def test_refresh_impersonation_with_lifetime (self , mock_metrics_header_value ):
16831685 # Simulate service account access token expires in 2800 seconds.
@@ -1704,7 +1706,7 @@ def test_refresh_impersonation_with_lifetime(self, mock_metrics_header_value):
17041706 impersonation_headers = {
17051707 "Content-Type" : "application/json" ,
17061708 "authorization" : "Bearer {}" .format (token_response ["access_token" ]),
1707- "x-goog-api-client" : METRICS_HEADER_VALUE ,
1709+ "x-goog-api-client" : IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE ,
17081710 }
17091711 impersonation_request_data = {
17101712 "delegates" : None ,
0 commit comments