IAM: list_groups() now returns the CreateDate-attribute (#6854)
This commit is contained in:
parent
9a84423187
commit
fecde6c001
@ -1761,6 +1761,7 @@ LIST_GROUPS_TEMPLATE = """<ListGroupsResponse>
|
|||||||
<GroupName>{{ group.name }}</GroupName>
|
<GroupName>{{ group.name }}</GroupName>
|
||||||
<GroupId>{{ group.id }}</GroupId>
|
<GroupId>{{ group.id }}</GroupId>
|
||||||
<Arn>{{ group.arn }}</Arn>
|
<Arn>{{ group.arn }}</Arn>
|
||||||
|
<CreateDate>{{ group.created_iso_8601 }}</CreateDate>
|
||||||
</member>
|
</member>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</Groups>
|
</Groups>
|
||||||
|
@ -4594,36 +4594,30 @@ def test_list_roles_none_found_returns_empty_list():
|
|||||||
assert len(roles) == 0
|
assert len(roles) == 0
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("desc", ["", "Test Description"])
|
|
||||||
@mock_iam()
|
@mock_iam()
|
||||||
def test_list_roles_with_description(desc):
|
def test_list_roles():
|
||||||
conn = boto3.client("iam", region_name="us-east-1")
|
conn = boto3.client("iam", region_name="us-east-1")
|
||||||
resp = conn.create_role(
|
for desc in ["", "desc"]:
|
||||||
RoleName="my-role", AssumeRolePolicyDocument="some policy", Description=desc
|
resp = conn.create_role(
|
||||||
)
|
RoleName=f"role_{desc}",
|
||||||
assert resp["Role"]["Description"] == desc
|
AssumeRolePolicyDocument="some policy",
|
||||||
|
Description=desc,
|
||||||
|
)
|
||||||
|
assert resp["Role"]["Description"] == desc
|
||||||
|
conn.create_role(RoleName="role3", AssumeRolePolicyDocument="sp")
|
||||||
|
|
||||||
# Ensure the Description is included in role listing as well
|
# Ensure the Description is included in role listing as well
|
||||||
assert conn.list_roles()["Roles"][0]["Description"] == desc
|
all_roles = conn.list_roles()["Roles"]
|
||||||
|
|
||||||
|
role1 = next(r for r in all_roles if r["RoleName"] == "role_")
|
||||||
|
role2 = next(r for r in all_roles if r["RoleName"] == "role_desc")
|
||||||
|
role3 = next(r for r in all_roles if r["RoleName"] == "role3")
|
||||||
|
assert role1["Description"] == ""
|
||||||
|
assert role2["Description"] == "desc"
|
||||||
|
assert "Description" not in role3
|
||||||
|
|
||||||
@mock_iam()
|
assert all([role["CreateDate"] for role in all_roles])
|
||||||
def test_list_roles_without_description():
|
assert all([role["MaxSessionDuration"] for role in all_roles])
|
||||||
conn = boto3.client("iam", region_name="us-east-1")
|
|
||||||
resp = conn.create_role(RoleName="my-role", AssumeRolePolicyDocument="some policy")
|
|
||||||
assert "Description" not in resp["Role"]
|
|
||||||
|
|
||||||
# Ensure the Description is not included in role listing as well
|
|
||||||
assert "Description" not in conn.list_roles()["Roles"][0]
|
|
||||||
|
|
||||||
|
|
||||||
@mock_iam()
|
|
||||||
def test_list_roles_includes_max_session_duration():
|
|
||||||
conn = boto3.client("iam", region_name="us-east-1")
|
|
||||||
conn.create_role(RoleName="my-role", AssumeRolePolicyDocument="some policy")
|
|
||||||
|
|
||||||
# Ensure the MaxSessionDuration is included in the role listing
|
|
||||||
assert "MaxSessionDuration" in conn.list_roles()["Roles"][0]
|
|
||||||
|
|
||||||
|
|
||||||
@mock_iam()
|
@mock_iam()
|
||||||
|
@ -86,6 +86,8 @@ def test_get_all_groups():
|
|||||||
groups = conn.list_groups()["Groups"]
|
groups = conn.list_groups()["Groups"]
|
||||||
assert len(groups) == 2
|
assert len(groups) == 2
|
||||||
|
|
||||||
|
assert all([g["CreateDate"] for g in groups])
|
||||||
|
|
||||||
|
|
||||||
@mock_iam
|
@mock_iam
|
||||||
def test_add_unknown_user_to_group():
|
def test_add_unknown_user_to_group():
|
||||||
|
Loading…
Reference in New Issue
Block a user