diff options
Diffstat (limited to 'plugins/tests')
-rwxr-xr-x | plugins/tests/check_curl.t | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/plugins/tests/check_curl.t b/plugins/tests/check_curl.t index 702edb8..28dacd0 100755 --- a/plugins/tests/check_curl.t +++ b/plugins/tests/check_curl.t | |||
@@ -20,6 +20,7 @@ use FindBin qw($Bin); | |||
20 | $ENV{'LC_TIME'} = "C"; | 20 | $ENV{'LC_TIME'} = "C"; |
21 | 21 | ||
22 | my $common_tests = 70; | 22 | my $common_tests = 70; |
23 | my $virtual_port_tests = 8; | ||
23 | my $ssl_only_tests = 8; | 24 | my $ssl_only_tests = 8; |
24 | # Check that all dependent modules are available | 25 | # Check that all dependent modules are available |
25 | eval "use HTTP::Daemon 6.01;"; | 26 | eval "use HTTP::Daemon 6.01;"; |
@@ -36,7 +37,7 @@ if ($@) { | |||
36 | plan skip_all => "Missing required module for test: $@"; | 37 | plan skip_all => "Missing required module for test: $@"; |
37 | } else { | 38 | } else { |
38 | if (-x "./$plugin") { | 39 | if (-x "./$plugin") { |
39 | plan tests => $common_tests * 2 + $ssl_only_tests; | 40 | plan tests => $common_tests * 2 + $ssl_only_tests + $virtual_port_tests; |
40 | } else { | 41 | } else { |
41 | plan skip_all => "No $plugin compiled"; | 42 | plan skip_all => "No $plugin compiled"; |
42 | } | 43 | } |
@@ -161,6 +162,11 @@ sub run_server { | |||
161 | $c->send_basic_header; | 162 | $c->send_basic_header; |
162 | $c->send_header('foo'); | 163 | $c->send_header('foo'); |
163 | $c->send_crlf; | 164 | $c->send_crlf; |
165 | } elsif ($r->url->path eq "/virtual_port") { | ||
166 | # return sent Host header | ||
167 | $c->send_basic_header; | ||
168 | $c->send_crlf; | ||
169 | $c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host'))); | ||
164 | } else { | 170 | } else { |
165 | $c->send_error(HTTP::Status->RC_FORBIDDEN); | 171 | $c->send_error(HTTP::Status->RC_FORBIDDEN); |
166 | } | 172 | } |
@@ -210,6 +216,37 @@ SKIP: { | |||
210 | 216 | ||
211 | } | 217 | } |
212 | 218 | ||
219 | my $cmd; | ||
220 | # check virtual port behaviour | ||
221 | # | ||
222 | # http without virtual port | ||
223 | $cmd = "$command -p $port_http -u /virtual_port -r ^127.0.0.1:$port_http\$"; | ||
224 | $result = NPTest->testCmd( $cmd ); | ||
225 | is( $result->return_code, 0, $cmd); | ||
226 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
227 | |||
228 | # http with virtual port | ||
229 | $cmd = "$command:80 -p $port_http -u /virtual_port -r ^127.0.0.1\$"; | ||
230 | $result = NPTest->testCmd( $cmd ); | ||
231 | is( $result->return_code, 0, $cmd); | ||
232 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
233 | |||
234 | SKIP: { | ||
235 | skip "HTTP::Daemon::SSL not installed", 4 if ! exists $servers->{https}; | ||
236 | # https without virtual port | ||
237 | $cmd = "$command -p $port_https --ssl -u /virtual_port -r ^127.0.0.1:$port_https\$"; | ||
238 | $result = NPTest->testCmd( $cmd ); | ||
239 | is( $result->return_code, 0, $cmd); | ||
240 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
241 | |||
242 | # https with virtual port | ||
243 | $cmd = "$command:443 -p $port_https --ssl -u /virtual_port -r ^127.0.0.1\$"; | ||
244 | $result = NPTest->testCmd( $cmd ); | ||
245 | is( $result->return_code, 0, $cmd); | ||
246 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
247 | } | ||
248 | |||
249 | |||
213 | sub run_common_tests { | 250 | sub run_common_tests { |
214 | my ($opts) = @_; | 251 | my ($opts) = @_; |
215 | my $command = $opts->{command}; | 252 | my $command = $opts->{command}; |
@@ -395,7 +432,7 @@ sub run_common_tests { | |||
395 | 432 | ||
396 | # Test an external address - timeout | 433 | # Test an external address - timeout |
397 | SKIP: { | 434 | SKIP: { |
398 | skip "This doesn't seems to work all the time", 1 unless ($ENV{HTTP_EXTERNAL}); | 435 | skip "This doesn't seem to work all the time", 1 unless ($ENV{HTTP_EXTERNAL}); |
399 | $cmd = "$command -f follow -u /redir_external -t 5"; | 436 | $cmd = "$command -f follow -u /redir_external -t 5"; |
400 | eval { | 437 | eval { |
401 | $result = NPTest->testCmd( $cmd, 2 ); | 438 | $result = NPTest->testCmd( $cmd, 2 ); |