1
|
|
|
import subprocess |
2
|
|
|
|
3
|
|
|
import pytest |
4
|
|
|
|
5
|
|
|
JSON_TO_GRAPH_COMMAND = ['python3', |
6
|
|
|
'-m', |
7
|
|
|
'oval_graph.command_line', |
8
|
|
|
'json-to-graph', |
9
|
|
|
'tests_oval_graph/global_test_data/ssg-fedora-ds-arf.xml', |
10
|
|
|
'.' |
11
|
|
|
] |
12
|
|
|
|
13
|
|
|
|
14
|
|
View Code Duplication |
@pytest.mark.parametrize("command_name", ['arf-to-graph', 'arf-to-json']) |
|
|
|
|
15
|
|
|
def test_command_with_bad_arf_file_with_verbose(command_name): |
16
|
|
|
command = [ |
17
|
|
|
'python3', |
18
|
|
|
'-m', |
19
|
|
|
'oval_graph.command_line', |
20
|
|
|
command_name, |
21
|
|
|
'-v', |
22
|
|
|
'tests/test_data/xccdf_org.ssgproject.content_profile_ospp-results-initial.xml', |
23
|
|
|
'.' |
24
|
|
|
] |
25
|
|
|
out = subprocess.check_output( |
26
|
|
|
command, |
27
|
|
|
stderr=subprocess.STDOUT) |
28
|
|
|
out_string = out.decode('utf-8') |
29
|
|
|
assert out_string.find("Traceback") > -1 |
30
|
|
|
assert out_string.find("Warning:") > -1 |
31
|
|
|
assert out_string.find("Error:") > -1 |
32
|
|
|
|
33
|
|
|
|
34
|
|
View Code Duplication |
@pytest.mark.parametrize("command_name", ['arf-to-graph', 'arf-to-json']) |
|
|
|
|
35
|
|
|
def test_command_with_bad_arf_file(command_name): |
36
|
|
|
command = [ |
37
|
|
|
'python3', |
38
|
|
|
'-m', |
39
|
|
|
'oval_graph.command_line', |
40
|
|
|
command_name, |
41
|
|
|
'tests/test_data/xccdf_org.ssgproject.content_profile_ospp-results-initial.xml', |
42
|
|
|
'.' |
43
|
|
|
] |
44
|
|
|
out = subprocess.check_output( |
45
|
|
|
command, |
46
|
|
|
stderr=subprocess.STDOUT) |
47
|
|
|
out_string = out.decode('utf-8') |
48
|
|
|
assert out_string.find("Traceback") == -1 |
49
|
|
|
assert out_string.find("Warning:") > -1 |
50
|
|
|
assert out_string.find("Error:") > -1 |
51
|
|
|
|
52
|
|
|
|
53
|
|
|
def test_bad_command_json_to_graph_with_verbose(): |
54
|
|
|
command = [*JSON_TO_GRAPH_COMMAND, '-v'] |
55
|
|
|
out = subprocess.check_output(command, |
56
|
|
|
stderr=subprocess.STDOUT) |
57
|
|
|
out_string = out.decode('utf-8') |
58
|
|
|
assert out_string.find("Traceback") > -1 |
59
|
|
|
assert out_string.find("Error:") > -1 |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
def test_bad_command_json_to_graph(): |
63
|
|
|
out = subprocess.check_output(JSON_TO_GRAPH_COMMAND, |
64
|
|
|
stderr=subprocess.STDOUT) |
65
|
|
|
out_string = out.decode('utf-8') |
66
|
|
|
assert out_string.find("Traceback") == -1 |
67
|
|
|
assert out_string.find("Error:") > -1 |
68
|
|
|
|