diff options
author | linkslice <sparctacus@gmail.com> | 2012-06-06 21:35:34 -0700 |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-08-18 18:23:11 +0200 |
commit | 2a8eab6b31e0f461e52b504776caad6bb93b981f (patch) | |
tree | 087ab01032764d366d91849a619489b73d3c776c /plugins/tests/check_http.t | |
parent | 0eeb8cde6756c1280f4925ba479d378541bbce04 (diff) | |
download | monitoring-plugins-2a8eab6b31e0f461e52b504776caad6bb93b981f.tar.gz |
added ability to check regex against http headers. booyah!
Diffstat (limited to 'plugins/tests/check_http.t')
-rwxr-xr-x | plugins/tests/check_http.t | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t index 9f97abdc..873fd6ec 100755 --- a/plugins/tests/check_http.t +++ b/plugins/tests/check_http.t | |||
@@ -151,6 +151,10 @@ sub run_server { | |||
151 | unshift @persist, $c; | 151 | unshift @persist, $c; |
152 | delete($persist[1000]); | 152 | delete($persist[1000]); |
153 | next MAINLOOP; | 153 | next MAINLOOP; |
154 | } elsif ($r->url->path eq "/header_check") { | ||
155 | $c->send_basic_header; | ||
156 | $c->send_header('foo'); | ||
157 | $c->send_crlf; | ||
154 | } else { | 158 | } else { |
155 | $c->send_error(HTTP::Status->RC_FORBIDDEN); | 159 | $c->send_error(HTTP::Status->RC_FORBIDDEN); |
156 | } | 160 | } |
@@ -223,6 +227,13 @@ sub run_common_tests { | |||
223 | is( $result->return_code, 2, "Missing string check"); | 227 | is( $result->return_code, 2, "Missing string check"); |
224 | like( $result->output, qr%HTTP CRITICAL: HTTP/1\.1 200 OK - string 'NonRootWithOver30charsAndM...' not found on 'https?://127\.0\.0\.1:\d+/file/root'%, "Shows search string and location"); | 228 | like( $result->output, qr%HTTP CRITICAL: HTTP/1\.1 200 OK - string 'NonRootWithOver30charsAndM...' not found on 'https?://127\.0\.0\.1:\d+/file/root'%, "Shows search string and location"); |
225 | 229 | ||
230 | $result = NPTest->testCmd( "$command -u /header_check -d foo" ); | ||
231 | is( $result->return_code, 0, "header_check search for string"); | ||
232 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - 274 bytes in [\d\.]+ second/', "Output correct" ); | ||
233 | |||
234 | $result = NPTest->testCmd( "$command -u /header_check -d foobar" ); | ||
235 | is( $result->return_code, 2, "Missing header string check"); | ||
236 | like( $result->output, qr%^HTTP CRITICAL: HTTP/1\.1 200 OK - string 'foobar' not found on 'https?://127\.0\.0\.1:\d+/header_check/root'%, "Shows search string and location"); | ||
226 | 237 | ||
227 | my $cmd; | 238 | my $cmd; |
228 | $cmd = "$command -u /slow"; | 239 | $cmd = "$command -u /slow"; |