This repository was archived by the owner on Jan 9, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
oval_graph/command_line_client Expand file tree Collapse file tree Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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 :
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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+
183203clean () {
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
227252exec 3>&1 4>&2
@@ -241,6 +266,7 @@ basic_test
241266regex_and_all_test
242267regex_and_all_in_one_test
243268hide_all_passing_tests_test
269+ test_of_reference_to_right_binary_in_help
244270
245271if [ " $_arg_clean " = " on" ]; then
246272 clean " ${tmp_dir_src} "
You can’t perform that action at this time.
0 commit comments