summaryrefslogtreecommitdiffstats
path: root/plugins/tests
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/tests')
-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) {
28 #print "child\n"; 28 #print "child\n";
29 29
30 my $d = HTTP::Daemon->new( 30 my $d = HTTP::Daemon->new(
31 LocalPort => $port 31 LocalPort => $port,
32 LocalAddr => "127.0.0.1",
32 ) || die; 33 ) || die;
33 print "Please contact me at: <URL:", $d->url, ">\n"; 34 print "Please contact me at: <URL:", $d->url, ">\n";
34 while (my $c = $d->accept ) { 35 while (my $c = $d->accept ) {
@@ -57,6 +58,12 @@ if ($pid) {
57 $c->send_basic_header; 58 $c->send_basic_header;
58 $c->send_crlf; 59 $c->send_crlf;
59 $c->send_response($r->method.":".$r->content); 60 $c->send_response($r->method.":".$r->content);
61 } elsif ($r->url->path eq "/redirect") {
62 $c->send_redirect( "/redirect2" );
63 } elsif ($r->url->path eq "/redirect2") {
64 $c->send_basic_header;
65 $c->send_crlf;
66 $c->send_response("redirected");
60 } else { 67 } else {
61 $c->send_error(RC_FORBIDDEN); 68 $c->send_error(RC_FORBIDDEN);
62 } 69 }
@@ -73,7 +80,7 @@ if ($ARGV[0] && $ARGV[0] eq "-d") {
73} 80}
74 81
75if (-x "./check_http") { 82if (-x "./check_http") {
76 plan tests => 39; 83 plan tests => 47;
77} else { 84} else {
78 plan skip_all => "No check_http compiled"; 85 plan skip_all => "No check_http compiled";
79} 86}
@@ -180,3 +187,23 @@ $result = NPTest->testCmd( $cmd );
180is( $result->return_code, 0, $cmd); 187is( $result->return_code, 0, $cmd);
181like( $result->output, '/^HTTP OK HTTP/1.1 200 OK - ([\d\.]+) second/', "Output correct: ".$result->output ); 188like( $result->output, '/^HTTP OK HTTP/1.1 200 OK - ([\d\.]+) second/', "Output correct: ".$result->output );
182 189
190$cmd = "$command -u /redirect";
191$result = NPTest->testCmd( $cmd );
192is( $result->return_code, 0, $cmd);
193like( $result->output, '/^HTTP OK - HTTP/1.1 301 Moved Permanently - [\d\.]+ second/', "Output correct: ".$result->output );
194
195$cmd = "$command -f follow -u /redirect";
196$result = NPTest->testCmd( $cmd );
197is( $result->return_code, 0, $cmd);
198like( $result->output, '/^HTTP OK HTTP/1.1 200 OK - 183 bytes in [\d\.]+ second/', "Output correct: ".$result->output );
199
200$cmd = "$command -u /redirect -k 'follow: me'";
201$result = NPTest->testCmd( $cmd );
202is( $result->return_code, 0, $cmd);
203like( $result->output, '/^HTTP OK - HTTP/1.1 301 Moved Permanently - [\d\.]+ second/', "Output correct: ".$result->output );
204
205$cmd = "$command -f follow -u /redirect -k 'follow: me'";
206$result = NPTest->testCmd( $cmd );
207is( $result->return_code, 0, $cmd);
208like( $result->output, '/^HTTP OK HTTP/1.1 200 OK - 183 bytes in [\d\.]+ second/', "Output correct: ".$result->output );
209