@@ -825,6 +825,7 @@ def test_refresh_impersonation_without_client_auth_success(
825825 "Content-Type" : "application/json" ,
826826 "authorization" : "Bearer {}" .format (token_response ["access_token" ]),
827827 "x-goog-api-client" : IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE ,
828+ "x-identity-trust-boundary" : "0" ,
828829 }
829830 impersonation_request_data = {
830831 "delegates" : None ,
@@ -906,6 +907,7 @@ def test_refresh_workforce_impersonation_without_client_auth_success(
906907 "Content-Type" : "application/json" ,
907908 "authorization" : "Bearer {}" .format (token_response ["access_token" ]),
908909 "x-goog-api-client" : IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE ,
910+ "x-identity-trust-boundary" : "0" ,
909911 }
910912 impersonation_request_data = {
911913 "delegates" : None ,
@@ -1124,6 +1126,7 @@ def test_refresh_impersonation_with_client_auth_success_ignore_default_scopes(
11241126 "Content-Type" : "application/json" ,
11251127 "authorization" : "Bearer {}" .format (token_response ["access_token" ]),
11261128 "x-goog-api-client" : IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE ,
1129+ "x-identity-trust-boundary" : "0" ,
11271130 }
11281131 impersonation_request_data = {
11291132 "delegates" : None ,
@@ -1207,6 +1210,7 @@ def test_refresh_impersonation_with_client_auth_success_use_default_scopes(
12071210 "Content-Type" : "application/json" ,
12081211 "authorization" : "Bearer {}" .format (token_response ["access_token" ]),
12091212 "x-goog-api-client" : IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE ,
1213+ "x-identity-trust-boundary" : "0" ,
12101214 }
12111215 impersonation_request_data = {
12121216 "delegates" : None ,
@@ -1261,7 +1265,8 @@ def test_apply_without_quota_project_id(self):
12611265 credentials .apply (headers )
12621266
12631267 assert headers == {
1264- "authorization" : "Bearer {}" .format (self .SUCCESS_RESPONSE ["access_token" ])
1268+ "authorization" : "Bearer {}" .format (self .SUCCESS_RESPONSE ["access_token" ]),
1269+ "x-identity-trust-boundary" : "0" ,
12651270 }
12661271
12671272 def test_apply_workforce_without_quota_project_id (self ):
@@ -1277,7 +1282,8 @@ def test_apply_workforce_without_quota_project_id(self):
12771282 credentials .apply (headers )
12781283
12791284 assert headers == {
1280- "authorization" : "Bearer {}" .format (self .SUCCESS_RESPONSE ["access_token" ])
1285+ "authorization" : "Bearer {}" .format (self .SUCCESS_RESPONSE ["access_token" ]),
1286+ "x-identity-trust-boundary" : "0" ,
12811287 }
12821288
12831289 def test_apply_impersonation_without_quota_project_id (self ):
@@ -1308,7 +1314,8 @@ def test_apply_impersonation_without_quota_project_id(self):
13081314 credentials .apply (headers )
13091315
13101316 assert headers == {
1311- "authorization" : "Bearer {}" .format (impersonation_response ["accessToken" ])
1317+ "authorization" : "Bearer {}" .format (impersonation_response ["accessToken" ]),
1318+ "x-identity-trust-boundary" : "0" ,
13121319 }
13131320
13141321 def test_apply_with_quota_project_id (self ):
@@ -1325,6 +1332,7 @@ def test_apply_with_quota_project_id(self):
13251332 "other" : "header-value" ,
13261333 "authorization" : "Bearer {}" .format (self .SUCCESS_RESPONSE ["access_token" ]),
13271334 "x-goog-user-project" : self .QUOTA_PROJECT_ID ,
1335+ "x-identity-trust-boundary" : "0" ,
13281336 }
13291337
13301338 def test_apply_impersonation_with_quota_project_id (self ):
@@ -1359,6 +1367,7 @@ def test_apply_impersonation_with_quota_project_id(self):
13591367 "other" : "header-value" ,
13601368 "authorization" : "Bearer {}" .format (impersonation_response ["accessToken" ]),
13611369 "x-goog-user-project" : self .QUOTA_PROJECT_ID ,
1370+ "x-identity-trust-boundary" : "0" ,
13621371 }
13631372
13641373 def test_before_request (self ):
@@ -1374,6 +1383,7 @@ def test_before_request(self):
13741383 assert headers == {
13751384 "other" : "header-value" ,
13761385 "authorization" : "Bearer {}" .format (self .SUCCESS_RESPONSE ["access_token" ]),
1386+ "x-identity-trust-boundary" : "0" ,
13771387 }
13781388
13791389 # Second call shouldn't call refresh.
@@ -1382,6 +1392,7 @@ def test_before_request(self):
13821392 assert headers == {
13831393 "other" : "header-value" ,
13841394 "authorization" : "Bearer {}" .format (self .SUCCESS_RESPONSE ["access_token" ]),
1395+ "x-identity-trust-boundary" : "0" ,
13851396 }
13861397
13871398 def test_before_request_workforce (self ):
@@ -1399,6 +1410,7 @@ def test_before_request_workforce(self):
13991410 assert headers == {
14001411 "other" : "header-value" ,
14011412 "authorization" : "Bearer {}" .format (self .SUCCESS_RESPONSE ["access_token" ]),
1413+ "x-identity-trust-boundary" : "0" ,
14021414 }
14031415
14041416 # Second call shouldn't call refresh.
@@ -1407,6 +1419,7 @@ def test_before_request_workforce(self):
14071419 assert headers == {
14081420 "other" : "header-value" ,
14091421 "authorization" : "Bearer {}" .format (self .SUCCESS_RESPONSE ["access_token" ]),
1422+ "x-identity-trust-boundary" : "0" ,
14101423 }
14111424
14121425 def test_before_request_impersonation (self ):
@@ -1437,6 +1450,7 @@ def test_before_request_impersonation(self):
14371450 assert headers == {
14381451 "other" : "header-value" ,
14391452 "authorization" : "Bearer {}" .format (impersonation_response ["accessToken" ]),
1453+ "x-identity-trust-boundary" : "0" ,
14401454 }
14411455
14421456 # Second call shouldn't call refresh.
@@ -1445,6 +1459,7 @@ def test_before_request_impersonation(self):
14451459 assert headers == {
14461460 "other" : "header-value" ,
14471461 "authorization" : "Bearer {}" .format (impersonation_response ["accessToken" ]),
1462+ "x-identity-trust-boundary" : "0" ,
14481463 }
14491464
14501465 @mock .patch ("google.auth._helpers.utcnow" )
@@ -1470,7 +1485,10 @@ def test_before_request_expired(self, utcnow):
14701485 credentials .before_request (request , "POST" , "https://example.com/api" , headers )
14711486
14721487 # Cached token should be used.
1473- assert headers == {"authorization" : "Bearer token" }
1488+ assert headers == {
1489+ "authorization" : "Bearer token" ,
1490+ "x-identity-trust-boundary" : "0" ,
1491+ }
14741492
14751493 # Next call should simulate 1 second passed.
14761494 utcnow .return_value = datetime .datetime .min + datetime .timedelta (seconds = 1 )
@@ -1482,7 +1500,8 @@ def test_before_request_expired(self, utcnow):
14821500
14831501 # New token should be retrieved.
14841502 assert headers == {
1485- "authorization" : "Bearer {}" .format (self .SUCCESS_RESPONSE ["access_token" ])
1503+ "authorization" : "Bearer {}" .format (self .SUCCESS_RESPONSE ["access_token" ]),
1504+ "x-identity-trust-boundary" : "0" ,
14861505 }
14871506
14881507 @mock .patch ("google.auth._helpers.utcnow" )
@@ -1523,7 +1542,10 @@ def test_before_request_impersonation_expired(self, utcnow):
15231542 credentials .before_request (request , "POST" , "https://example.com/api" , headers )
15241543
15251544 # Cached token should be used.
1526- assert headers == {"authorization" : "Bearer token" }
1545+ assert headers == {
1546+ "authorization" : "Bearer token" ,
1547+ "x-identity-trust-boundary" : "0" ,
1548+ }
15271549
15281550 # Next call should simulate 1 second passed. This will trigger the expiration
15291551 # threshold.
@@ -1536,7 +1558,8 @@ def test_before_request_impersonation_expired(self, utcnow):
15361558
15371559 # New token should be retrieved.
15381560 assert headers == {
1539- "authorization" : "Bearer {}" .format (impersonation_response ["accessToken" ])
1561+ "authorization" : "Bearer {}" .format (impersonation_response ["accessToken" ]),
1562+ "x-identity-trust-boundary" : "0" ,
15401563 }
15411564
15421565 @pytest .mark .parametrize (
@@ -1635,6 +1658,7 @@ def test_get_project_id_cloud_resource_manager_success(
16351658 "x-goog-user-project" : self .QUOTA_PROJECT_ID ,
16361659 "authorization" : "Bearer {}" .format (token_response ["access_token" ]),
16371660 "x-goog-api-client" : IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE ,
1661+ "x-identity-trust-boundary" : "0" ,
16381662 }
16391663 impersonation_request_data = {
16401664 "delegates" : None ,
@@ -1688,6 +1712,7 @@ def test_get_project_id_cloud_resource_manager_success(
16881712 "authorization" : "Bearer {}" .format (
16891713 impersonation_response ["accessToken" ]
16901714 ),
1715+ "x-identity-trust-boundary" : "0" ,
16911716 },
16921717 )
16931718
@@ -1759,6 +1784,7 @@ def test_workforce_pool_get_project_id_cloud_resource_manager_success(
17591784 "authorization" : "Bearer {}" .format (
17601785 self .SUCCESS_RESPONSE ["access_token" ]
17611786 ),
1787+ "x-identity-trust-boundary" : "0" ,
17621788 },
17631789 )
17641790
@@ -1808,6 +1834,7 @@ def test_refresh_impersonation_with_lifetime(
18081834 "Content-Type" : "application/json" ,
18091835 "authorization" : "Bearer {}" .format (token_response ["access_token" ]),
18101836 "x-goog-api-client" : IMPERSONATE_ACCESS_TOKEN_REQUEST_METRICS_HEADER_VALUE ,
1837+ "x-identity-trust-boundary" : "0" ,
18111838 }
18121839 impersonation_request_data = {
18131840 "delegates" : None ,
0 commit comments