diff options
Diffstat (limited to 'plugins/t/check_curl.t')
| -rw-r--r-- | plugins/t/check_curl.t | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/plugins/t/check_curl.t b/plugins/t/check_curl.t index 4bff538a..ada6a045 100644 --- a/plugins/t/check_curl.t +++ b/plugins/t/check_curl.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 => 57; | 12 | plan tests => 58; |
| 13 | 13 | ||
| 14 | my $successOutput = '/OK.*HTTP.*second/'; | 14 | my $successOutput = '/OK.*HTTP.*second/'; |
| 15 | 15 | ||
| @@ -46,7 +46,7 @@ $res = NPTest->testCmd( | |||
| 46 | ); | 46 | ); |
| 47 | cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" ); | 47 | cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" ); |
| 48 | # was CRITICAL only, but both check_curl and check_http print HTTP CRITICAL (puzzle?!) | 48 | # was CRITICAL only, but both check_curl and check_http print HTTP CRITICAL (puzzle?!) |
| 49 | cmp_ok( $res->output, 'eq', "HTTP CRITICAL - Invalid HTTP response received from host on port 80: cURL returned 28 - Timeout was reached", "Output OK"); | 49 | like( $res->output, "/HTTP CRITICAL - Invalid HTTP response received from host on port 80: cURL returned 28 - Connection timed out after/", "Output OK"); |
| 50 | 50 | ||
| 51 | $res = NPTest->testCmd( | 51 | $res = NPTest->testCmd( |
| 52 | "./$plugin $hostname_invalid -wt 1 -ct 2" | 52 | "./$plugin $hostname_invalid -wt 1 -ct 2" |
| @@ -56,7 +56,7 @@ cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" ); | |||
| 56 | # On Debian, it is Name or service not known, on Darwin, it is No address associated with nodename | 56 | # On Debian, it is Name or service not known, on Darwin, it is No address associated with nodename |
| 57 | # Is also possible to get a socket timeout if DNS is not responding fast enough | 57 | # Is also possible to get a socket timeout if DNS is not responding fast enough |
| 58 | # cURL gives us consistent strings from it's own 'lib/strerror.c' | 58 | # cURL gives us consistent strings from it's own 'lib/strerror.c' |
| 59 | like( $res->output, "/cURL returned 6 - Couldn't resolve host name/", "Output OK"); | 59 | like( $res->output, "/cURL returned 6 - Could not resolve host:/", "Output OK"); |
| 60 | 60 | ||
| 61 | # host header checks | 61 | # host header checks |
| 62 | $res = NPTest->testCmd("./$plugin -v -H $host_tcp_http"); | 62 | $res = NPTest->testCmd("./$plugin -v -H $host_tcp_http"); |
| @@ -84,7 +84,7 @@ like( $res->output, '/^Host: testhost:8001\s*$/ms', "Host Header OK" ); | |||
| 84 | like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" ); | 84 | like( $res->output, '/CURLOPT_URL: http:\/\/'.$host_tcp_http.':80\//ms', "Url OK" ); |
| 85 | 85 | ||
| 86 | SKIP: { | 86 | SKIP: { |
| 87 | skip "No internet access", 3 if $internet_access eq "no"; | 87 | skip "No internet access", 4 if $internet_access eq "no"; |
| 88 | 88 | ||
| 89 | $res = NPTest->testCmd("./$plugin -v -H $host_tls_http -S"); | 89 | $res = NPTest->testCmd("./$plugin -v -H $host_tls_http -S"); |
| 90 | like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" ); | 90 | like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" ); |
| @@ -94,6 +94,9 @@ SKIP: { | |||
| 94 | 94 | ||
| 95 | $res = NPTest->testCmd("./$plugin -v -H $host_tls_http:443 -S -p 443"); | 95 | $res = NPTest->testCmd("./$plugin -v -H $host_tls_http:443 -S -p 443"); |
| 96 | like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" ); | 96 | like( $res->output, '/^Host: '.$host_tls_http.'\s*$/ms', "Host Header OK" ); |
| 97 | |||
| 98 | $res = NPTest->testCmd("./$plugin -v -H $host_tls_http -D -S -p 443"); | ||
| 99 | like( $res->output, '/(^Host: '.$host_tls_http.'\s*$)|(cURL returned 60)/ms', "Host Header OK" ); | ||
| 97 | }; | 100 | }; |
| 98 | 101 | ||
| 99 | SKIP: { | 102 | SKIP: { |
| @@ -117,7 +120,7 @@ SKIP: { | |||
| 117 | cmp_ok( $res->return_code, "==", 0, "And also when not found"); | 120 | cmp_ok( $res->return_code, "==", 0, "And also when not found"); |
| 118 | } | 121 | } |
| 119 | SKIP: { | 122 | SKIP: { |
| 120 | skip "No internet access", 16 if $internet_access eq "no"; | 123 | skip "No internet access", 28 if $internet_access eq "no"; |
| 121 | 124 | ||
| 122 | $res = NPTest->testCmd( | 125 | $res = NPTest->testCmd( |
| 123 | "./$plugin --ssl $host_tls_http" | 126 | "./$plugin --ssl $host_tls_http" |
| @@ -190,8 +193,7 @@ SKIP: { | |||
| 190 | ); | 193 | ); |
| 191 | cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" ); | 194 | cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" ); |
| 192 | 195 | ||
| 193 | 196 | $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f curl" ); | |
| 194 | $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f follow" ); | ||
| 195 | is( $res->return_code, 0, "Redirection based on location is okay"); | 197 | is( $res->return_code, 0, "Redirection based on location is okay"); |
| 196 | 198 | ||
| 197 | $res = NPTest->testCmd( "./$plugin -H www.mozilla.com --extended-perfdata" ); | 199 | $res = NPTest->testCmd( "./$plugin -H www.mozilla.com --extended-perfdata" ); |
