Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
0xdabbad00 committed Sep 6, 2022
1 parent 1d7b436 commit ba58b69
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions tests/unit/test_action_expansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,36 @@ class TestActionExpansion:

def test_expand_action_no_expansion(self):
expanded_actions = expand_action("s3:listallmybuckets")
assert (
len(expanded_actions),
len([{"service": "s3", "action": "ListAllMyBuckets"}]),
assert len(expanded_actions) == len(
[{"service": "s3", "action": "ListAllMyBuckets"}]
)

def test_expand_action_with_expansion(self):
expanded_actions = expand_action("s3:listallmybucke*")
assert (
len(expanded_actions),
len([{"service": "s3", "action": "ListAllMyBuckets"}]),
assert len(expanded_actions) == len(
[{"service": "s3", "action": "ListAllMyBuckets"}]
)

def test_expand_action_with_casing(self):
expanded_actions = expand_action("iAm:li*sTuS*rs")
assert (len(expanded_actions), len([{"service": "iam", "action": "ListUsers"}]))
assert len(expanded_actions) == len([{"service": "iam", "action": "ListUsers"}])

def test_expand_action_with_expansion_for_prefix_used_multiple_times(self):
expanded_actions = expand_action("ses:Describe*")
assert (
len(expanded_actions),
len(
[
{"service": "ses", "action": "DescribeActiveReceiptRuleSet"},
{"service": "ses", "action": "DescribeConfigurationSet"},
{"service": "ses", "action": "DescribeReceiptRule"},
{"service": "ses", "action": "DescribeReceiptRuleSet"},
]
),
assert len(expanded_actions) == len(
[
{"service": "ses", "action": "DescribeActiveReceiptRuleSet"},
{"service": "ses", "action": "DescribeConfigurationSet"},
{"service": "ses", "action": "DescribeReceiptRule"},
{"service": "ses", "action": "DescribeReceiptRuleSet"},
]
)

def test_expand_action_with_permission_only_action(self):
# There are 17 privileges list as "logs.CreateLogDelivery [permission only]"
expanded_actions = expand_action("logs:GetLogDelivery")
assert (
len(expanded_actions),
len([{"service": "logs", "action": "GetLogDelivery"}]),
assert len(expanded_actions) == len(
[{"service": "logs", "action": "GetLogDelivery"}]
)

def test_exception_malformed(self):
Expand Down

0 comments on commit ba58b69

Please sign in to comment.