Skip to content

Commit

Permalink
Fix for the auditor permissions tests.
Browse files Browse the repository at this point in the history
AWS SDK is not returning all the roles at once while calling
get-account-authorization-details, but is paginating the results. This
is a fix that iterates over all the pages of the response.

[#184632801] Add AssumeRole support to bosh-aws-cpi

Signed-off-by: Daniel Felipe Ochoa <danielfelipo@vmware.com>
  • Loading branch information
jpalermo authored and danielfor committed Apr 25, 2023
1 parent 72ed37e commit 868e754
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/bosh_aws_cpi/spec/integration/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ def validate_minimum_permissions(logger)
logger: logger
)

account_details = iam_client.get_account_authorization_details(filter: ['Role']).role_detail_list.find { |role|

##
# The following lines are a workaround for the fact that the AWS SDK does not return all the results at once.
role_list = []
iam_client.get_account_authorization_details(filter: ['Role']).each{ | response |
role_list += response.role_detail_list
}

account_details = role_list.find { |role|
role.arn == 'arn:aws:iam::' + integration_test_user.account + ':role/' + integration_test_user.arn.split('/')[1]
}

Expand All @@ -46,7 +54,7 @@ def validate_minimum_permissions(logger)
s['Action']
end.flatten.uniq

expect(actions).to include(*minimum_action)
expect(actions).to match_array(minimum_action)
end
end

Expand Down

0 comments on commit 868e754

Please sign in to comment.