From 5597730e274ae3ac736654839413d378e23c61aa Mon Sep 17 00:00:00 2001 From: Michael Rash Date: Sun, 18 Oct 2015 09:13:49 -0700 Subject: [PATCH] [test suite] added open/close file tests --- .../hmac_cmd_open_close_cycle_access.conf | 8 +++---- test/test-fwknop.pl | 22 +++++++++++++++++++ test/tests/rijndael_hmac_cmd_open_close.pl | 4 +++- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/test/conf/hmac_cmd_open_close_cycle_access.conf b/test/conf/hmac_cmd_open_close_cycle_access.conf index fbe909e2..7d3633be 100644 --- a/test/conf/hmac_cmd_open_close_cycle_access.conf +++ b/test/conf/hmac_cmd_open_close_cycle_access.conf @@ -1,8 +1,6 @@ SOURCE ANY KEY_BASE64 wzNP62oPPgEc+kXDPQLHPOayQBuNbYUTPP+QrErNDmg= HMAC_KEY_BASE64 Yh+xizBnl6FotC5ec7FanVGClRMlsOAPh2u6eovnerfBVKwaVKzjGoblFMHMc593TNyi0dWn4opLoTIV9q/ttg== -FW_ACCESS_TIMEOUT 3 -#CMD_CYCLE_OPEN /some/cmd/to/execute -with -args test test -CMD_CYCLE_OPEN /usr/bin/touch /tmp/cmdcycle.test -CMD_CYCLE_CLOSE /some/closecmd/to/execute -test -CMD_CYCLE_TIMER 2 +CMD_CYCLE_OPEN /usr/bin/touch /tmp/$IP +CMD_CYCLE_CLOSE /usr/bin/touch /tmp/2$IP +CMD_CYCLE_TIMER 1 diff --git a/test/test-fwknop.pl b/test/test-fwknop.pl index 22e863e0..01831bd9 100755 --- a/test/test-fwknop.pl +++ b/test/test-fwknop.pl @@ -917,6 +917,8 @@ my %test_keys = ( 'server_access_file' => $OPTIONAL, 'server_conf_file' => $OPTIONAL, 'digest_cache_file' => $OPTIONAL, + 'cmd_cycle_open_file' => $OPTIONAL, + 'cmd_cycle_close_file' => $OPTIONAL, 'cmd_exec_file_owner' => $OPTIONAL, 'cmd_exec_file_not_created' => $OPTIONAL, 'rm_rule_mid_cycle' => $OPTIONAL, @@ -4737,6 +4739,26 @@ sub write_sudo_access_conf() { return; } +sub spa_cmd_open_close_exec_cycle() { + my $test_hr = shift; + for my $file ($test_hr->{'cmd_cycle_open_file'}, + $test_hr->{'cmd_cycle_close_file'}) { + unlink $file if -e $file; + } + my $rv = &spa_cycle($test_hr); + + for my $file ($test_hr->{'cmd_cycle_open_file'}, + $test_hr->{'cmd_cycle_close_file'}) { + unless (-e $file) { + &write_test_file("[-] $file does not exist after SPA cycle.\n", + $curr_test_file); + $rv = 0; + } + } + + return $rv; +} + sub spa_cmd_exec_cycle() { my $test_hr = shift; diff --git a/test/tests/rijndael_hmac_cmd_open_close.pl b/test/tests/rijndael_hmac_cmd_open_close.pl index 7f1e00bd..290a7d11 100644 --- a/test/tests/rijndael_hmac_cmd_open_close.pl +++ b/test/tests/rijndael_hmac_cmd_open_close.pl @@ -4,11 +4,13 @@ 'category' => 'Rijndael+HMAC', 'subcategory' => 'client+server', 'detail' => 'cmd open/close cycle', - 'function' => \&spa_cycle, + 'function' => \&spa_cmd_open_close_exec_cycle, 'cmdline' => $default_client_hmac_args, 'fwknopd_cmdline' => "$fwknopdCmd -c $cf{'def'} -a $cf{'hmac_cmd_open_close_cycle_access'} " . "-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'}, }, );