Skip to content

Commit

Permalink
Fix path problem
Browse files Browse the repository at this point in the history
  • Loading branch information
JJmako committed Jan 14, 2020
1 parent 4ded2d5 commit 21b45f1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/test-utils-conditions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import os

from ScoutSuite.core.conditions import *

Expand Down Expand Up @@ -158,7 +159,10 @@ def test_pass_condition(self):
assert pass_condition('192.168.1.1', 'inSubnets', ['192.168.0.0/24']) == False
assert pass_condition('192.168.1.1', 'notInSubnets', ['192.168.0.0/24']) == True

with open('./data/policy1.json', 'rt') as f:
src_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data')
src_file = os.path.join(src_dir, 'policy1.json')

with open(src_file) as f:
testpolicy = json.load(f)
assert pass_condition(testpolicy['Statement'][0], 'containAction', 'iam:GetUser') == True
assert pass_condition(testpolicy['Statement'][0], 'containAction', 'iam:CreateUser') == False
Expand All @@ -169,7 +173,9 @@ def test_pass_condition(self):
assert pass_condition(testpolicy['Statement'][0], 'containAtLeastOneAction', '') == False
assert pass_condition(testpolicy['Statement'][0], 'containAtLeastOneAction', 'iam:GetUser') == True
assert pass_condition(testpolicy['Statement'][0], 'containAtLeastOneAction', ['iam:CreateUser', 'iam:GetUser']) == True
with open('./data/statement1.json', 'rt') as f:

src_file = os.path.join(src_dir, 'statement1.json')
with open(src_file) as f:
stringstatement = f.read()
assert pass_condition(stringstatement, 'containAction', 'iam:GetUser') == True
assert pass_condition(stringstatement, 'containAtLeastOneAction', 'iam:GetUser') == True
Expand Down

0 comments on commit 21b45f1

Please sign in to comment.