Code

check_ping's timeout interval is only +1 if ping command has a timeout value.
[nagiosplug.git] / plugins / t / check_imap.t
1 #! /usr/bin/perl -w -I ..
2 #
3 # Internet Mail Access Protocol (IMAP) Server Tests via check_imap
4 #
5 # $Id$
6 #
8 use strict;
9 use Test::More tests => 7;
10 use NPTest;
12 my $host_tcp_smtp      = getTestParameter( "host_tcp_smtp",      "NP_HOST_TCP_SMTP",      "mailhost",
13                                            "A host providing an STMP Service (a mail server)");
15 my $host_tcp_imap      = getTestParameter( "host_tcp_imap",      "NP_HOST_TCP_IMAP",      $host_tcp_smtp,
16                                            "A host providing an IMAP Service (a mail server)");
18 my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
19                                            "The hostname of system not responsive to network requests" );
21 my $hostname_invalid   = getTestParameter( "hostname_invalid",   "NP_HOSTNAME_INVALID",   "nosuchhost",
22                                            "An invalid (not known to DNS) hostname" );
24 my $t;
26 $t = NPTest->testCmd( "./check_imap $host_tcp_imap" );
27 cmp_ok( $t->return_code, '==', 0, "Contacted imap" );
29 $t = NPTest->testCmd( "./check_imap -H $host_tcp_imap -p 143 -w 9 -c 9 -to 10 -e '* OK'" );
30 cmp_ok( $t->return_code, '==', 0, "Got right response" );
32 $t = NPTest->testCmd( "./check_imap $host_tcp_imap -p 143 -wt 9 -ct 9 -to 10 -e '* OK'" );
33 cmp_ok( $t->return_code, '==', 0, "Check old parameter options" );
35 $t = NPTest->testCmd( "./check_imap $host_nonresponsive" );
36 cmp_ok( $t->return_code, '==', 2, "Get error with non reponsive host" );
38 $t = NPTest->testCmd( "./check_imap $hostname_invalid" );
39 cmp_ok( $t->return_code, '==', 2, "Invalid hostname" );
41 $t = NPTest->testCmd( "./check_imap -H $host_tcp_imap -e unlikely_string");
42 cmp_ok( $t->return_code, '==', 1, "Got warning with bad response" );
44 $t = NPTest->testCmd( "./check_imap -H $host_tcp_imap -e unlikely_string -M crit");
45 cmp_ok( $t->return_code, '==', 2, "Got critical error with bad response" );