diff options
| author | Sven Nierlein <sven@nierlein.de> | 2022-12-22 14:58:01 +0100 |
|---|---|---|
| committer | Sven Nierlein <sven@nierlein.org> | 2023-01-07 18:34:46 +0100 |
| commit | 07561a67abb02688955433db5b4a38b23523a754 (patch) | |
| tree | 7a2dd12a4db03132e79d8fbf6a8ae7e25c3985b3 /plugins/tests | |
| parent | c256af44fb23a4749faa5f3fce167a9d9a4367d7 (diff) | |
| download | monitoring-plugins-07561a67abb02688955433db5b4a38b23523a754.tar.gz | |
tests: fix chunked encoding test server
Diffstat (limited to 'plugins/tests')
| -rwxr-xr-x | plugins/tests/check_curl.t | 29 | ||||
| -rwxr-xr-x | plugins/tests/check_http.t | 7 |
2 files changed, 16 insertions, 20 deletions
diff --git a/plugins/tests/check_curl.t b/plugins/tests/check_curl.t index 86bfb538..72f2b7c2 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 | ||
| 24 | my $common_tests = 74; | 24 | my $common_tests = 73; |
| 25 | my $ssl_only_tests = 8; | 25 | my $ssl_only_tests = 8; |
| 26 | # Check that all dependent modules are available | 26 | # Check that all dependent modules are available |
| 27 | eval "use HTTP::Daemon 6.01;"; | 27 | eval "use HTTP::Daemon 6.01;"; |
| @@ -200,17 +200,14 @@ sub run_server { | |||
| 200 | $c->send_basic_header; | 200 | $c->send_basic_header; |
| 201 | $c->send_crlf; | 201 | $c->send_crlf; |
| 202 | $c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host'))); | 202 | $c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host'))); |
| 203 | } elsif ($r->url->path eq "/chunked") { | 203 | } elsif ($r->url->path eq "/chunked") { |
| 204 | $c->send_basic_header; | 204 | my $chunks = ["chunked", "encoding", "test\n"]; |
| 205 | $c->send_header('Transfer-Encoding', "chunked"); | 205 | $c->send_response(HTTP::Response->new( 200, 'OK', undef, sub { |
| 206 | $c->send_crlf; | 206 | my $chunk = shift @{$chunks}; |
| 207 | my $chunks = ["chunked", "encoding", "test\n"]; | 207 | return unless $chunk; |
| 208 | $c->send_response(HTTP::Response->new( 200, 'OK', undef, sub { | 208 | sleep(1); |
| 209 | my $chunk = shift @{$chunks}; | 209 | return($chunk); |
| 210 | return unless $chunk; | 210 | })); |
| 211 | sleep(1); | ||
| 212 | return($chunk); | ||
| 213 | })); | ||
| 214 | } else { | 211 | } else { |
| 215 | $c->send_error(HTTP::Status->RC_FORBIDDEN); | 212 | $c->send_error(HTTP::Status->RC_FORBIDDEN); |
| 216 | } | 213 | } |
| @@ -483,7 +480,8 @@ sub run_common_tests { | |||
| 483 | local $SIG{ALRM} = sub { die "alarm\n" }; | 480 | local $SIG{ALRM} = sub { die "alarm\n" }; |
| 484 | alarm(2); | 481 | alarm(2); |
| 485 | $result = NPTest->testCmd( $cmd ); | 482 | $result = NPTest->testCmd( $cmd ); |
| 486 | alarm(0); }; | 483 | }; |
| 484 | alarm(0); | ||
| 487 | isnt( $@, "alarm\n", $cmd ); | 485 | isnt( $@, "alarm\n", $cmd ); |
| 488 | is( $result->return_code, 0, $cmd ); | 486 | is( $result->return_code, 0, $cmd ); |
| 489 | 487 | ||
| @@ -493,7 +491,8 @@ sub run_common_tests { | |||
| 493 | local $SIG{ALRM} = sub { die "alarm\n" }; | 491 | local $SIG{ALRM} = sub { die "alarm\n" }; |
| 494 | alarm(2); | 492 | alarm(2); |
| 495 | $result = NPTest->testCmd( $cmd ); | 493 | $result = NPTest->testCmd( $cmd ); |
| 496 | alarm(0); }; | 494 | }; |
| 495 | alarm(0); | ||
| 497 | isnt( $@, "alarm\n", $cmd ); | 496 | isnt( $@, "alarm\n", $cmd ); |
| 498 | isnt( $result->return_code, 0, $cmd ); | 497 | isnt( $result->return_code, 0, $cmd ); |
| 499 | 498 | ||
| @@ -519,7 +518,7 @@ sub run_common_tests { | |||
| 519 | }; | 518 | }; |
| 520 | is( $@, "", $cmd ); | 519 | is( $@, "", $cmd ); |
| 521 | 520 | ||
| 522 | $cmd = "$command -u /chunked -s 'chunkedencodingtest'"; | 521 | $cmd = "$command -u /chunked -s 'chunkedencodingtest' -d 'Transfer-Encoding: chunked'"; |
| 523 | eval { | 522 | eval { |
| 524 | $result = NPTest->testCmd( $cmd, 5 ); | 523 | $result = NPTest->testCmd( $cmd, 5 ); |
| 525 | }; | 524 | }; |
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t index 132c6659..d766ac37 100755 --- a/plugins/tests/check_http.t +++ b/plugins/tests/check_http.t | |||
| @@ -12,7 +12,7 @@ use FindBin qw($Bin); | |||
| 12 | 12 | ||
| 13 | $ENV{'LC_TIME'} = "C"; | 13 | $ENV{'LC_TIME'} = "C"; |
| 14 | 14 | ||
| 15 | my $common_tests = 72; | 15 | my $common_tests = 71; |
| 16 | my $virtual_port_tests = 8; | 16 | my $virtual_port_tests = 8; |
| 17 | my $ssl_only_tests = 12; | 17 | my $ssl_only_tests = 12; |
| 18 | # Check that all dependent modules are available | 18 | # Check that all dependent modules are available |
| @@ -191,9 +191,6 @@ sub run_server { | |||
| 191 | $c->send_crlf; | 191 | $c->send_crlf; |
| 192 | $c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host'))); | 192 | $c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host'))); |
| 193 | } elsif ($r->url->path eq "/chunked") { | 193 | } elsif ($r->url->path eq "/chunked") { |
| 194 | $c->send_basic_header; | ||
| 195 | $c->send_header('Transfer-Encoding', "chunked"); | ||
| 196 | $c->send_crlf; | ||
| 197 | my $chunks = ["chunked", "encoding", "test\n"]; | 194 | my $chunks = ["chunked", "encoding", "test\n"]; |
| 198 | $c->send_response(HTTP::Response->new( 200, 'OK', undef, sub { | 195 | $c->send_response(HTTP::Response->new( 200, 'OK', undef, sub { |
| 199 | my $chunk = shift @{$chunks}; | 196 | my $chunk = shift @{$chunks}; |
| @@ -508,7 +505,7 @@ sub run_common_tests { | |||
| 508 | }; | 505 | }; |
| 509 | is( $@, "", $cmd ); | 506 | is( $@, "", $cmd ); |
| 510 | 507 | ||
| 511 | $cmd = "$command -u /chunked -s 'chunkedencodingtest'"; | 508 | $cmd = "$command -u /chunked -s 'chunkedencodingtest' -d 'Transfer-Encoding: chunked'"; |
| 512 | eval { | 509 | eval { |
| 513 | $result = NPTest->testCmd( $cmd, 5 ); | 510 | $result = NPTest->testCmd( $cmd, 5 ); |
| 514 | }; | 511 | }; |
