Code

check_http: check for and print the certificate cn
[nagiosplug.git] / plugins / t / check_hpjd.t
1 #! /usr/bin/perl -w -I ..
2 #
3 # HP JetDirect Test via check_hpjd
4 #
5 #
7 use strict;
8 use Test::More;
9 use NPTest;
11 plan skip_all => "check_hpjd not compiled" unless (-x "check_hpjd");
13 plan tests => 5;
15 my $successOutput = '/^Printer ok - /';
16 my $failureOutput = '/Timeout: No [Rr]esponse from /';
18 my $host_tcp_hpjd = getTestParameter( 
19                         "NP_HOST_TCP_HPJD",
20                         "A host (usually a printer) providing the HP-JetDirect Services"
21                         );
23 my $host_nonresponsive = getTestParameter( 
24                         "NP_HOST_NONRESPONSIVE",
25                         "The hostname of system not responsive to network requests",
26                         "10.0.0.1",
27                         );
29 my $hostname_invalid = getTestParameter( 
30                         "NP_HOSTNAME_INVALID",
31                         "An invalid (not known to DNS) hostname",
32                         "nosuchhost",
33                         );
35 my $res;
37 SKIP: {
38         skip "No HP JetDirect defined", 2 unless $host_tcp_hpjd;
39         $res = NPTest->testCmd("./check_hpjd $host_tcp_hpjd");
40         cmp_ok( $res->return_code, '==', 0, "Jetdirect responding" );
41         like  ( $res->output, $successOutput, "Output correct" );
42 }
44 $res = NPTest->testCmd("./check_hpjd $host_nonresponsive");
45 cmp_ok( $res->return_code, 'eq', 2, "Host not responding");
46 like  ( $res->output, $failureOutput, "Output OK" );
48 $res = NPTest->testCmd("./check_hpjd $hostname_invalid");
49 cmp_ok( $res->return_code, 'eq', 3, "Hostname invalid");