summaryrefslogtreecommitdiffstats
path: root/plugins/tests
diff options
context:
space:
mode:
authorSven Nierlein <sven@nierlein.de>2020-05-15 11:52:55 +0200
committerSven Nierlein <sven@nierlein.de>2020-05-15 14:24:18 +0200
commitd54f14a09238fff7b8f4454b59d0adaef446d5c6 (patch)
treec3841ba20a15b51862066c3af10c0874c026d192 /plugins/tests
parent072e97d5de3f147aef1eae41222385352fb8df73 (diff)
downloadmonitoring-plugins-d54f14a.tar.gz
merge test changes from check_http
the example certificate has changed since.
Diffstat (limited to 'plugins/tests')
-rwxr-xr-xplugins/tests/check_curl.t21
1 files changed, 11 insertions, 10 deletions
diff --git a/plugins/tests/check_curl.t b/plugins/tests/check_curl.t
index e182623c..1afbe4bb 100755
--- a/plugins/tests/check_curl.t
+++ b/plugins/tests/check_curl.t
@@ -4,13 +4,15 @@
4# 4#
5# To create the https server certificate: 5# To create the https server certificate:
6# openssl req -new -x509 -keyout server-key.pem -out server-cert.pem -days 3650 -nodes 6# openssl req -new -x509 -keyout server-key.pem -out server-cert.pem -days 3650 -nodes
7# Country Name (2 letter code) [AU]:UK 7# to create a new expired certificate:
8# State or Province Name (full name) [Some-State]:Derbyshire 8# faketime '2008-01-01 12:00:00' openssl req -new -x509 -keyout expired-key.pem -out expired-cert.pem -days 1 -nodes
9# Locality Name (eg, city) []:Belper 9# Country Name (2 letter code) [AU]:DE
10# State or Province Name (full name) [Some-State]:Bavaria
11# Locality Name (eg, city) []:Munich
10# Organization Name (eg, company) [Internet Widgits Pty Ltd]:Monitoring Plugins 12# Organization Name (eg, company) [Internet Widgits Pty Ltd]:Monitoring Plugins
11# Organizational Unit Name (eg, section) []: 13# Organizational Unit Name (eg, section) []:
12# Common Name (eg, YOUR name) []:Ton Voon 14# Common Name (e.g. server FQDN or YOUR name) []:Monitoring Plugins
13# Email Address []:tonvoon@mac.com 15# Email Address []:devel@monitoring-plugins.org
14 16
15use strict; 17use strict;
16use Test::More; 18use Test::More;
@@ -221,21 +223,21 @@ SKIP: {
221 223
222 $result = NPTest->testCmd( "$command -p $port_https -S -C 14" ); 224 $result = NPTest->testCmd( "$command -p $port_https -S -C 14" );
223 is( $result->return_code, 0, "$command -p $port_https -S -C 14" ); 225 is( $result->return_code, 0, "$command -p $port_https -S -C 14" );
224 is( $result->output, 'OK - Certificate \'Ton Voon\' will expire on Sun Mar 3 21:41:28 2019 +0000.', "output ok" ); 226 is( $result->output, "OK - Certificate 'Monitoring Plugins' will expire on Fri Feb 16 15:31:44 2029 +0000.", "output ok" );
225 227
226 $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" ); 228 $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" );
227 is( $result->return_code, 1, "$command -p $port_https -S -C 14000" ); 229 is( $result->return_code, 1, "$command -p $port_https -S -C 14000" );
228 like( $result->output, '/WARNING - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:28 2019 \+0000\)./', "output ok" ); 230 like( $result->output, '/WARNING - Certificate \'Monitoring Plugins\' expires in \d+ day\(s\) \(Fri Feb 16 15:31:44 2029 \+0000\)./', "output ok" );
229 231
230 # Expired cert tests 232 # Expired cert tests
231 $result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" ); 233 $result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" );
232 is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" ); 234 is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" );
233 like( $result->output, '/CRITICAL - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:28 2019 \+0000\)./', "output ok" ); 235 like( $result->output, '/CRITICAL - Certificate \'Monitoring Plugins\' expires in \d+ day\(s\) \(Fri Feb 16 15:31:44 2029 \+0000\)./', "output ok" );
234 236
235 $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" ); 237 $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" );
236 is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" ); 238 is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" );
237 is( $result->output, 239 is( $result->output,
238 'CRITICAL - Certificate \'Ton Voon\' expired on Thu Mar 5 00:13:16 2009 +0000.', 240 'CRITICAL - Certificate \'Monitoring Plugins\' expired on Wed Jan 2 11:00:26 2008 +0000.',
239 "output ok" ); 241 "output ok" );
240 242
241} 243}
@@ -288,7 +290,6 @@ SKIP: {
288} 290}
289 291
290 292
291
292sub run_common_tests { 293sub run_common_tests {
293 my ($opts) = @_; 294 my ($opts) = @_;
294 my $command = $opts->{command}; 295 my $command = $opts->{command};