summaryrefslogtreecommitdiffstats
path: root/plugins/t
diff options
context:
space:
mode:
authorMatthias Eble <psychotrahe@users.sourceforge.net>2007-04-01 14:21:09 (GMT)
committerMatthias Eble <psychotrahe@users.sourceforge.net>2007-04-01 14:21:09 (GMT)
commit0ab3f7be5dca0265bf7816acbb8dd039a2ec99c4 (patch)
tree05aae4874e47eae3f6a6f9d88c85ad4324b64785 /plugins/t
parent5e7c9821be3aac6a76e701d78be6c578c80870ab (diff)
downloadmonitoring-plugins-0ab3f7be5dca0265bf7816acbb8dd039a2ec99c4.tar.gz
check_http.t: - added internet_access variable to skip tests where internet access is required.
- added host_tcp_http2 variable for a webserver serving the string 'nagios' in index - no tests are skipped if the new vars are not defined (existing installations) git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1669 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/t')
-rw-r--r--plugins/t/check_http.t94
1 files changed, 58 insertions, 36 deletions
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t
index 5b67886..3ecc0ac 100644
--- a/plugins/t/check_http.t
+++ b/plugins/t/check_http.t
@@ -27,6 +27,18 @@ my $hostname_invalid = getTestParameter( "NP_HOSTNAME_INVALID",
27 "An invalid (not known to DNS) hostname", 27 "An invalid (not known to DNS) hostname",
28 "nosuchhost"); 28 "nosuchhost");
29 29
30my $internet_access = getTestParameter( "NP_INTERNET_ACCESS",
31 "Is this system directly connected to the internet?",
32 "yes");
33
34my $host_tcp_http2;
35if ($internet_access eq "no") {
36 $host_tcp_http2 = getTestParameter( "NP_HOST_TCP_HTTP2",
37 "A host providing an index page containing the string 'nagios'",
38 "altinity.com" );
39}
40
41
30$res = NPTest->testCmd( 42$res = NPTest->testCmd(
31 "./check_http $host_tcp_http -wt 300 -ct 600" 43 "./check_http $host_tcp_http -wt 300 -ct 600"
32 ); 44 );
@@ -58,52 +70,62 @@ cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" );
58# Is also possible to get a socket timeout if DNS is not responding fast enough 70# Is also possible to get a socket timeout if DNS is not responding fast enough
59like( $res->output, "/Unable to open TCP socket|Socket timeout after/", "Output OK"); 71like( $res->output, "/Unable to open TCP socket|Socket timeout after/", "Output OK");
60 72
61$res = NPTest->testCmd( 73SKIP: {
62 "./check_http --ssl www.verisign.com" 74 skip "No internet access and no host serving nagios in index file",
63 ); 75 7 if $internet_access eq "no" && ! $host_tcp_http2;
64cmp_ok( $res->return_code, '==', 0, "Can read https for www.verisign.com" );
65 76
66$res = NPTest->testCmd( "./check_http -C 1 --ssl www.verisign.com" ); 77 $host_tcp_http2 = "altinity.com" if (! $host_tcp_http2);
67cmp_ok( $res->return_code, '==', 0, "Checking certificate for www.verisign.com");
68like ( $res->output, '/Certificate will expire on/', "Output OK" );
69my $saved_cert_output = $res->output;
70 78
71$res = NPTest->testCmd( "./check_http www.verisign.com -C 1" ); 79 $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'nagios'" );
72is( $res->return_code, 0, "Old syntax for cert checking okay" ); 80 cmp_ok( $res->return_code, "==", 0, "Got a reference to 'nagios'");
73is( $res->output, $saved_cert_output, "Same output as new syntax" );
74 81
75$res = NPTest->testCmd( "./check_http -H www.verisign.com -C 1" ); 82 $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'nAGiOs'" );
76is( $res->return_code, 0, "Updated syntax for cert checking okay" ); 83 cmp_ok( $res->return_code, "==", 2, "Not got 'nAGiOs'");
77is( $res->output, $saved_cert_output, "Same output as new syntax" ); 84 like ( $res->output, "/pattern not found/", "Error message says 'pattern not found'");
78 85
79$res = NPTest->testCmd( "./check_http -C 1 www.verisign.com" ); 86 $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -R 'nAGiOs'" );
80cmp_ok( $res->output, 'eq', $saved_cert_output, "--ssl option automatically added"); 87 cmp_ok( $res->return_code, "==", 0, "But case insensitive doesn't mind 'nAGiOs'");
81 88
82$res = NPTest->testCmd( "./check_http www.verisign.com -C 1" ); 89 $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'nagios' --invert-regex" );
83cmp_ok( $res->output, 'eq', $saved_cert_output, "Old syntax for cert checking still works"); 90 cmp_ok( $res->return_code, "==", 2, "Invert results work when found");
91 like ( $res->output, "/pattern found/", "Error message says 'pattern found'");
84 92
85$res = NPTest->testCmd( 93 $res = NPTest->testCmd( "./check_http -H $host_tcp_http2 -r 'nAGiOs' --invert-regex" );
86 "./check_http --ssl www.e-paycobalt.com" 94 cmp_ok( $res->return_code, "==", 0, "And also when not found");
87 ); 95}
88cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" ); 96SKIP: {
97 skip "No internet access", 11 if $internet_access eq "no";
98
99 $res = NPTest->testCmd(
100 "./check_http --ssl www.verisign.com"
101 );
102 cmp_ok( $res->return_code, '==', 0, "Can read https for www.verisign.com" );
103
104 $res = NPTest->testCmd( "./check_http -C 1 --ssl www.verisign.com" );
105 cmp_ok( $res->return_code, '==', 0, "Checking certificate for www.verisign.com");
106 like ( $res->output, '/Certificate will expire on/', "Output OK" );
107 my $saved_cert_output = $res->output;
89 108
90$res = NPTest->testCmd( "./check_http -H altinity.com -r 'nagios'" ); 109 $res = NPTest->testCmd( "./check_http www.verisign.com -C 1" );
91cmp_ok( $res->return_code, "==", 0, "Got a reference to 'nagios'"); 110 is( $res->return_code, 0, "Old syntax for cert checking okay" );
111 is( $res->output, $saved_cert_output, "Same output as new syntax" );
92 112
93$res = NPTest->testCmd( "./check_http -H altinity.com -r 'nAGiOs'" ); 113 $res = NPTest->testCmd( "./check_http -H www.verisign.com -C 1" );
94cmp_ok( $res->return_code, "==", 2, "Not got 'nAGiOs'"); 114 is( $res->return_code, 0, "Updated syntax for cert checking okay" );
95like ( $res->output, "/pattern not found/", "Error message says 'pattern not found'"); 115 is( $res->output, $saved_cert_output, "Same output as new syntax" );
96 116
97$res = NPTest->testCmd( "./check_http -H altinity.com -R 'nAGiOs'" ); 117 $res = NPTest->testCmd( "./check_http -C 1 www.verisign.com" );
98cmp_ok( $res->return_code, "==", 0, "But case insensitive doesn't mind 'nAGiOs'"); 118 cmp_ok( $res->output, 'eq', $saved_cert_output, "--ssl option automatically added");
99 119
100$res = NPTest->testCmd( "./check_http -H altinity.com -r 'nagios' --invert-regex" ); 120 $res = NPTest->testCmd( "./check_http www.verisign.com -C 1" );
101cmp_ok( $res->return_code, "==", 2, "Invert results work when found"); 121 cmp_ok( $res->output, 'eq', $saved_cert_output, "Old syntax for cert checking still works");
102like ( $res->output, "/pattern found/", "Error message says 'pattern found'");
103 122
104$res = NPTest->testCmd( "./check_http -H altinity.com -r 'nAGiOs' --invert-regex" ); 123 $res = NPTest->testCmd(
105cmp_ok( $res->return_code, "==", 0, "And also when not found"); 124 "./check_http --ssl www.e-paycobalt.com"
125 );
126 cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" );
106 127
107$res = NPTest->testCmd( "./check_http -H www.mozilla.com -u /firefox -f follow" );
108is( $res->return_code, 0, "Redirection based on location is okay");
109 128
129 $res = NPTest->testCmd( "./check_http -H www.mozilla.com -u /firefox -f follow" );
130 is( $res->return_code, 0, "Redirection based on location is okay");
131}