summaryrefslogtreecommitdiffstats
path: root/plugins/t/check_http.t
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/t/check_http.t')
-rw-r--r--plugins/t/check_http.t34
1 files changed, 30 insertions, 4 deletions
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t
index c2caec60..5a90f02a 100644
--- a/plugins/t/check_http.t
+++ b/plugins/t/check_http.t
@@ -9,7 +9,7 @@ use Test::More;
9use POSIX qw/mktime strftime/; 9use POSIX qw/mktime strftime/;
10use NPTest; 10use NPTest;
11 11
12plan tests => 42; 12plan tests => 49;
13 13
14my $successOutput = '/OK.*HTTP.*second/'; 14my $successOutput = '/OK.*HTTP.*second/';
15 15
@@ -64,6 +64,32 @@ cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" );
64# Is also possible to get a socket timeout if DNS is not responding fast enough 64# Is also possible to get a socket timeout if DNS is not responding fast enough
65like( $res->output, "/Unable to open TCP socket|Socket timeout after/", "Output OK"); 65like( $res->output, "/Unable to open TCP socket|Socket timeout after/", "Output OK");
66 66
67# host header checks
68$res = NPTest->testCmd("./check_http -v -H $host_tcp_http");
69like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" );
70
71$res = NPTest->testCmd("./check_http -v -H $host_tcp_http -p 80");
72like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" );
73
74$res = NPTest->testCmd("./check_http -v -H $host_tcp_http:8080 -p 80");
75like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" );
76
77$res = NPTest->testCmd("./check_http -v -H $host_tcp_http:8080 -p 80");
78like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" );
79
80SKIP: {
81 skip "No internet access", 3 if $internet_access eq "no";
82
83 $res = NPTest->testCmd("./check_http -v -H www.verisign.com -S");
84 like( $res->output, '/^Host: www.verisign.com\s*$/ms', "Host Header OK" );
85
86 $res = NPTest->testCmd("./check_http -v -H www.verisign.com:8080 -S -p 443");
87 like( $res->output, '/^Host: www.verisign.com:8080\s*$/ms', "Host Header OK" );
88
89 $res = NPTest->testCmd("./check_http -v -H www.verisign.com:443 -S -p 443");
90 like( $res->output, '/^Host: www.verisign.com\s*$/ms', "Host Header OK" );
91};
92
67SKIP: { 93SKIP: {
68 skip "No host serving monitoring in index file", 7 unless $host_tcp_http2; 94 skip "No host serving monitoring in index file", 7 unless $host_tcp_http2;
69 95
@@ -121,9 +147,9 @@ SKIP: {
121 $res = NPTest->testCmd("LC_TIME=C TZ=UTC ./check_http -C 1 www.verisign.com"); 147 $res = NPTest->testCmd("LC_TIME=C TZ=UTC ./check_http -C 1 www.verisign.com");
122 like($res->output, qr/OK - Certificate 'www.verisign.com' will expire on/, "Catch cert output"); 148 like($res->output, qr/OK - Certificate 'www.verisign.com' will expire on/, "Catch cert output");
123 is( $res->return_code, 0, "Catch cert output exit code" ); 149 is( $res->return_code, 0, "Catch cert output exit code" );
124 my($mon,$day,$hour,$min,$sec,$year) = ($res->output =~ /(\w+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\d+)\./); 150 my($mon,$day,$hour,$min,$sec,$year) = ($res->output =~ /(\w+)\s+(\d+)\s+(\d+):(\d+):(\d+)\s+(\d+)/);
125 if(!defined $year) { 151 if(!defined $year) {
126 die("parsing date failed from: ".$res); 152 die("parsing date failed from: ".$res->output);
127 } 153 }
128 my $months = {'Jan' => 0, 'Feb' => 1, 'Mar' => 2, 'Apr' => 3, 'May' => 4, 'Jun' => 5, 'Jul' => 6, 'Aug' => 7, 'Sep' => 8, 'Oct' => 9, 'Nov' => 10, 'Dec' => 11}; 154 my $months = {'Jan' => 0, 'Feb' => 1, 'Mar' => 2, 'Apr' => 3, 'May' => 4, 'Jun' => 5, 'Jul' => 6, 'Aug' => 7, 'Sep' => 8, 'Oct' => 9, 'Nov' => 10, 'Dec' => 11};
129 my $ts = mktime($sec, $min, $hour, $day, $months->{$mon}, $year-1900); 155 my $ts = mktime($sec, $min, $hour, $day, $months->{$mon}, $year-1900);
@@ -154,7 +180,7 @@ SKIP: {
154 like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); 180 like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' );
155 181
156 $res = NPTest->testCmd( 182 $res = NPTest->testCmd(
157 "./check_http --ssl www.e-paycobalt.com" 183 "./check_http --ssl -H www.e-paycobalt.com"
158 ); 184 );
159 cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" ); 185 cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" );
160 186