This repository has been archived by the owner on Dec 4, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 301
/
test-scout2.py
79 lines (65 loc) · 2.41 KB
/
test-scout2.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
import mock
import subprocess
from AWSScout2.__main__ import *
from opinel.utils.console import configPrintException
from opinel.utils.credentials import read_creds_from_environment_variables
#
# Test for Scout2.py
#
class TestScout2Class:
@classmethod
def setUpClass(cls):
configPrintException(True)
creds = read_creds_from_environment_variables()
cls.profile_name = 'travislike' if creds['AccessKeyId'] == None else None
cls.has_run_scout2 = False
def call_scout2(self, args):
args = ['./Scout2.py' ] + args
if TestScout2Class.profile_name:
args.append('--profile')
args.append(TestScout2Class.profile_name)
args.append('--force')
args.append('--debug')
args.append('--no-browser')
if TestScout2Class.has_run_scout2:
args.append('--local')
TestScout2Class.has_run_scout2 = True
with mock.patch.object(sys, 'argv', args):
return main()
#
# Make sure that Scout2 does not crash with --help
#
def test_scout2_help(self):
command = './Scout2.py --help'
process = subprocess.Popen(command, shell=True, stdout=None)
process.wait()
assert process.returncode == 0
#
# Make sure that Scout2's default run does not crash
#
def test_scout2_default_run(self):
rc = self.call_scout2([])
assert (rc == 0)
#
# Make sure that Scout2's CIS ruleset run does not crash
#
def test_scout2_cis_ruleset_run(self):
rc = self.call_scout2(['--ruleset', 'cis-02-29-2016.json'])
assert (rc == 0)
# #
# # Make sure that Scout2's check-s3-acl option does not crash
# #
# def test_scout2_default_run(self):
# command = './Scout2.py --force --services s3 --check-s3-acls --bucket-name misconfigured-bucket-objectacls-mismatch'
# process = subprocess.Popen(command, shell=True, stdout=None) #subprocess.PIPE)
# process.wait()
# assert process.returncode == 0
#
# #
# # Make sure that Scout2's check-s3-encryption option does not crash
# #
# def test_scout2_default_run(self):
# command = './Scout2.py --force --services s3 --check-s3-encryption --bucket-name misconfigured-bucket-unencrypted-objects'
# process = subprocess.Popen(command, shell=True, stdout=None) #subprocess.PIPE)
# process.wait()
# assert process.returncode == 0