summaryrefslogtreecommitdiffstats
path: root/plugins/tests
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/tests')
-rwxr-xr-xplugins/tests/check_http.t35
-rwxr-xr-xplugins/tests/check_procs.t29
-rwxr-xr-xplugins/tests/check_snmp.t2
3 files changed, 33 insertions, 33 deletions
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t
index 2c89beb..d93a0ec 100755
--- a/plugins/tests/check_http.t
+++ b/plugins/tests/check_http.t
@@ -20,8 +20,9 @@ use FindBin qw($Bin);
20my $common_tests = 70; 20my $common_tests = 70;
21my $ssl_only_tests = 8; 21my $ssl_only_tests = 8;
22# Check that all dependent modules are available 22# Check that all dependent modules are available
23eval "use HTTP::Daemon 6.01;";
24plan skip_all => 'HTTP::Daemon >= 6.01 required' if $@;
23eval { 25eval {
24 require HTTP::Daemon;
25 require HTTP::Status; 26 require HTTP::Status;
26 require HTTP::Response; 27 require HTTP::Response;
27}; 28};
@@ -185,21 +186,21 @@ SKIP: {
185 186
186 $result = NPTest->testCmd( "$command -p $port_https -S -C 14" ); 187 $result = NPTest->testCmd( "$command -p $port_https -S -C 14" );
187 is( $result->return_code, 0, "$command -p $port_https -S -C 14" ); 188 is( $result->return_code, 0, "$command -p $port_https -S -C 14" );
188 is( $result->output, 'OK - Certificate \'Ton Voon\' will expire on 03/03/2019 21:41.', "output ok" ); 189 is( $result->output, 'OK - Certificate \'Ton Voon\' will expire on Sun Mar 3 21:41:00 2019.', "output ok" );
189 190
190 $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" ); 191 $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" );
191 is( $result->return_code, 1, "$command -p $port_https -S -C 14000" ); 192 is( $result->return_code, 1, "$command -p $port_https -S -C 14000" );
192 like( $result->output, '/WARNING - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(03/03/2019 21:41\)./', "output ok" ); 193 like( $result->output, '/WARNING - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:00 2019\)./', "output ok" );
193 194
194 # Expired cert tests 195 # Expired cert tests
195 $result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" ); 196 $result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" );
196 is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" ); 197 is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" );
197 like( $result->output, '/CRITICAL - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(03/03/2019 21:41\)./', "output ok" ); 198 like( $result->output, '/CRITICAL - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:00 2019\)./', "output ok" );
198 199
199 $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" ); 200 $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" );
200 is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" ); 201 is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" );
201 is( $result->output, 202 is( $result->output,
202 'CRITICAL - Certificate \'Ton Voon\' expired on 03/05/2009 00:13.', 203 'CRITICAL - Certificate \'Ton Voon\' expired on Thu Mar 5 00:13:00 2009.',
203 "output ok" ); 204 "output ok" );
204 205
205} 206}
@@ -392,27 +393,21 @@ sub run_common_tests {
392 skip "This doesn't seems to work all the time", 1 unless ($ENV{HTTP_EXTERNAL}); 393 skip "This doesn't seems to work all the time", 1 unless ($ENV{HTTP_EXTERNAL});
393 $cmd = "$command -f follow -u /redir_external -t 5"; 394 $cmd = "$command -f follow -u /redir_external -t 5";
394 eval { 395 eval {
395 local $SIG{ALRM} = sub { die "alarm\n" }; 396 $result = NPTest->testCmd( $cmd, 2 );
396 alarm(2); 397 };
397 $result = NPTest->testCmd( $cmd ); 398 like( $@, "/timeout in command: $cmd/", $cmd );
398 alarm(0); };
399 is( $@, "alarm\n", $cmd );
400 } 399 }
401 400
402 $cmd = "$command -u /timeout -t 5"; 401 $cmd = "$command -u /timeout -t 5";
403 eval { 402 eval {
404 local $SIG{ALRM} = sub { die "alarm\n" }; 403 $result = NPTest->testCmd( $cmd, 2 );
405 alarm(2); 404 };
406 $result = NPTest->testCmd( $cmd ); 405 like( $@, "/timeout in command: $cmd/", $cmd );
407 alarm(0); };
408 is( $@, "alarm\n", $cmd );
409 406
410 $cmd = "$command -f follow -u /redir_timeout -t 2"; 407 $cmd = "$command -f follow -u /redir_timeout -t 2";
411 eval { 408 eval {
412 local $SIG{ALRM} = sub { die "alarm\n" }; 409 $result = NPTest->testCmd( $cmd, 5 );
413 alarm(5); 410 };
414 $result = NPTest->testCmd( $cmd ); 411 is( $@, "", $cmd );
415 alarm(0); };
416 isnt( $@, "alarm\n", $cmd );
417 412
418} 413}
diff --git a/plugins/tests/check_procs.t b/plugins/tests/check_procs.t
index 1ad2c2f..54d43d9 100755
--- a/plugins/tests/check_procs.t
+++ b/plugins/tests/check_procs.t
@@ -48,21 +48,26 @@ SKIP: {
48 like( $result->output, '/^PROCS OK: 1 process with command name \'launchd\', UID = 501 (.*)$/', "Output correct" ); 48 like( $result->output, '/^PROCS OK: 1 process with command name \'launchd\', UID = 501 (.*)$/', "Output correct" );
49} 49}
50 50
51$result = NPTest->testCmd( "$command -u -2 -w 2:2" ); 51SKIP: {
52is( $result->return_code, 1, "Checking processes with userid=-2" ); 52 skip 'user with uid -2 required', 8 unless getpwuid(-2);
53like( $result->output, '/^PROCS WARNING: 3 processes with UID = -2 \(nobody\)$/', "Output correct" ); 53 skip 'uid -2 must have name "nobody"', 8 unless getpwuid(-2) eq 'nobody';
54
55 $result = NPTest->testCmd( "$command -u -2 -w 2:2" );
56 is( $result->return_code, 1, "Checking processes with userid=-2" );
57 like( $result->output, '/^PROCS WARNING: 3 processes with UID = -2 \(nobody\)$/', "Output correct" );
54 58
55$result = NPTest->testCmd( "$command -u -2 -w 3:3" ); 59 $result = NPTest->testCmd( "$command -u -2 -w 3:3" );
56is( $result->return_code, 0, "Checking processes with userid=-2 past threshold" ); 60 is( $result->return_code, 0, "Checking processes with userid=-2 past threshold" );
57like( $result->output, '/^PROCS OK: 3 processes with UID = -2 \(nobody\)$/', "Output correct" ); 61 like( $result->output, '/^PROCS OK: 3 processes with UID = -2 \(nobody\)$/', "Output correct" );
58 62
59$result = NPTest->testCmd( "$command -u -2 -a usb" ); 63 $result = NPTest->testCmd( "$command -u -2 -a usb" );
60is( $result->return_code, 0, "Checking processes with userid=-2 and usb in arguments" ); 64 is( $result->return_code, 0, "Checking processes with userid=-2 and usb in arguments" );
61like( $result->output, '/^PROCS OK: 1 process with UID = -2 \(nobody\), args \'usb\'/', "Output correct" ); 65 like( $result->output, '/^PROCS OK: 1 process with UID = -2 \(nobody\), args \'usb\'/', "Output correct" );
62 66
63$result = NPTest->testCmd( "$command -u -2 -a UsB" ); 67 $result = NPTest->testCmd( "$command -u -2 -a UsB" );
64is( $result->return_code, 0, "Checking case sensitivity of args" ); 68 is( $result->return_code, 0, "Checking case sensitivity of args" );
65like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \'UsB\'/', "Output correct" ); 69 like( $result->output, '/^PROCS OK: 0 processes with UID = -2 \(nobody\), args \'UsB\'/', "Output correct" );
70};
66 71
67$result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" ); 72$result = NPTest->testCmd( "$command --ereg-argument-array='mdworker.*501'" );
68is( $result->return_code, 0, "Checking regexp search of arguments" ); 73is( $result->return_code, 0, "Checking regexp search of arguments" );
diff --git a/plugins/tests/check_snmp.t b/plugins/tests/check_snmp.t
index d865e19..aace9bc 100755
--- a/plugins/tests/check_snmp.t
+++ b/plugins/tests/check_snmp.t
@@ -79,7 +79,7 @@ Copyright (c) 1986-2004 by cisco Systems, Inc.
79$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.0 -o sysContact.0 -o .1.3.6.1.4.1.8072.3.2.67.1"); 79$res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.0 -o sysContact.0 -o .1.3.6.1.4.1.8072.3.2.67.1");
80cmp_ok( $res->return_code, '==', 0, "Exit OK when querying multi-line OIDs" ); 80cmp_ok( $res->return_code, '==', 0, "Exit OK when querying multi-line OIDs" );
81like($res->output, '/^SNMP OK - /', "String contains SNMP OK"); 81like($res->output, '/^SNMP OK - /', "String contains SNMP OK");
82like($res->output, '/'.quotemeta('SNMP OK - Cisco Internetwork Operating System Software "Alice" Kisco Outernetwork Oserating Gystem Totware | 82like($res->output, '/'.quotemeta('SNMP OK - Cisco Internetwork Operating System Software ').'"?Alice"?'.quotemeta(' Kisco Outernetwork Oserating Gystem Totware |
83.1.3.6.1.4.1.8072.3.2.67.0: 83.1.3.6.1.4.1.8072.3.2.67.0:
84"Cisco Internetwork Operating System Software 84"Cisco Internetwork Operating System Software
85IOS (tm) Catalyst 4000 \"L3\" Switch Software (cat4000-I9K91S-M), Version 85IOS (tm) Catalyst 4000 \"L3\" Switch Software (cat4000-I9K91S-M), Version