forked from cloud-custodian/cloud-custodian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_health.py
46 lines (41 loc) · 1.57 KB
/
test_health.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
# Copyright The Cloud Custodian Authors.
# SPDX-License-Identifier: Apache-2.0
from .common import BaseTest
class HealthResource(BaseTest):
def test_health_query(self):
session_factory = self.replay_flight_data("test_health_query")
p = self.load_policy(
{"name": "account-health-query", "resource": "health-event"},
session_factory=session_factory,
)
resources = p.run()
self.assertEqual(len(resources), 0)
def test_health_resource_query(self):
session_factory = self.replay_flight_data("test_health_resource_query")
p = self.load_policy(
{
"name": "account-health-ec2-query",
"resource": "health-event",
"query": [{"services": "EC2"}],
},
session_factory=session_factory,
)
resources = p.run()
self.assertEqual(len(resources), 1)
self.assertEqual(resources[0]["service"], "EC2")
def test_health_augment(self):
session_factory = self.replay_flight_data("test_health_augment")
p = self.load_policy(
{
"name": "account-health-augment",
"resource": "health-event",
"query": [{"services": ["BILLING", "IAM"]}],
},
session_factory=session_factory,
)
resources = p.run()
for r in resources:
self.assertTrue("Description" in r)
self.assertTrue(
(r["eventTypeCategory"] == "accountNotification") ^ ("AffectedEntities" in r)
)