From 8c7a007a4a61ab427f91af0103197978a65d52eb Mon Sep 17 00:00:00 2001 From: Michael Rash Date: Tue, 17 Nov 2015 22:41:22 -0800 Subject: [PATCH] [test suite] differentiate TIMEOUT vs. CLIENT_TIMEOUT values in command open close cycles --- Makefile.am | 2 ++ .../hmac_cmd_open_close_cycle_access7.conf | 6 ++++ .../hmac_cmd_open_close_cycle_access8.conf | 6 ++++ test/test-fwknop.pl | 35 ++++++++++++------- test/tests/rijndael_hmac_cmd_open_close.pl | 22 ++++++++++-- 5 files changed, 56 insertions(+), 15 deletions(-) create mode 100644 test/conf/hmac_cmd_open_close_cycle_access7.conf create mode 100644 test/conf/hmac_cmd_open_close_cycle_access8.conf diff --git a/Makefile.am b/Makefile.am index 6045d80b..967d015d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -197,6 +197,8 @@ EXTRA_DIST = \ test/conf/hmac_cmd_open_close_cycle_access4.conf \ test/conf/hmac_cmd_open_close_cycle_access5.conf \ test/conf/hmac_cmd_open_close_cycle_access6.conf \ + test/conf/hmac_cmd_open_close_cycle_access7.conf \ + test/conf/hmac_cmd_open_close_cycle_access8.conf \ test/conf/hmac_cmd_open_close_multi_cycle_access.conf \ test/conf/hmac_get_key_access.conf \ test/conf/hmac_no_b64_access.conf \ diff --git a/test/conf/hmac_cmd_open_close_cycle_access7.conf b/test/conf/hmac_cmd_open_close_cycle_access7.conf new file mode 100644 index 00000000..f03b0d93 --- /dev/null +++ b/test/conf/hmac_cmd_open_close_cycle_access7.conf @@ -0,0 +1,6 @@ +SOURCE ANY +KEY_BASE64 wzNP62oPPgEc+kXDPQLHPOayQBuNbYUTPP+QrErNDmg= +HMAC_KEY_BASE64 Yh+xizBnl6FotC5ec7FanVGClRMlsOAPh2u6eovnerfBVKwaVKzjGoblFMHMc593TNyi0dWn4opLoTIV9q/ttg== +CMD_CYCLE_OPEN /bin/echo 1$TIMEOUT +CMD_CYCLE_CLOSE /bin/echo 2$TIMEOUT +CMD_CYCLE_TIMER 30 diff --git a/test/conf/hmac_cmd_open_close_cycle_access8.conf b/test/conf/hmac_cmd_open_close_cycle_access8.conf new file mode 100644 index 00000000..2ecf6e3f --- /dev/null +++ b/test/conf/hmac_cmd_open_close_cycle_access8.conf @@ -0,0 +1,6 @@ +SOURCE ANY +KEY_BASE64 wzNP62oPPgEc+kXDPQLHPOayQBuNbYUTPP+QrErNDmg= +HMAC_KEY_BASE64 Yh+xizBnl6FotC5ec7FanVGClRMlsOAPh2u6eovnerfBVKwaVKzjGoblFMHMc593TNyi0dWn4opLoTIV9q/ttg== +CMD_CYCLE_OPEN /bin/echo 1$CLIENT_TIMEOUT1 +CMD_CYCLE_CLOSE /bin/echo 2$CLIENT_TIMEOUT2 +CMD_CYCLE_TIMER 30 diff --git a/test/test-fwknop.pl b/test/test-fwknop.pl index 46f61af9..06c13003 100755 --- a/test/test-fwknop.pl +++ b/test/test-fwknop.pl @@ -444,6 +444,8 @@ our %cf = ( 'hmac_cmd_open_close_cycle_access4' => "$conf_dir/hmac_cmd_open_close_cycle_access4.conf", 'hmac_cmd_open_close_cycle_access5' => "$conf_dir/hmac_cmd_open_close_cycle_access5.conf", 'hmac_cmd_open_close_cycle_access6' => "$conf_dir/hmac_cmd_open_close_cycle_access6.conf", + 'hmac_cmd_open_close_cycle_access7' => "$conf_dir/hmac_cmd_open_close_cycle_access7.conf", + 'hmac_cmd_open_close_cycle_access8' => "$conf_dir/hmac_cmd_open_close_cycle_access8.conf", 'hmac_cmd_open_close_multi_cycle_access' => "$conf_dir/hmac_cmd_open_close_multi_cycle_access.conf", 'spa_destination' => "$conf_dir/destination_rule_fwknopd.conf", "${fw_conf_prefix}_spa_dst_snat" => "$conf_dir/${fw_conf_prefix}_spa_dst_snat_fwknopd.conf", @@ -4859,25 +4861,34 @@ sub write_sudo_access_conf() { sub spa_cmd_open_close_exec_cycle() { my $test_hr = shift; - for my $file (@{$test_hr->{'cmd_cycle_open_file'}}) { - unlink $file if -e $file; + + if ($test_hr->{'cmd_cycle_open_file'}) { + for my $file (@{$test_hr->{'cmd_cycle_open_file'}}) { + unlink $file if -e $file; + } } - for my $file (@{$test_hr->{'cmd_cycle_close_file'}}) { - next if $file eq 'NONE'; - unlink $file if -e $file; + if ($test_hr->{'cmd_cycle_close_file'}) { + for my $file (@{$test_hr->{'cmd_cycle_close_file'}}) { + next if $file eq 'NONE'; + unlink $file if -e $file; + } } my $rv = &spa_cycle($test_hr); - unless (&file_check_and_remove('cycle open file', - $test_hr->{'cmd_cycle_open_file'})) { - $rv = 0; + if ($test_hr->{'cmd_cycle_open_file'}) { + unless (&file_check_and_remove('cycle open file', + $test_hr->{'cmd_cycle_open_file'})) { + $rv = 0; + } } - unless ($test_hr->{'cmd_cycle_close_file'} eq 'NONE') { - unless (&file_check_and_remove('cycle close file', - $test_hr->{'cmd_cycle_close_file'})) { - $rv = 0; + if ($test_hr->{'cmd_cycle_close_file'}) { + unless ($test_hr->{'cmd_cycle_close_file'} eq 'NONE') { + unless (&file_check_and_remove('cycle close file', + $test_hr->{'cmd_cycle_close_file'})) { + $rv = 0; + } } } diff --git a/test/tests/rijndael_hmac_cmd_open_close.pl b/test/tests/rijndael_hmac_cmd_open_close.pl index 43b66c5a..bef2353c 100644 --- a/test/tests/rijndael_hmac_cmd_open_close.pl +++ b/test/tests/rijndael_hmac_cmd_open_close.pl @@ -76,15 +76,31 @@ 'detail' => 'cmd open/close cycle client timeout', 'function' => \&spa_cmd_open_close_exec_cycle, 'cmdline' => "$default_client_hmac_args --fw-timeout 2", - 'fwknopd_cmdline' => "$fwknopdCmd -c $cf{'def'} -a $cf{'hmac_cmd_open_close_cycle_access'} " . + 'fwknopd_cmdline' => "$fwknopdCmd -c $cf{'def'} -a $cf{'hmac_cmd_open_close_cycle_access7'} " . "-d $default_digest_file -p $default_pid_file $intf_str", 'fw_rule_created' => $REQUIRE_NO_NEW_RULE, - 'cmd_cycle_open_file' => ['/tmp/127.0.0.2'], - 'cmd_cycle_close_file' => ['/tmp/2127.0.0.2'], 'key_file' => $cf{'rc_hmac_b64_key'}, 'server_positive_output_matches' => [ qr/Timer expired/, qr/Running.*CLOSE.*in 2 seconds/, + qr/CLOSE.*\s2\d{5}/, + ], + }, + { + 'category' => 'Rijndael+HMAC', + 'subcategory' => 'client+server', + 'detail' => 'cmd open/close cycle timeout (2)', + 'function' => \&spa_cmd_open_close_exec_cycle, + 'cmdline' => "$default_client_hmac_args --fw-timeout 2", + 'fwknopd_cmdline' => "$fwknopdCmd -c $cf{'def'} -a $cf{'hmac_cmd_open_close_cycle_access8'} " . + "-d $default_digest_file -p $default_pid_file $intf_str", + 'fw_rule_created' => $REQUIRE_NO_NEW_RULE, + 'key_file' => $cf{'rc_hmac_b64_key'}, + 'server_positive_output_matches' => [ + qr/Timer expired/, + qr/Running.*CLOSE.*in 2 seconds/, + qr/OPEN.*\s121/, + qr/CLOSE.*\s222/, ], }, {