From ce7b5ebf54021f64cf855f17f60a77f4b09262ce Mon Sep 17 00:00:00 2001 From: William Rubel Date: Sun, 17 Feb 2019 21:37:33 -0600 Subject: [PATCH] Fix policy date --- file.tmp | 9 +++++++++ moto/iam/models.py | 5 +++++ moto/iam/responses.py | 12 ++++++++++-- tests/test_iam/test_iam.py | 2 +- 4 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 file.tmp diff --git a/file.tmp b/file.tmp new file mode 100644 index 000000000..80053c647 --- /dev/null +++ b/file.tmp @@ -0,0 +1,9 @@ + + AWSTemplateFormatVersion: '2010-09-09' + Description: Simple CloudFormation Test Template + Resources: + S3Bucket: + Type: AWS::S3::Bucket + Properties: + AccessControl: PublicRead + BucketName: cf-test-bucket-1 diff --git a/moto/iam/models.py b/moto/iam/models.py index f71ad5352..80c7da29a 100644 --- a/moto/iam/models.py +++ b/moto/iam/models.py @@ -479,6 +479,11 @@ class IAMBackend(BaseBackend): role.description = role_description return role + def update_role(self, role_name, role_description): + role = self.get_role(role_name) + role.description = role_description + return role + def detach_role_policy(self, policy_arn, role_name): arns = dict((p.arn, p) for p in self.managed_policies.values()) try: diff --git a/moto/iam/responses.py b/moto/iam/responses.py index 7ee4b6345..26781ab6f 100644 --- a/moto/iam/responses.py +++ b/moto/iam/responses.py @@ -183,8 +183,8 @@ class IamResponse(BaseResponse): def update_role(self): role_name = self._get_param('RoleName') description = self._get_param('Description') - role = iam_backend.update_role_description(role_name, description) - template = self.response_template(UPDATE_ROLE_DESCRIPTION_TEMPLATE) + role = iam_backend.update_role(role_name, description) + template = self.response_template(UPDATE_ROLE_TEMPLATE) return template.render(role=role) def create_policy_version(self): @@ -944,6 +944,14 @@ GET_ROLE_POLICY_TEMPLATE = """ + + + + df37e965-9967-11e1-a4c3-270EXAMPLE04 + +""" + UPDATE_ROLE_DESCRIPTION_TEMPLATE = """ diff --git a/tests/test_iam/test_iam.py b/tests/test_iam/test_iam.py index 1114f72de..77ba17a5a 100644 --- a/tests/test_iam/test_iam.py +++ b/tests/test_iam/test_iam.py @@ -1185,7 +1185,7 @@ def test_update_role(): conn.create_role(RoleName="my-role", AssumeRolePolicyDocument="some policy", Path="/my-path/") response = conn.update_role(RoleName="my-role", Description="test") - assert response['Role']['RoleName'] == 'my-role' + assert len(response.keys()) == 1 @mock_iam() def test_list_entities_for_policy():