aboutsummaryrefslogtreecommitdiff
path: root/plugins/tests/check_http.t
diff options
context:
space:
mode:
authorGravatar Ton Voon <tonvoon@users.sourceforge.net> 2008-11-08 02:32:03 +0000
committerGravatar Ton Voon <tonvoon@users.sourceforge.net> 2008-11-08 02:32:03 +0000
commit6c5f781bc58cef0a28ab2dbc7eeb1391df3ba009 (patch)
treeccc0cd52ce067193efecc1b4a05c9b86c5364a61 /plugins/tests/check_http.t
parent288b742ed61bb62a210fdd3614d4e3883aa82407 (diff)
downloadmonitoring-plugins-6c5f781bc58cef0a28ab2dbc7eeb1391df3ba009.tar.gz
Fixed bug where extra headers and redirect caused segfault (Dieter Van de Walle - 2089159)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2076 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/tests/check_http.t')
-rwxr-xr-xplugins/tests/check_http.t31
1 files changed, 29 insertions, 2 deletions
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t
index d54932e6..c5f90803 100755
--- a/plugins/tests/check_http.t
+++ b/plugins/tests/check_http.t
@@ -28,7 +28,8 @@ if ($pid) {
#print "child\n";
my $d = HTTP::Daemon->new(
- LocalPort => $port
+ LocalPort => $port,
+ LocalAddr => "127.0.0.1",
) || die;
print "Please contact me at: <URL:", $d->url, ">\n";
while (my $c = $d->accept ) {
@@ -57,6 +58,12 @@ if ($pid) {
$c->send_basic_header;
$c->send_crlf;
$c->send_response($r->method.":".$r->content);
+ } elsif ($r->url->path eq "/redirect") {
+ $c->send_redirect( "/redirect2" );
+ } elsif ($r->url->path eq "/redirect2") {
+ $c->send_basic_header;
+ $c->send_crlf;
+ $c->send_response("redirected");
} else {
$c->send_error(RC_FORBIDDEN);
}
@@ -73,7 +80,7 @@ if ($ARGV[0] && $ARGV[0] eq "-d") {
}
if (-x "./check_http") {
- plan tests => 39;
+ plan tests => 47;
} else {
plan skip_all => "No check_http compiled";
}
@@ -180,3 +187,23 @@ $result = NPTest->testCmd( $cmd );
is( $result->return_code, 0, $cmd);
like( $result->output, '/^HTTP OK HTTP/1.1 200 OK - ([\d\.]+) second/', "Output correct: ".$result->output );
+$cmd = "$command -u /redirect";
+$result = NPTest->testCmd( $cmd );
+is( $result->return_code, 0, $cmd);
+like( $result->output, '/^HTTP OK - HTTP/1.1 301 Moved Permanently - [\d\.]+ second/', "Output correct: ".$result->output );
+
+$cmd = "$command -f follow -u /redirect";
+$result = NPTest->testCmd( $cmd );
+is( $result->return_code, 0, $cmd);
+like( $result->output, '/^HTTP OK HTTP/1.1 200 OK - 183 bytes in [\d\.]+ second/', "Output correct: ".$result->output );
+
+$cmd = "$command -u /redirect -k 'follow: me'";
+$result = NPTest->testCmd( $cmd );
+is( $result->return_code, 0, $cmd);
+like( $result->output, '/^HTTP OK - HTTP/1.1 301 Moved Permanently - [\d\.]+ second/', "Output correct: ".$result->output );
+
+$cmd = "$command -f follow -u /redirect -k 'follow: me'";
+$result = NPTest->testCmd( $cmd );
+is( $result->return_code, 0, $cmd);
+like( $result->output, '/^HTTP OK HTTP/1.1 200 OK - 183 bytes in [\d\.]+ second/', "Output correct: ".$result->output );
+