Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit 5458ace

Browse files
authored
Merge pull request #214 from Honny1/fix-bugzilla-2011382
Fix bugzilla 2011382
2 parents f354d61 + 9ed1f38 commit 5458ace

5 files changed

Lines changed: 31 additions & 1 deletion

File tree

oval_graph/command_line_client/arf_to_html.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ def __init__(self, args):
1010

1111
def _get_message(self):
1212
return {
13+
'command_name': 'arf-to-graph',
1314
'description': 'Client for visualization of SCAP rule evaluation results',
1415
'source_filename': 'ARF scan file',
1516
}

oval_graph/command_line_client/arf_to_json.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def __init__(self, args):
1313

1414
def _get_message(self):
1515
return {
16+
'command_name': 'arf-to-json',
1617
'description': 'Client for generating JSON of SCAP rule evaluation results',
1718
'source_filename': 'ARF scan file',
1819
}

oval_graph/command_line_client/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def __init__(self, args):
2525
@staticmethod
2626
def _get_message():
2727
return {
28+
'command_name': '',
2829
'description': '',
2930
'source_filename': '',
3031
}
@@ -123,7 +124,7 @@ def _get_wanted_rules(self, rules):
123124

124125
def parse_arguments(self, args):
125126
parser = argparse.ArgumentParser(
126-
prog='oval-graph',
127+
prog=self._get_message().get('command_name'),
127128
description=self._get_message().get('description'))
128129
self.prepare_parser(parser)
129130
if args is None:

oval_graph/command_line_client/json_to_html.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def _get_rows_of_unselected_rules(self):
2727

2828
def _get_message(self):
2929
return {
30+
'command_name': 'json-to-graph',
3031
'description': 'Client for visualization of JSON created by command arf-to-json',
3132
'source_filename': 'JSON file',
3233
}

test_commands.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,26 @@ test_command_rise_error() {
180180
report "${msg}"
181181
}
182182

183+
test_of_command_output_contains_expected_str() {
184+
test_name="$1"
185+
command="$2"
186+
expected_str="$3"
187+
msg=""
188+
echo "Start: $test_name"
189+
output=$($command 2>&1)
190+
exit_code=$?
191+
if [[ $output =~ $expected_str ]]; then
192+
test_result=0
193+
msg="$test_name"
194+
else
195+
echo "$output"
196+
test_result=1
197+
overall_test_result=1
198+
msg="$test_name: $command"
199+
fi
200+
report "${msg}"
201+
}
202+
183203
clean() {
184204
file=$1
185205
if [ "$_arg_verbose" = "on" ]; then
@@ -222,6 +242,11 @@ hide_all_passing_tests_test() {
222242
test_command run-json-to-graph "json-to-graph -o ${tmp_dir_src} ${tmp_json_file_src} --hide-passing-tests -i fips"
223243
}
224244

245+
test_of_reference_to_right_binary_in_help() {
246+
test_of_command_output_contains_expected_str expect_right_reference_in_help "arf-to-graph -h" "arf-to-graph"
247+
test_of_command_output_contains_expected_str expect_right_reference_in_help "arf-to-json -h" "arf-to-json"
248+
test_of_command_output_contains_expected_str expect_right_reference_in_help "json-to-graph -h" "json-to-graph"
249+
}
225250

226251
# Backup descriptors stdout -> 3, stderr -> 4
227252
exec 3>&1 4>&2
@@ -241,6 +266,7 @@ basic_test
241266
regex_and_all_test
242267
regex_and_all_in_one_test
243268
hide_all_passing_tests_test
269+
test_of_reference_to_right_binary_in_help
244270

245271
if [ "$_arg_clean" = "on" ]; then
246272
clean "${tmp_dir_src}"

0 commit comments

Comments
 (0)