summaryrefslogtreecommitdiffstats
path: root/plugins/tests/check_curl.t
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/tests/check_curl.t')
-rwxr-xr-xplugins/tests/check_curl.t21
1 files changed, 16 insertions, 5 deletions
diff --git a/plugins/tests/check_curl.t b/plugins/tests/check_curl.t
index 1afbe4b..29cb03f 100755
--- a/plugins/tests/check_curl.t
+++ b/plugins/tests/check_curl.t
@@ -21,7 +21,7 @@ use FindBin qw($Bin);
21 21
22$ENV{'LC_TIME'} = "C"; 22$ENV{'LC_TIME'} = "C";
23 23
24my $common_tests = 70; 24my $common_tests = 72;
25my $ssl_only_tests = 8; 25my $ssl_only_tests = 8;
26# Check that all dependent modules are available 26# Check that all dependent modules are available
27eval "use HTTP::Daemon 6.01;"; 27eval "use HTTP::Daemon 6.01;";
@@ -126,8 +126,6 @@ if ($pid) {
126 exit; 126 exit;
127 } 127 }
128 } 128 }
129 # give our webservers some time to startup
130 sleep(1);
131} else { 129} else {
132 # Child 130 # Child
133 #print "child\n"; 131 #print "child\n";
@@ -140,6 +138,9 @@ if ($pid) {
140 exit; 138 exit;
141} 139}
142 140
141# give our webservers some time to startup
142sleep(3);
143
143# Run the same server on http and https 144# Run the same server on http and https
144sub run_server { 145sub run_server {
145 my $d = shift; 146 my $d = shift;
@@ -188,6 +189,12 @@ sub run_server {
188 $c->send_basic_header; 189 $c->send_basic_header;
189 $c->send_header('foo'); 190 $c->send_header('foo');
190 $c->send_crlf; 191 $c->send_crlf;
192 } elsif ($r->url->path eq "/header_broken_check") {
193 $c->send_basic_header;
194 $c->send_header('foo');
195 print $c "Test1:: broken\n";
196 print $c " Test2: leading whitespace\n";
197 $c->send_crlf;
191 } elsif ($r->url->path eq "/virtual_port") { 198 } elsif ($r->url->path eq "/virtual_port") {
192 # return sent Host header 199 # return sent Host header
193 $c->send_basic_header; 200 $c->send_basic_header;
@@ -247,7 +254,7 @@ my $cmd;
247# advanced checks with virtual hostname and virtual port 254# advanced checks with virtual hostname and virtual port
248SKIP: { 255SKIP: {
249 skip "libcurl version is smaller than $required_version", 6 unless $use_advanced_checks; 256 skip "libcurl version is smaller than $required_version", 6 unless $use_advanced_checks;
250 257
251 # http without virtual port 258 # http without virtual port
252 $cmd = "./$plugin -H $virtual_host -I 127.0.0.1 -p $port_http -u /virtual_port -r ^$virtual_host:$port_http\$"; 259 $cmd = "./$plugin -H $virtual_host -I 127.0.0.1 -p $port_http -u /virtual_port -r ^$virtual_host:$port_http\$";
253 $result = NPTest->testCmd( $cmd ); 260 $result = NPTest->testCmd( $cmd );
@@ -259,7 +266,7 @@ SKIP: {
259 $result = NPTest->testCmd( $cmd ); 266 $result = NPTest->testCmd( $cmd );
260 is( $result->return_code, 0, $cmd); 267 is( $result->return_code, 0, $cmd);
261 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); 268 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output );
262 269
263 # http with virtual port (80) 270 # http with virtual port (80)
264 $cmd = "./$plugin -H $virtual_host:80 -I 127.0.0.1 -p $port_http -u /virtual_port -r ^$virtual_host\$"; 271 $cmd = "./$plugin -H $virtual_host:80 -I 127.0.0.1 -p $port_http -u /virtual_port -r ^$virtual_host\$";
265 $result = NPTest->testCmd( $cmd ); 272 $result = NPTest->testCmd( $cmd );
@@ -321,6 +328,10 @@ sub run_common_tests {
321 is( $result->return_code, 2, "Missing header string check"); 328 is( $result->return_code, 2, "Missing header string check");
322 like( $result->output, qr%^HTTP CRITICAL: HTTP/1\.1 200 OK - header 'bar' not found on 'https?://127\.0\.0\.1:\d+/header_check'%, "Shows search string and location"); 329 like( $result->output, qr%^HTTP CRITICAL: HTTP/1\.1 200 OK - header 'bar' not found on 'https?://127\.0\.0\.1:\d+/header_check'%, "Shows search string and location");
323 330
331 $result = NPTest->testCmd( "$command -u /header_broken_check" );
332 is( $result->return_code, 0, "header_check search for string");
333 like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - 138 bytes in [\d\.]+ second/', "Output correct" );
334
324 my $cmd; 335 my $cmd;
325 $cmd = "$command -u /slow"; 336 $cmd = "$command -u /slow";
326 $result = NPTest->testCmd( $cmd ); 337 $result = NPTest->testCmd( $cmd );