forked from cloud-custodian/cloud-custodian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_swf.py
84 lines (76 loc) · 2.83 KB
/
test_swf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Copyright The Cloud Custodian Authors.
# SPDX-License-Identifier: Apache-2.0
from .common import BaseTest
class TestSimpleWorkflow(BaseTest):
def test_swf_domain_value_filter(self):
session_factory = self.replay_flight_data('test_swf_domain_value_filter')
p = self.load_policy(
{
"name": "test-swf-domain-value-filter",
"resource": "swf-domain",
"filters": [
{
"type": "value",
"key": "name",
"op": "eq",
"value": "test-custodian-swf-domain",
}
]
},
session_factory=session_factory,
)
resources = p.run()
self.assertEqual(len(resources), 1)
self.assertEqual(resources[0]['name'], 'test-custodian-swf-domain')
self.assertEqual(resources[0]['c7n:MatchedFilters'], ['name'])
def test_swf_domain_tag(self):
session_factory = self.replay_flight_data('test_swf_domain_tag')
client = session_factory().client("swf")
p = self.load_policy(
{
"name": "test-swf-domain-tag",
"resource": "swf-domain",
"actions": [{
"type": "tag",
"key": "TestKey",
"value": "TestValue"
}]
},
session_factory=session_factory,
)
resources = p.run()
tags = client.list_tags_for_resource(resourceArn=resources[0]["arn"])["tags"]
self.assertEqual(tags[0]["key"], "TestKey")
p = self.load_policy(
{
"name": "test-swf-domain-untag",
"resource": "swf-domain",
"actions": [{
"type": "remove-tag",
"tags": ["TestKey"]
}]
},
session_factory=session_factory,
)
resources = p.run()
tags = client.list_tags_for_resource(resourceArn=resources[0]["arn"])["tags"]
self.assertEqual(len(tags), 0)
def test_swf_domain_config(self):
session_factory = self.replay_flight_data('test_swf_domain_config')
p = self.load_policy(
{
"name": "test-swf-domain-config",
"resource": "swf-domain",
"filters": [{
"type": "configuration",
"key": "workflowExecutionRetentionPeriodInDays",
"op": "gt",
"value": 45
}]
},
session_factory=session_factory,
)
resources = p.run()
self.assertEqual(len(resources), 1)
self.assertEqual(resources[0]["c7n:configuration"][
"workflowExecutionRetentionPeriodInDays"], 90)