diff options
author | Markus Frosch <markus.frosch@icinga.com> | 2018-11-06 11:32:52 +0100 |
---|---|---|
committer | Markus Frosch <markus.frosch@icinga.com> | 2018-11-06 12:33:24 +0100 |
commit | 198611a3c2bd89562af87d8bf0c7584fce1ce037 (patch) | |
tree | 44d15f8f27f38e5e6b60f49a9fa2eab2d266772b /plugins/t/check_http.t | |
parent | d659f8d99faa0738be0ddcdb822f41e7f8c7f829 (diff) | |
download | monitoring-plugins-198611a3c2bd89562af87d8bf0c7584fce1ce037.tar.gz |
test: Add proxy tests via proxy
On Travis with a local squid
Diffstat (limited to 'plugins/t/check_http.t')
-rw-r--r-- | plugins/t/check_http.t | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t index 8bd484a0..416fbbcb 100644 --- a/plugins/t/check_http.t +++ b/plugins/t/check_http.t @@ -9,7 +9,7 @@ use Test::More; use POSIX qw/mktime strftime/; use NPTest; -plan tests => 49; +plan tests => 55; my $successOutput = '/OK.*HTTP.*second/'; @@ -42,6 +42,14 @@ my $host_tcp_http2 = getTestParameter( "NP_HOST_TCP_HTTP2", "A host providing an index page containing the string 'monitoring'", "test.monitoring-plugins.org" ); +my $host_tcp_proxy = getTestParameter( "NP_HOST_TCP_PROXY", + "A host providing a HTTP proxy with CONNECT support", + "localhost"); + +my $port_tcp_proxy = getTestParameter( "NP_PORT_TCP_PROXY", + "Port of the proxy with HTTP and CONNECT support", + "3128"); + my $faketime = -x '/usr/bin/faketime' ? 1 : 0; @@ -198,3 +206,19 @@ SKIP: { $res = NPTest->testCmd( "./check_http -H www.mozilla.com --extended-perfdata" ); like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); } + +SKIP: { + skip "No internet access or proxy configured", 6 if $internet_access eq "no" or ! $host_tcp_proxy; + + $res = NPTest->testCmd( "./check_http -I $host_tcp_proxy -p $port_tcp_proxy -u http://$host_tcp_http -e 200,301,302"); + is( $res->return_code, 0, "Proxy HTTP works"); + like($res->output, qr/OK: Status line output matched/, "Proxy HTTP Output is sufficent"); + + $res = NPTest->testCmd( "./check_http -I $host_tcp_proxy -p $port_tcp_proxy -H $host_tls_http -S -j CONNECT"); + is( $res->return_code, 0, "Proxy HTTP CONNECT works"); + like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficent"); + + $res = NPTest->testCmd( "./check_http -I $host_tcp_proxy -p $port_tcp_proxy -H $host_tls_http -S -j CONNECT:HEAD"); + is( $res->return_code, 0, "Proxy HTTP CONNECT works with override method"); + like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficent"); +} |