diff --git a/moto/iam/models.py b/moto/iam/models.py index c7142fb5d..0f11022ee 100644 --- a/moto/iam/models.py +++ b/moto/iam/models.py @@ -177,7 +177,7 @@ class AccessKey(BaseModel): self.status = 'Active' self.create_date = datetime.strftime( datetime.utcnow(), - "%Y-%m-%d-%H-%M-%S" + "%Y-%m-%dT%H:%M:%SZ" ) def get_cfn_attribute(self, attribute_name): diff --git a/moto/iam/responses.py b/moto/iam/responses.py index 64f4e3297..db94c158d 100644 --- a/moto/iam/responses.py +++ b/moto/iam/responses.py @@ -901,6 +901,7 @@ LIST_ACCESS_KEYS_TEMPLATE = """ {{ user_name }} {{ key.access_key_id }} {{ key.status }} + {{ key.create_date }} {% endfor %} diff --git a/tests/test_iam/test_iam.py b/tests/test_iam/test_iam.py index e039f8f61..798c516a6 100644 --- a/tests/test_iam/test_iam.py +++ b/tests/test_iam/test_iam.py @@ -299,6 +299,8 @@ def test_create_access_key(): @mock_iam_deprecated() def test_get_all_access_keys(): + """If no access keys exist there should be none in the response, + if an access key is present it should have the correct fields present""" conn = boto.connect_iam() conn.create_user('my-user') response = conn.get_all_access_keys('my-user') @@ -309,10 +311,10 @@ def test_get_all_access_keys(): ) conn.create_access_key('my-user') response = conn.get_all_access_keys('my-user') - assert_not_equals( - response['list_access_keys_response'][ - 'list_access_keys_result']['access_key_metadata'], - [] + assert_equals( + sorted(response['list_access_keys_response'][ + 'list_access_keys_result']['access_key_metadata'][0].keys()), + sorted(['status', 'create_date', 'user_name', 'access_key_id']) )