From 2a8eab6b31e0f461e52b504776caad6bb93b981f Mon Sep 17 00:00:00 2001 From: linkslice Date: Wed, 6 Jun 2012 21:35:34 -0700 Subject: added ability to check regex against http headers. booyah! --- plugins/tests/check_http.t | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'plugins/tests') 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 { unshift @persist, $c; delete($persist[1000]); next MAINLOOP; + } elsif ($r->url->path eq "/header_check") { + $c->send_basic_header; + $c->send_header('foo'); + $c->send_crlf; } else { $c->send_error(HTTP::Status->RC_FORBIDDEN); } @@ -223,6 +227,13 @@ sub run_common_tests { is( $result->return_code, 2, "Missing string check"); 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"); + $result = NPTest->testCmd( "$command -u /header_check -d foo" ); + is( $result->return_code, 0, "header_check search for string"); + like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - 274 bytes in [\d\.]+ second/', "Output correct" ); + + $result = NPTest->testCmd( "$command -u /header_check -d foobar" ); + is( $result->return_code, 2, "Missing header string check"); + 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"); my $cmd; $cmd = "$command -u /slow"; -- cgit v1.2.3