@@ -328,8 +328,9 @@ def test_get_workload_access_token_with_user_token(self):
328
328
329
329
with patch ("boto3.client" ) as mock_boto_client :
330
330
mock_cp_client = Mock ()
331
+ mock_identity_client = Mock ()
331
332
mock_dp_client = Mock ()
332
- mock_boto_client .side_effect = [mock_cp_client , mock_dp_client ]
333
+ mock_boto_client .side_effect = [mock_cp_client , mock_identity_client , mock_dp_client ]
333
334
334
335
identity_client = IdentityClient (region )
335
336
@@ -357,8 +358,9 @@ def test_get_workload_access_token_with_user_id(self):
357
358
358
359
with patch ("boto3.client" ) as mock_boto_client :
359
360
mock_cp_client = Mock ()
361
+ mock_identity_client = Mock ()
360
362
mock_dp_client = Mock ()
361
- mock_boto_client .side_effect = [mock_cp_client , mock_dp_client ]
363
+ mock_boto_client .side_effect = [mock_cp_client , mock_identity_client , mock_dp_client ]
362
364
363
365
identity_client = IdentityClient (region )
364
366
@@ -385,8 +387,9 @@ def test_get_workload_access_token_without_user_info(self):
385
387
386
388
with patch ("boto3.client" ) as mock_boto_client :
387
389
mock_cp_client = Mock ()
390
+ mock_identity_client = Mock ()
388
391
mock_dp_client = Mock ()
389
- mock_boto_client .side_effect = [mock_cp_client , mock_dp_client ]
392
+ mock_boto_client .side_effect = [mock_cp_client , mock_identity_client , mock_dp_client ]
390
393
391
394
identity_client = IdentityClient (region )
392
395
@@ -410,33 +413,34 @@ def test_create_workload_identity(self):
410
413
411
414
with patch ("boto3.client" ) as mock_boto_client :
412
415
mock_cp_client = Mock ()
416
+ mock_identity_client = Mock ()
413
417
mock_dp_client = Mock ()
414
- mock_boto_client .side_effect = [mock_cp_client , mock_dp_client ]
418
+ mock_boto_client .side_effect = [mock_cp_client , mock_identity_client , mock_dp_client ]
415
419
416
420
identity_client = IdentityClient (region )
417
421
418
422
# Test with provided name
419
423
custom_name = "my-custom-workload"
420
424
expected_response = {"name" : custom_name , "workloadIdentityId" : "workload-123" }
421
- mock_cp_client .create_workload_identity .return_value = expected_response
425
+ mock_identity_client .create_workload_identity .return_value = expected_response
422
426
423
427
result = identity_client .create_workload_identity (name = custom_name )
424
428
425
429
assert result == expected_response
426
- mock_cp_client .create_workload_identity .assert_called_with (name = custom_name )
430
+ mock_identity_client .create_workload_identity .assert_called_with (name = custom_name )
427
431
428
432
# Test without provided name (auto-generated)
429
- mock_cp_client .reset_mock ()
433
+ mock_identity_client .reset_mock ()
430
434
expected_response_auto = {"name" : "workload-abcd1234" , "workloadIdentityId" : "workload-456" }
431
- mock_cp_client .create_workload_identity .return_value = expected_response_auto
435
+ mock_identity_client .create_workload_identity .return_value = expected_response_auto
432
436
433
437
with patch ("uuid.uuid4" ) as mock_uuid :
434
438
mock_uuid .return_value .hex = "abcd1234efgh5678"
435
439
436
440
result = identity_client .create_workload_identity ()
437
441
438
442
assert result == expected_response_auto
439
- mock_cp_client .create_workload_identity .assert_called_with (name = "workload-abcd1234" )
443
+ mock_identity_client .create_workload_identity .assert_called_with (name = "workload-abcd1234" )
440
444
441
445
442
446
class TestDefaultApiTokenPoller :
0 commit comments