|
1 | 1 | import unittest |
2 | 2 |
|
3 | 3 | from troposphere import Retain |
4 | | -from troposphere.logs import Destination, LogGroup, validate_resource_policy, LogResourcePolicy |
| 4 | +from troposphere.logs import ( |
| 5 | + Destination, |
| 6 | + LogGroup, |
| 7 | + ResourcePolicy, |
| 8 | + validate_resource_policy, |
| 9 | +) |
5 | 10 |
|
6 | 11 |
|
7 | 12 | class TestLogs(unittest.TestCase): |
@@ -36,18 +41,30 @@ def test_log_destination(self): |
36 | 41 | self.assertIn("Properties", log_destination_json) |
37 | 42 |
|
38 | 43 | def test_validate_resource_policy(self): |
39 | | - for s in ["{ \"Version\": \"2012-10-17\", \"Statement\": [ { \"Sid\": \"Route53LogsToCloudWatchLogs\", \"Effect\": \"Allow\", \"Principal\": { \"Service\": [ \"route53.amazonaws.com\" ] }, \"Action\":\"logs:PutLogEvents\", \"Resource\": \"logArn\" } ] }", {'Version': '2012-10-17', 'Statement': [{'Sid': 'Route53LogsToCloudWatchLogs', 'Effect': 'Allow', 'Principal': {'Service': ['route53.amazonaws.com']}, 'Action': 'logs:PutLogEvents', 'Resource': 'logArn'}]}]: |
| 44 | + for s in [ |
| 45 | + '{ "Version": "2012-10-17", "Statement": [ { "Sid": "Route53LogsToCloudWatchLogs", "Effect": "Allow", "Principal": { "Service": [ "route53.amazonaws.com" ] }, "Action":"logs:PutLogEvents", "Resource": "logArn" } ] }', |
| 46 | + { |
| 47 | + "Version": "2012-10-17", |
| 48 | + "Statement": [ |
| 49 | + { |
| 50 | + "Sid": "Route53LogsToCloudWatchLogs", |
| 51 | + "Effect": "Allow", |
| 52 | + "Principal": {"Service": ["route53.amazonaws.com"]}, |
| 53 | + "Action": "logs:PutLogEvents", |
| 54 | + "Resource": "logArn", |
| 55 | + } |
| 56 | + ], |
| 57 | + }, |
| 58 | + ]: |
40 | 59 | validate_resource_policy(s) |
41 | | - log_policy = LogResourcePolicy( |
42 | | - "TestLogPolicy", |
43 | | - PolicyName='TestLogPolicy', |
44 | | - PolicyDocument=s |
| 60 | + log_policy = ResourcePolicy( |
| 61 | + "TestLogPolicy", PolicyName="TestLogPolicy", PolicyDocument=s |
45 | 62 | ) |
46 | 63 | expected = log_policy.to_dict() |
47 | | - properties = expected['Properties'] |
48 | | - self.assertEqual(properties.get('PolicyDocument'), s) |
| 64 | + properties = expected["Properties"] |
| 65 | + self.assertEqual(properties.get("PolicyDocument"), s) |
49 | 66 |
|
50 | | - for s in ["", "H"*5121, "TEXT", {}]: |
| 67 | + for s in ["", "H" * 5121, "TEXT", {}]: |
51 | 68 | with self.assertRaises(ValueError): |
52 | 69 | validate_resource_policy(s) |
53 | 70 |
|
|
0 commit comments