diff options
Diffstat (limited to 'plugins/tests/check_http.t')
-rwxr-xr-x | plugins/tests/check_http.t | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t index f03933b..74eff17 100755 --- a/plugins/tests/check_http.t +++ b/plugins/tests/check_http.t | |||
@@ -18,9 +18,24 @@ use Test::More; | |||
18 | use NPTest; | 18 | use NPTest; |
19 | use FindBin qw($Bin); | 19 | use FindBin qw($Bin); |
20 | 20 | ||
21 | use HTTP::Daemon; | 21 | my $common_tests = 66; |
22 | use HTTP::Status; | 22 | my $ssl_only_tests = 6; |
23 | use HTTP::Response; | 23 | # Check that all dependent modules are available |
24 | eval { | ||
25 | require HTTP::Daemon; | ||
26 | require HTTP::Status; | ||
27 | require HTTP::Response; | ||
28 | }; | ||
29 | |||
30 | if ($@) { | ||
31 | plan skip_all => "Missing required module for test: $@"; | ||
32 | } else { | ||
33 | if (-x "./check_http") { | ||
34 | plan tests => $common_tests * 2 + $ssl_only_tests; | ||
35 | } else { | ||
36 | plan skip_all => "No check_http compiled"; | ||
37 | } | ||
38 | } | ||
24 | 39 | ||
25 | my $servers = { http => 0 }; # HTTP::Daemon should always be available | 40 | my $servers = { http => 0 }; # HTTP::Daemon should always be available |
26 | eval { require HTTP::Daemon::SSL }; | 41 | eval { require HTTP::Daemon::SSL }; |
@@ -112,9 +127,9 @@ sub run_server { | |||
112 | $c->send_response("slow"); | 127 | $c->send_response("slow"); |
113 | } elsif ($r->url->path eq "/method") { | 128 | } elsif ($r->url->path eq "/method") { |
114 | if ($r->method eq "DELETE") { | 129 | if ($r->method eq "DELETE") { |
115 | $c->send_error(RC_METHOD_NOT_ALLOWED); | 130 | $c->send_error(HTTP::Status->RC_METHOD_NOT_ALLOWED); |
116 | } elsif ($r->method eq "foo") { | 131 | } elsif ($r->method eq "foo") { |
117 | $c->send_error(RC_NOT_IMPLEMENTED); | 132 | $c->send_error(HTTP::Status->RC_NOT_IMPLEMENTED); |
118 | } else { | 133 | } else { |
119 | $c->send_status_line(200, $r->method); | 134 | $c->send_status_line(200, $r->method); |
120 | } | 135 | } |
@@ -138,7 +153,7 @@ sub run_server { | |||
138 | delete($persist[1000]); | 153 | delete($persist[1000]); |
139 | next MAINLOOP; | 154 | next MAINLOOP; |
140 | } else { | 155 | } else { |
141 | $c->send_error(RC_FORBIDDEN); | 156 | $c->send_error(HTTP::Status->RC_FORBIDDEN); |
142 | } | 157 | } |
143 | $c->close; | 158 | $c->close; |
144 | } | 159 | } |
@@ -157,14 +172,6 @@ if ($ARGV[0] && $ARGV[0] eq "-d") { | |||
157 | } | 172 | } |
158 | } | 173 | } |
159 | 174 | ||
160 | my $common_tests = 66; | ||
161 | my $ssl_only_tests = 6; | ||
162 | if (-x "./check_http") { | ||
163 | plan tests => $common_tests * 2 + $ssl_only_tests; | ||
164 | } else { | ||
165 | plan skip_all => "No check_http compiled"; | ||
166 | } | ||
167 | |||
168 | my $result; | 175 | my $result; |
169 | my $command = "./check_http -H 127.0.0.1"; | 176 | my $command = "./check_http -H 127.0.0.1"; |
170 | 177 | ||