aboutsummaryrefslogtreecommitdiff
path: root/plugins/t/check_http.t
diff options
context:
space:
mode:
authorGravatar Sven Nierlein <sven@nierlein.de> 2016-11-11 10:32:19 +0100
committerGravatar Sven Nierlein <sven@nierlein.de> 2016-11-11 10:32:19 +0100
commit9e02d0c3e6cc4c2cf08140dcff50fb280315bfc8 (patch)
tree4a92931af41c3b38e037c6d023dd379041465411 /plugins/t/check_http.t
parente11823090308cb278fd0a32f3d07a8ee20e5ec2c (diff)
downloadmonitoring-plugins-9e02d0c3e6cc4c2cf08140dcff50fb280315bfc8.tar.gz
check_http: add host header tests
Signed-off-by: Sven Nierlein <sven@nierlein.de>
Diffstat (limited to 'plugins/t/check_http.t')
-rw-r--r--plugins/t/check_http.t28
1 files changed, 27 insertions, 1 deletions
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t
index f514ca6f..5a90f02a 100644
--- a/plugins/t/check_http.t
+++ b/plugins/t/check_http.t
@@ -9,7 +9,7 @@ use Test::More;
use POSIX qw/mktime strftime/;
use NPTest;
-plan tests => 42;
+plan tests => 49;
my $successOutput = '/OK.*HTTP.*second/';
@@ -64,6 +64,32 @@ cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" );
# Is also possible to get a socket timeout if DNS is not responding fast enough
like( $res->output, "/Unable to open TCP socket|Socket timeout after/", "Output OK");
+# host header checks
+$res = NPTest->testCmd("./check_http -v -H $host_tcp_http");
+like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" );
+
+$res = NPTest->testCmd("./check_http -v -H $host_tcp_http -p 80");
+like( $res->output, '/^Host: '.$host_tcp_http.'\s*$/ms', "Host Header OK" );
+
+$res = NPTest->testCmd("./check_http -v -H $host_tcp_http:8080 -p 80");
+like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" );
+
+$res = NPTest->testCmd("./check_http -v -H $host_tcp_http:8080 -p 80");
+like( $res->output, '/^Host: '.$host_tcp_http.':8080\s*$/ms', "Host Header OK" );
+
+SKIP: {
+ skip "No internet access", 3 if $internet_access eq "no";
+
+ $res = NPTest->testCmd("./check_http -v -H www.verisign.com -S");
+ like( $res->output, '/^Host: www.verisign.com\s*$/ms', "Host Header OK" );
+
+ $res = NPTest->testCmd("./check_http -v -H www.verisign.com:8080 -S -p 443");
+ like( $res->output, '/^Host: www.verisign.com:8080\s*$/ms', "Host Header OK" );
+
+ $res = NPTest->testCmd("./check_http -v -H www.verisign.com:443 -S -p 443");
+ like( $res->output, '/^Host: www.verisign.com\s*$/ms', "Host Header OK" );
+};
+
SKIP: {
skip "No host serving monitoring in index file", 7 unless $host_tcp_http2;