forked from nccgroup/ScoutSuite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_scoutsuite.py
executable file
·51 lines (40 loc) · 1.52 KB
/
test_scoutsuite.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
import subprocess
import unittest
from unittest import mock
import pytest
from ScoutSuite.__main__ import run_from_cli
from ScoutSuite.core.console import set_logger_configuration
class TestScoutSuiteClass(unittest.TestCase):
@classmethod
def setUpClass(cls):
set_logger_configuration(is_debug=True)
cls.has_run_scout_suite = False
@pytest.mark.xfail("only runs with AWS, cannot be used dynamically")
@staticmethod
def call_scout_suite(args):
args = ['./scout.py'] + args
args.append('aws')
if TestScoutSuiteClass.profile_name:
args.append('--profile')
args.append(TestScoutSuiteClass.profile_name)
# TODO: FIXME this only tests AWS
args.append('--force')
args.append('--debug')
args.append('--no-browser')
if TestScoutSuiteClass.has_run_scout_suite:
args.append('--local')
TestScoutSuiteClass.has_run_scout_suite = True
sys = None
with mock.patch.object(sys, 'argv', args):
return run_from_cli()
def test_scout_suite_help(self):
"""Make sure that ScoutSuite does not crash with --help"""
command = './scout.py --help'
process = subprocess.Popen(command, shell=True, stdout=None)
process.wait()
assert process.returncode == 0
@pytest.mark.xfail
def test_scout_suite_default_run(self):
"""Make sure that ScoutSuite's default run does not crash"""
rc = self.call_scout_suite([])
assert (rc == 0)