forked from nccgroup/ScoutSuite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_utils_console.py
executable file
·76 lines (58 loc) · 3.13 KB
/
test_utils_console.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
# -*- coding: utf-8 -*-
import unittest
from ScoutSuite.core.console import *
class TestOpinelUtilsConsoleClass(unittest.TestCase):
def test_configPrintException(self):
set_logger_configuration(False)
set_logger_configuration(True)
def test_printDebug(self):
print_debug('hello')
def test_printError(self):
print_error('hello')
def test_printException(self):
set_logger_configuration(True)
try:
raise Exception('opinelunittest')
except Exception as e:
print_exception(e)
set_logger_configuration(False)
try:
raise Exception('opinelunittest')
except Exception as e:
print_exception(e)
try:
raise Exception('opinelunittest')
except Exception as e:
print_exception(e, True)
def test_printInfo(msg, newLine=True):
print_info('hello')
def test_printGeneric(self):
print_generic('hello')
def test_prompt(self):
assert prompt('a') == 'a'
assert prompt('') == ''
test = ['a', 'b']
assert prompt(test) == 'a'
assert prompt(test) == 'b'
assert prompt(test) == ''
def test_prompt_4_value(self):
assert prompt_value('prompt_4_value', no_confirm=True, test_input='inputvalue') == 'inputvalue'
assert prompt_value('prompt_4_value', no_confirm=True, is_question=True, test_input='inputvalue') == 'inputvalue'
assert prompt_value('prompt_4_value', choices=['a', 'b', 'c'], no_confirm=True, test_input='b') == 'b'
assert prompt_value('prompt_4_value', choices=['a', 'b', 'c'], display_choices=False, no_confirm=True, test_input='b') == 'b'
assert prompt_value('prompt_4_value', choices=['a', 'b', 'c'], display_indices=True, no_confirm=True, test_input='1') == 'b'
assert prompt_value('prompt_4_value', choices=['a', 'b', 'c'], default='b', no_confirm=True, test_input='') == 'b'
assert prompt_value('prompt_4_value', choices=['a', 'b', 'c'], no_confirm=True, authorize_list=True, test_input='a,b') == 'a,b'
assert prompt_value('prompt_4_value', choices=['a', 'b', 'c'], required=True, no_confirm=True, test_input=['', 'b']) == 'b'
assert prompt_value('prompt_4_value', choices=['a', 'b', 'c'], required=True, no_confirm=True, test_input=['invalid', 'b']) == 'b'
assert prompt_value('prompt_4_value', choices=['a', 'b', 'c'], no_confirm=True, test_input='a,c') == None
assert prompt_value('prompt_4_value', choices=['a', 'b', 'c'], no_confirm=True, test_input='a,b', authorize_list = True) == 'a,b'
assert prompt_value('prompt_4_value', choices=['a', 'b', 'c'], no_confirm=True, test_input='a,e', authorize_list = True) == None
def test_prompt_4_yes_no(self):
assert prompt_yes_no('hello', 'N') == False
assert prompt_yes_no('hello', 'no') == False
assert prompt_yes_no('hello', 'Y') == True
assert prompt_yes_no('hello', 'yes') == True
assert prompt_yes_no('hello', ['foo', 'bar', 'no']) == False
assert prompt_yes_no('hello', 'Ye') == None
assert prompt_yes_no('hello', 'Non') == None