forked from cloud-custodian/cloud-custodian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_accessanalyzer.py
60 lines (53 loc) · 1.98 KB
/
test_accessanalyzer.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
# Copyright The Cloud Custodian Authors.
# SPDX-License-Identifier: Apache-2.0
from .common import BaseTest
class AccessanalyzerFindingTest(BaseTest):
""" IAM Access Analyzer Tests"""
def test_access_analyzer_finding(self):
"""
Test IAM AA Finding resource with Generic Value filter
"""
session_factory = self.replay_flight_data('test_access_analyzer_finding')
policy = {
'name': 'list-access-analyzer-findings',
'resource': 'aws.access-analyzer-finding',
'filters': [{'type': 'value',
'key': 'status',
'value': 'ACTIVE'}]
}
policy = self.load_policy(
policy,
session_factory=session_factory
)
resources = policy.run()
self.assertEqual(len(resources), 2)
def test_access_analyzer_finding_no_analyzer(self):
"""
Test IAM AA Finding resource when there is no active analyzer configured in the account
"""
session_factory = self.replay_flight_data('test_access_analyzer_finding_no_analyzer')
policy = {
'name': 'list-access-analyzer-findings',
'resource': 'aws.access-analyzer-finding'
}
policy = self.load_policy(
policy,
session_factory=session_factory
)
resources = policy.run()
self.assertEqual(len(resources), 0)
def test_access_analyzer_finding_org_analyzer(self):
"""
Test IAM AA Finding resource when there is Org analyzer configured in the account
"""
session_factory = self.replay_flight_data('test_access_analyzer_finding_org_analyzer')
policy = {
'name': 'list-access-analyzer-findings',
'resource': 'aws.access-analyzer-finding'
}
policy = self.load_policy(
policy,
session_factory=session_factory
)
resources = policy.run()
self.assertEqual(len(resources), 4)