summaryrefslogtreecommitdiffstats
path: root/plugins/t
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/t')
-rw-r--r--plugins/t/check_pop.t54
1 files changed, 36 insertions, 18 deletions
diff --git a/plugins/t/check_pop.t b/plugins/t/check_pop.t
index e78f963..b78291d 100644
--- a/plugins/t/check_pop.t
+++ b/plugins/t/check_pop.t
@@ -6,33 +6,51 @@
6# 6#
7 7
8use strict; 8use strict;
9use Test; 9use Test::More;
10use NPTest; 10use NPTest;
11 11
12use vars qw($tests); 12plan tests => 5;
13BEGIN {$tests = 5; plan tests => $tests}
14 13
15my $host_tcp_smtp = getTestParameter( "host_tcp_smtp", "NP_HOST_TCP_SMTP", "mailhost", 14my $host_tcp_smtp = getTestParameter(
16 "A host providing an STMP Service (a mail server)"); 15 "NP_HOST_TCP_SMTP",
16 "A host providing an STMP Service (a mail server)",
17 "mailhost"
18 );
17 19
18my $host_tcp_pop = getTestParameter( "host_tcp_pop", "NP_HOST_TCP_POP", $host_tcp_smtp, 20my $host_tcp_pop = getTestParameter(
19 "A host providing an POP Service (a mail server)"); 21 "NP_HOST_TCP_POP",
22 "A host providing a POP Service (a mail server)",
23 $host_tcp_smtp
24 );
20 25
21my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1", 26my $host_nonresponsive = getTestParameter(
22 "The hostname of system not responsive to network requests" ); 27 "NP_HOST_NONRESPONSIVE",
28 "The hostname of system not responsive to network requests",
29 "10.0.0.1",
30 );
23 31
24my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost", 32my $hostname_invalid = getTestParameter(
25 "An invalid (not known to DNS) hostname" ); 33 "NP_HOSTNAME_INVALID",
34 "An invalid (not known to DNS) hostname",
35 "nosuchhost",
36 );
26 37
27my %exceptions = ( 2 => "No POP Server present?" ); 38my %exceptions = ( 2 => "No POP Server present?" );
28 39
29my $t; 40my $t;
41my $res;
30 42
31$t += checkCmd( "./check_pop $host_tcp_pop", 0, undef, %exceptions ); 43$res = NPTest->testCmd( "./check_pop $host_tcp_pop" );
32$t += checkCmd( "./check_pop -H $host_tcp_pop -p 110 -w 9 -c 9 -t 10 -e '+OK'", 0, undef, %exceptions ); 44cmp_ok( $res->return_code, '==', 0, "POP server ok");
33$t += checkCmd( "./check_pop $host_tcp_pop -p 110 -wt 9 -ct 9 -to 10 -e '+OK'", 0, undef, %exceptions );
34$t += checkCmd( "./check_pop $host_nonresponsive", 2 );
35$t += checkCmd( "./check_pop $hostname_invalid", 2 );
36 45
37exit(0) if defined($Test::Harness::VERSION); 46$res = NPTest->testCmd( "./check_pop -H $host_tcp_pop -p 110 -w 9 -c 9 -t 10 -e '+OK'");
38exit($tests - $t); 47cmp_ok( $res->return_code, '==', 0, "POP server returned +OK");
48
49$res = NPTest->testCmd( "./check_pop $host_tcp_pop -p 110 -wt 9 -ct 9 -to 10 -e '+OK'");
50cmp_ok( $res->return_code, '==', 0, "Old syntax");
51
52$res = NPTest->testCmd( "./check_pop $host_nonresponsive" );
53cmp_ok( $res->return_code, '==', 2, "Non responsive host");
54
55$res = NPTest->testCmd( "./check_pop $hostname_invalid" );
56cmp_ok( $res->return_code, '==', 2, "Invalid host");