Changeset 1286

Show
Ignore:
Timestamp:
10/05/08 23:27:59 (2 months ago)
Author:
mbr
Message:

Added tests for fwknopd --Override configs, filesystem SPA packet caching (with --Save-packet and --Save-packet-append), added uptime to system specifics

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • fwknop/trunk/test/fwknop_test.pl

    r1283 r1286  
    7070my $multi_source_access_conf = "$conf_dir/multi_source_access.conf"; 
    7171my $no_local_nat_fwknop_conf = "$conf_dir/no_local_nat_fwknop.conf"; 
     72my $override_sleep_fwknop_conf = "$conf_dir/override_sleep_fwknop.conf"; 
    7273my $client_timeout_access_conf = "$conf_dir/client_timeout_access.conf"; 
    7374my $restricted_forward_access_conf = "$conf_dir/forward_internal_ip_access.conf"; 
     
    212213&test_driver("(Setup) System information and fwknop installation specifics", 
    213214    \&specs); 
     215&test_driver('(Setup) Dump config', \&dump_config); 
     216&test_driver('(Setup) Override config', \&override_config); 
     217&test_driver('(Setup) Caching SPA packets to disk', \&SPA_disk_caching); 
     218&test_driver('(Setup) Caching multiple SPA packets to disk', 
     219    \&SPA_multi_packet_disk_caching); 
    214220&test_driver('(Setup) Stopping any running fwknopd processes', 
    215221    \&stop_fwknopd); 
     
    915921    for my $cmd ( 
    916922        'uname -a', 
     923        'uptime', 
    917924        'perl -V', 
    918925        'gpg --version', 
     
    924931        "$fwknopdCmd -V", 
    925932        "$fwknopCmd -V", 
    926         "$fwknopdCmd --Dump-conf", 
     933        "$fwknopdCmd --Dump-config", 
    927934        'if [ -e /usr/bin/fwknop ]; then /usr/bin/fwknop -V; fi', 
    928935        'if [ -e /usr/sbin/fwknopd ]; then /usr/sbin/fwknopd -V; fi', 
     
    30113018} 
    30123019 
     3020sub dump_config() { 
     3021    my $cmd = "$fwknopdCmd --Dump-config"; 
     3022    if (&run_cmd($cmd, $NO_APPEND)) { 
     3023        my $found = 0; 
     3024        open F, "< $current_test_file" or die $!; 
     3025        ### just look for an expected variable 
     3026        while (<F>) { 
     3027            if (/SLEEP_INTERVAL/) { 
     3028                $found = 1; 
     3029                last; 
     3030            } 
     3031        } 
     3032        close F; 
     3033        if ($found) { 
     3034            return 1; 
     3035        } else { 
     3036            return &print_errors("[-] Could not find expected " . 
     3037                "variable from --Dump-config output"); 
     3038        } 
     3039    } 
     3040    return &print_errors("[-] Could not execute: $cmd"); 
     3041} 
     3042 
     3043sub override_config() { 
     3044    my $cmd = "$fwknopdCmd --Override-config " . 
     3045        "$override_sleep_fwknop_conf --Dump-config"; 
     3046    if (&run_cmd($cmd, $NO_APPEND)) { 
     3047        my $found = 0; 
     3048        open F, "< $current_test_file" or die $!; 
     3049        ### just look for an expected variable 
     3050        while (<F>) { 
     3051            if (/SLEEP_INTERVAL\s+42/) { 
     3052                $found = 1; 
     3053                last; 
     3054            } 
     3055        } 
     3056        close F; 
     3057        if ($found) { 
     3058            return 1; 
     3059        } else { 
     3060            return &print_errors("[-] Could not find expected " . 
     3061                "override value from --Dump-config output"); 
     3062        } 
     3063    } 
     3064    return &print_errors("[-] Could not execute: $cmd"); 
     3065} 
     3066 
     3067sub SPA_disk_caching() { 
     3068    my $pkt_file = "$output_dir/SPA_pkt.single"; 
     3069    unlink $pkt_file if -e $pkt_file; 
     3070    my $cmd = "$fwknopCmd $default_fwknop_args --Save-packet " . 
     3071        "--Save-packet-file $pkt_file"; 
     3072    unless (&run_cmd($cmd, $NO_APPEND)) { 
     3073        return &print_errors("[-] Could not execute: $cmd"); 
     3074    } 
     3075    unless (&run_cmd($cmd, $APPEND)) { 
     3076        return &print_errors("[-] Could not execute: $cmd"); 
     3077    } 
     3078    if (-e $pkt_file) { 
     3079        my $lines = 0; 
     3080        open F, "< $pkt_file" or die $!; 
     3081        while (<F>) { 
     3082            $lines++; 
     3083        } 
     3084        close F; 
     3085        if ($lines == 1) { 
     3086            return 1; 
     3087        } else { 
     3088            return &print_errors("[-] --Save-packet-file " . 
     3089                "$pkt_file does not contain a single SPA packet"); 
     3090        } 
     3091    } else { 
     3092        return &print_errors("[-] --Save-packet-file " . 
     3093            "$pkt_file does not exist"); 
     3094    } 
     3095    return &print_errors("[-] Could not write SPA packet " . 
     3096        "to --Save-packet-file $pkt_file"); 
     3097} 
     3098 
     3099sub SPA_multi_packet_disk_caching() { 
     3100    my $pkt_file = "$output_dir/SPA_pkt.multi"; 
     3101    unlink $pkt_file if -e $pkt_file; 
     3102    my $cmd = "$fwknopCmd $default_fwknop_args --Save-packet " . 
     3103        "--Save-packet-file $pkt_file --Save-packet-append"; 
     3104    unless (&run_cmd($cmd, $NO_APPEND)) { 
     3105        return &print_errors("[-] Could not execute: $cmd"); 
     3106    } 
     3107    unless (&run_cmd($cmd, $APPEND)) { 
     3108        return &print_errors("[-] Could not execute: $cmd"); 
     3109    } 
     3110    if (-e $pkt_file) { 
     3111        my $lines = 0; 
     3112        open F, "< $pkt_file" or die $!; 
     3113        while (<F>) { 
     3114            $lines++; 
     3115        } 
     3116        close F; 
     3117        if ($lines == 2) { 
     3118            return 1; 
     3119        } else { 
     3120            return &print_errors("[-] --Save-packet-file " . 
     3121                "$pkt_file does not contain two SPA packets"); 
     3122        } 
     3123    } else { 
     3124        return &print_errors("[-] --Save-packet-file " . 
     3125            "$pkt_file does not exist"); 
     3126    } 
     3127    return &print_errors("[-] Could not write two SPA packets " . 
     3128        "with --Save-packet-append"); 
     3129} 
     3130 
    30133131sub show_last() { 
    30143132    &run_cmd("$fwknopCmd --Show-last", $APPEND);