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 | |
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')
-rw-r--r-- | plugins/t/NPTest.cache.travis | 2 | ||||
-rw-r--r-- | plugins/t/check_http.t | 26 |
2 files changed, 27 insertions, 1 deletions
diff --git a/plugins/t/NPTest.cache.travis b/plugins/t/NPTest.cache.travis index e9705f3b..28437a00 100644 --- a/plugins/t/NPTest.cache.travis +++ b/plugins/t/NPTest.cache.travis | |||
@@ -59,4 +59,6 @@ | |||
59 | 'host_udp_time' => 'none', | 59 | 'host_udp_time' => 'none', |
60 | 'host_tls_http' => 'localhost', | 60 | 'host_tls_http' => 'localhost', |
61 | 'host_tls_cert' => 'localhost', | 61 | 'host_tls_cert' => 'localhost', |
62 | 'NP_HOST_TCP_PROXY' => 'localhost', | ||
63 | 'NP_PORT_TCP_PROXY' => '3128', | ||
62 | } | 64 | } |
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; | |||
9 | use POSIX qw/mktime strftime/; | 9 | use POSIX qw/mktime strftime/; |
10 | use NPTest; | 10 | use NPTest; |
11 | 11 | ||
12 | plan tests => 49; | 12 | plan tests => 55; |
13 | 13 | ||
14 | my $successOutput = '/OK.*HTTP.*second/'; | 14 | my $successOutput = '/OK.*HTTP.*second/'; |
15 | 15 | ||
@@ -42,6 +42,14 @@ my $host_tcp_http2 = getTestParameter( "NP_HOST_TCP_HTTP2", | |||
42 | "A host providing an index page containing the string 'monitoring'", | 42 | "A host providing an index page containing the string 'monitoring'", |
43 | "test.monitoring-plugins.org" ); | 43 | "test.monitoring-plugins.org" ); |
44 | 44 | ||
45 | my $host_tcp_proxy = getTestParameter( "NP_HOST_TCP_PROXY", | ||
46 | "A host providing a HTTP proxy with CONNECT support", | ||
47 | "localhost"); | ||
48 | |||
49 | my $port_tcp_proxy = getTestParameter( "NP_PORT_TCP_PROXY", | ||
50 | "Port of the proxy with HTTP and CONNECT support", | ||
51 | "3128"); | ||
52 | |||
45 | my $faketime = -x '/usr/bin/faketime' ? 1 : 0; | 53 | my $faketime = -x '/usr/bin/faketime' ? 1 : 0; |
46 | 54 | ||
47 | 55 | ||
@@ -198,3 +206,19 @@ SKIP: { | |||
198 | $res = NPTest->testCmd( "./check_http -H www.mozilla.com --extended-perfdata" ); | 206 | $res = NPTest->testCmd( "./check_http -H www.mozilla.com --extended-perfdata" ); |
199 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); | 207 | like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); |
200 | } | 208 | } |
209 | |||
210 | SKIP: { | ||
211 | skip "No internet access or proxy configured", 6 if $internet_access eq "no" or ! $host_tcp_proxy; | ||
212 | |||
213 | $res = NPTest->testCmd( "./check_http -I $host_tcp_proxy -p $port_tcp_proxy -u http://$host_tcp_http -e 200,301,302"); | ||
214 | is( $res->return_code, 0, "Proxy HTTP works"); | ||
215 | like($res->output, qr/OK: Status line output matched/, "Proxy HTTP Output is sufficent"); | ||
216 | |||
217 | $res = NPTest->testCmd( "./check_http -I $host_tcp_proxy -p $port_tcp_proxy -H $host_tls_http -S -j CONNECT"); | ||
218 | is( $res->return_code, 0, "Proxy HTTP CONNECT works"); | ||
219 | like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficent"); | ||
220 | |||
221 | $res = NPTest->testCmd( "./check_http -I $host_tcp_proxy -p $port_tcp_proxy -H $host_tls_http -S -j CONNECT:HEAD"); | ||
222 | is( $res->return_code, 0, "Proxy HTTP CONNECT works with override method"); | ||
223 | like($res->output, qr/HTTP OK:/, "Proxy HTTP CONNECT output sufficent"); | ||
224 | } | ||