Fixes for IAM Role Description field in responses from list_roles and create_roles (#3724)

* Add IAM Role Description field to list_roles responses

The IAM ListRoles IAM API call will return the Description key/value
for each role if it exists.  If it does not exist the Description
key is not included.

* fix handling in create_role resp

* blackg

* Combine two tests using pytest.mark.parametrize

* consistency
This commit is contained in:
Jon Michaelchuck 2021-02-24 11:14:11 -08:00 committed by GitHub
commit 0625bbfa11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View file

@ -4029,6 +4029,29 @@ def test_list_roles_none_found_returns_empty_list():
assert len(roles) == 0
@pytest.mark.parametrize("desc", ["", "Test Description"])
@mock_iam()
def test_list_roles_with_description(desc):
conn = boto3.client("iam", region_name="us-east-1")
resp = conn.create_role(
RoleName="my-role", AssumeRolePolicyDocument="some policy", Description=desc,
)
resp.get("Role").get("Description").should.equal(desc)
# Ensure the Description is included in role listing as well
conn.list_roles().get("Roles")[0].get("Description").should.equal(desc)
@mock_iam()
def test_list_roles_without_description():
conn = boto3.client("iam", region_name="us-east-1")
resp = conn.create_role(RoleName="my-role", AssumeRolePolicyDocument="some policy",)
resp.get("Role").should_not.have.key("Description")
# Ensure the Description is not included in role listing as well
conn.list_roles().get("Roles")[0].should_not.have.key("Description")
@mock_iam()
def test_create_user_with_tags():
conn = boto3.client("iam", region_name="us-east-1")