From ab8a189bbf433ac2fbc8138f2c71f0a533da39e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bendeg=C3=BAz=20=C3=81cs?= <30595431+acsbendi@users.noreply.github.com> Date: Mon, 10 Jun 2019 21:00:37 +0200 Subject: [PATCH] Fixed policy version's Document type for AWS managed policies (#2234) * Added checking Document's type in AWS managed policy version response. * Fixed policy version's Document type for AWS managed policies. --- moto/iam/models.py | 2 +- tests/test_iam/test_iam.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/moto/iam/models.py b/moto/iam/models.py index 650a535c..86eec73f 100644 --- a/moto/iam/models.py +++ b/moto/iam/models.py @@ -131,7 +131,7 @@ class AWSManagedPolicy(ManagedPolicy): return cls(name, default_version_id=data.get('DefaultVersionId'), path=data.get('Path'), - document=data.get('Document'), + document=json.dumps(data.get('Document')), create_date=datetime.strptime(data.get('CreateDate'), "%Y-%m-%dT%H:%M:%S+00:00"), update_date=datetime.strptime(data.get('UpdateDate'), "%Y-%m-%dT%H:%M:%S+00:00")) diff --git a/tests/test_iam/test_iam.py b/tests/test_iam/test_iam.py index 6cc3d026..3e1c5914 100644 --- a/tests/test_iam/test_iam.py +++ b/tests/test_iam/test_iam.py @@ -369,6 +369,7 @@ def test_get_aws_managed_policy_version(): PolicyArn=managed_policy_arn, VersionId="v1") retrieved['PolicyVersion']['CreateDate'].replace(tzinfo=None).should.equal(managed_policy_version_create_date) + retrieved['PolicyVersion']['Document'].should.be.an(dict) @mock_iam @@ -384,6 +385,7 @@ def test_get_aws_managed_policy_v4_version(): PolicyArn=managed_policy_arn, VersionId="v4") retrieved['PolicyVersion']['CreateDate'].replace(tzinfo=None).should.equal(managed_policy_version_create_date) + retrieved['PolicyVersion']['Document'].should.be.an(dict) @mock_iam