mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-04-22 14:46:57 -04:00
Fix/adapt tests
This commit is contained in:
parent
afa81204dc
commit
404d52efb9
2 changed files with 29 additions and 18 deletions
|
|
@ -124,14 +124,14 @@ SKIP: {
|
|||
|
||||
$res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'mONiTORing'" );
|
||||
cmp_ok( $res->return_code, "==", 2, "Not got 'mONiTORing'");
|
||||
like ( $res->output, "/pattern not found/", "Error message says 'pattern not found'");
|
||||
like ( $res->output, "/matched not/", "Error message says 'matched not'");
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -R 'mONiTORing'" );
|
||||
cmp_ok( $res->return_code, "==", 0, "But case insensitive doesn't mind 'mONiTORing'");
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'monitoring' --invert-regex" );
|
||||
cmp_ok( $res->return_code, "==", 2, "Invert results work when found");
|
||||
like ( $res->output, "/pattern found/", "Error message says 'pattern found'");
|
||||
like ( $res->output, "/matched/", "Error message says 'matched'");
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -H $host_tcp_http2 -r 'mONiTORing' --invert-regex" );
|
||||
cmp_ok( $res->return_code, "==", 0, "And also when not found");
|
||||
|
|
@ -151,63 +151,74 @@ SKIP: {
|
|||
|
||||
$res = NPTest->testCmd( "./$plugin -C 8000,1 --ssl $host_tls_http" );
|
||||
cmp_ok( $res->return_code, '==', 1, "Checking certificate for $host_tls_http");
|
||||
like ( $res->output, qr/WARNING - Certificate '$host_tls_cert' expires in \d+ day/, "Output Warning" );
|
||||
like ( $res->output, qr/Certificate '$host_tls_cert' expires in \d+ day/, "Output Warning" );
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin $host_tls_http -C 1" );
|
||||
is( $res->return_code, 0, "Old syntax for cert checking okay" );
|
||||
is( $res->output, $saved_cert_output, "Same output as new syntax" );
|
||||
# deactived since different timings will change the output
|
||||
# TODO compare without perfdata
|
||||
# is( $res->output, $saved_cert_output, "Same output as new syntax" );
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -H $host_tls_http -C 1" );
|
||||
is( $res->return_code, 0, "Updated syntax for cert checking okay" );
|
||||
is( $res->output, $saved_cert_output, "Same output as new syntax" );
|
||||
# deactived since different timings will change the output
|
||||
# TODO compare without perfdata
|
||||
# is( $res->output, $saved_cert_output, "Same output as new syntax" );
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -C 1 $host_tls_http" );
|
||||
cmp_ok( $res->output, 'eq', $saved_cert_output, "--ssl option automatically added");
|
||||
# deactived since different timings will change the output
|
||||
# TODO compare without perfdata
|
||||
# cmp_ok( $res->output, 'eq', $saved_cert_output, "--ssl option automatically added");
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin $host_tls_http -C 1" );
|
||||
cmp_ok( $res->output, 'eq', $saved_cert_output, "Old syntax for cert checking still works");
|
||||
# deactived since different timings will change the output
|
||||
# TODO compare without perfdata
|
||||
# cmp_ok( $res->output, 'eq', $saved_cert_output, "Old syntax for cert checking still works");
|
||||
|
||||
# run some certificate checks with faketime
|
||||
SKIP: {
|
||||
skip "No faketime binary found", 12 if !$faketime;
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC ./$plugin -C 1 $host_tls_http");
|
||||
like($res->output, qr/OK - Certificate '$host_tls_cert' will expire on/, "Catch cert output");
|
||||
like($res->output, qr/Certificate '$host_tls_cert' will expire on/, "Catch cert output");
|
||||
is( $res->return_code, 0, "Catch cert output exit code" );
|
||||
|
||||
my($mon,$day,$hour,$min,$sec,$year) = ($res->output =~ /(\w+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\d+)/);
|
||||
if(!defined $year) {
|
||||
die("parsing date failed from: ".$res->output);
|
||||
}
|
||||
|
||||
my $months = {'Jan' => 0, 'Feb' => 1, 'Mar' => 2, 'Apr' => 3, 'May' => 4, 'Jun' => 5, 'Jul' => 6, 'Aug' => 7, 'Sep' => 8, 'Oct' => 9, 'Nov' => 10, 'Dec' => 11};
|
||||
my $ts = mktime($sec, $min, $hour, $day, $months->{$mon}, $year-1900);
|
||||
my $time = strftime("%Y-%m-%d %H:%M:%S", localtime($ts));
|
||||
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts))."' ./$plugin -C 1 $host_tls_http");
|
||||
like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' just expired/, "Output on expire date");
|
||||
like($res->output, qr/Certificate '$host_tls_cert' just expired/, "Output on expire date");
|
||||
is( $res->return_code, 2, "Output on expire date" );
|
||||
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-1))."' ./$plugin -C 1 $host_tls_http");
|
||||
like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 0 minutes/, "cert expires in 1 second output");
|
||||
like($res->output, qr/Certificate '$host_tls_cert' expires in 0 minutes/, "cert expires in 1 second output");
|
||||
is( $res->return_code, 2, "cert expires in 1 second exit code" );
|
||||
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-120))."' ./$plugin -C 1 $host_tls_http");
|
||||
like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 2 minutes/, "cert expires in 2 minutes output");
|
||||
like($res->output, qr/Certificate '$host_tls_cert' expires in 2 minutes/, "cert expires in 2 minutes output");
|
||||
is( $res->return_code, 2, "cert expires in 2 minutes exit code" );
|
||||
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts-7200))."' ./$plugin -C 1 $host_tls_http");
|
||||
like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expires in 2 hours/, "cert expires in 2 hours output");
|
||||
like($res->output, qr/Certificate '$host_tls_cert' expires in 2 hours/, "cert expires in 2 hours output");
|
||||
is( $res->return_code, 2, "cert expires in 2 hours exit code" );
|
||||
|
||||
$res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+1))."' ./$plugin -C 1 $host_tls_http");
|
||||
like($res->output, qr/CRITICAL - Certificate '$host_tls_cert' expired on/, "Certificate expired output");
|
||||
like($res->output, qr/Certificate '$host_tls_cert' expired on/, "Certificate expired output");
|
||||
is( $res->return_code, 2, "Certificate expired exit code" );
|
||||
};
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin --ssl $host_tls_http -E" );
|
||||
like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
|
||||
like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' );
|
||||
like ( $res->output, '/\'time_connect\'=[\d\.]+/', 'Extended Performance Data Output OK' );
|
||||
like ( $res->output, '/\'time_tls\'=[\d\.]+/', 'Extended Performance Data SSL Output OK' );
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -H monitoring-plugins.org -u /download.html -f follow" );
|
||||
is( $res->return_code, 0, "Redirection based on location is okay");
|
||||
|
||||
$res = NPTest->testCmd( "./$plugin -H monitoring-plugins.org --extended-perfdata" );
|
||||
like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
|
||||
like ( $res->output, '/\'time_connect\'=[\d\.]+/', 'Extended Performance Data Output OK' );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ SKIP: {
|
|||
|
||||
$result = NPTest->testCmd( "$command -p $port_https -S -C 14" );
|
||||
is( $result->return_code, 0, "$command -p $port_https -S -C 14" );
|
||||
like( $result->output, "/.*Certificate \'Monitoring Plugins\' will expire on $expiry.*", "output ok" );
|
||||
like( $result->output, '/.*Certificate \'Monitoring Plugins\' will expire on ' . quotemeta($expiry) . '.*/', "output ok" );
|
||||
|
||||
$result = NPTest->testCmd( "$command -p $port_https -S -C 14000" );
|
||||
is( $result->return_code, 1, "$command -p $port_https -S -C 14000" );
|
||||
|
|
@ -260,7 +260,7 @@ SKIP: {
|
|||
$result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" );
|
||||
is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" );
|
||||
like( $result->output,
|
||||
'/.*Certificate \'Monitoring Plugins\' expired on Wed Jan 2 12:00:00 2008 +0000.*/',
|
||||
'/.*Certificate \'Monitoring Plugins\' expired on Wed Jan\s+2 12:00:00 2008 \+0000.*/',
|
||||
"output ok" );
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue