def test_matches_policy_docs_unordered(self): lhs = '''{ "Version": "2012-10-17", "Statement": [ { "Sid": "Stmt1462317982000", "Effect": "Allow", "Action": [ "s3:AbortMultipartUpload", "s3:DeleteObject", "s3:GetObject", "s3:GetObjectAcl", "s3:PutObject", "s3:PutObjectAcl" ], "Resource": [ "arn:aws:s3:::thousandleaves-web/*" ] } ] }''' rhs = '''{ "Statement": [ { "Resource": [ "arn:aws:s3:::thousandleaves-web/*" ], "Sid": "Stmt1462317982000", "Effect": "Allow", "Action": [ "s3:DeleteObject", "s3:GetObject", "s3:PutObject", "s3:AbortMultipartUpload", "s3:PutObjectAcl", "s3:GetObjectAcl" ] } ], "Version": "2012-10-17" }''' self.assertTrue(matches_aws_policy_doc(lhs, rhs))
def test_matches_policy_docs_simple(self): gen = '''{"Version": "2012-10-17", "Statement": [{"Action": "sts:AssumeRole", "Effect": "Allow", "Principal": {"AWS": "arn:aws:iam::012345678901:user/biggles"}}]}''' aws = {'Version': '2012-10-17', 'Statement': [{'Action': 'sts:AssumeRole', 'Effect': 'Allow', 'Principal': {'AWS': 'arn:aws:iam::012345678901:user/biggles'}}]} self.assertTrue(matches_aws_policy_doc(aws, gen))
def test_matches_policy_docs_unicode(self): gen = '''{"Version": "2012-10-17", "Statement": [{"Action": "sts:AssumeRole", "Effect": "Allow", "Principal": {"AWS": "arn:aws:iam::012345678901:user/biggles"}}]}''' aws = {u'Version': u'2012-10-17', u'Statement': [{u'Action': u'sts:AssumeRole', u'Effect': u'Allow', u'Principal': {u'AWS': u'arn:aws:iam::012345678901:user/biggles'}}]} self.assertTrue(matches_aws_policy_doc(gen, aws))