diff options
Diffstat (limited to 'plugins/tests')
| -rw-r--r-- | plugins/tests/certs/expired-cert.pem | 41 | ||||
| -rw-r--r-- | plugins/tests/certs/expired-key.pem | 43 | ||||
| -rw-r--r-- | plugins/tests/certs/server-cert.pem | 41 | ||||
| -rw-r--r-- | plugins/tests/certs/server-key.pem | 43 | ||||
| -rwxr-xr-x | plugins/tests/check_curl.t | 508 | ||||
| -rwxr-xr-x | plugins/tests/check_http.t | 29 | ||||
| -rwxr-xr-x | plugins/tests/check_snmp.t | 110 |
7 files changed, 683 insertions, 132 deletions
diff --git a/plugins/tests/certs/expired-cert.pem b/plugins/tests/certs/expired-cert.pem index 40324cf8..77a9166e 100644 --- a/plugins/tests/certs/expired-cert.pem +++ b/plugins/tests/certs/expired-cert.pem | |||
| @@ -1,21 +1,24 @@ | |||
| 1 | -----BEGIN CERTIFICATE----- | 1 | -----BEGIN CERTIFICATE----- |
| 2 | MIIDYzCCAsygAwIBAgIJAJISzcX71f5pMA0GCSqGSIb3DQEBBAUAMH8xCzAJBgNV | 2 | MIIEETCCAvmgAwIBAgIUFDsP6WnV/uqeQMpD/DYSqouE13kwDQYJKoZIhvcNAQEL |
| 3 | BAYTAlVLMRMwEQYDVQQIEwpEZXJieXNoaXJlMQ8wDQYDVQQHEwZCZWxwZXIxFzAV | 3 | BQAwgZcxCzAJBgNVBAYTAkRFMRAwDgYDVQQIDAdCYXZhcmlhMQ8wDQYDVQQHDAZN |
| 4 | BgNVBAoTDk5hZ2lvcyBQbHVnaW5zMREwDwYDVQQDEwhUb24gVm9vbjEeMBwGCSqG | 4 | dW5pY2gxGzAZBgNVBAoMEk1vbml0b3JpbmcgUGx1Z2luczEbMBkGA1UEAwwSTW9u |
| 5 | SIb3DQEJARYPdG9udm9vbkBtYWMuY29tMB4XDTA5MDMwNjAwMTMxNVoXDTA5MDMw | 5 | aXRvcmluZyBQbHVnaW5zMSswKQYJKoZIhvcNAQkBFhxkZXZlbEBtb25pdG9yaW5n |
| 6 | NTAwMT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urCnuJQuk1P4VsSkJCOSeHjWZgK9pKNdsIJZr4wDVfhjQgU0XT6xakSf7 | ||
| 23 | eCaHtO0VKsbLZoiTmpxidjsdYiXyeKYIQNtUpTjyJ5V/cZsq9w== | ||
| 21 | -----END CERTIFICATE----- | 24 | -----END CERTIFICATE----- |
diff --git a/plugins/tests/certs/expired-key.pem b/plugins/tests/certs/expired-key.pem index af0e24da..c1510b2d 100644 --- a/plugins/tests/certs/expired-key.pem +++ b/plugins/tests/certs/expired-key.pem | |||
| @@ -1,15 +1,28 @@ | |||
| 1 | -----BEGIN RSA PRIVATE KEY----- | 1 | -----BEGIN PRIVATE KEY----- |
| 2 | MIICXAIBAAKBgQDkBz+CZ8wAouKuqrlwIivoE0n3xussoxFfiosrrUYARdjHRdN1 | 2 | MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDJ4crAoWMlZRdg |
| 3 | +ZbNMBDcP+X5zE6x8p5eF6BqFf6w+AkdoRk9Ju3b+1btDES5TydUgohXjLkEt9M8 | 3 | cqyKzKlR/10eUg9AAhLIY/UFfpQvbpku8TqQpvHcsVD1bY84ahBaXMWIHWygZ5VY |
| 4 | yzCa9AOyFvOvakZSkJs8bNSU+lw20qDULhdeeM6McDbCpTI6F7SUhzdmKQIDAQAB | 4 | N3RTQm1Z0IqY5dZ1xem6lCVNJS1EIwNCR+os3wZHlMFN3vet7OnmbPTycx8vC7Sn |
| 5 | AoGARgI3rHjjuDpKMGg4IMZNBqaNaiZHY9/44IVvrww21rSbFqtIfgsQEpU0R/rS | 5 | lVDX3VSLwkcWCsA5qUCfxTDkN7y+PhWZNeZTk0nZQWgLR11T9OH+XBEJrIdzVycx |
| 6 | R7xDWPztRGQqmwd/t6OfYNpqHbjO1MWzasVBVnzue5P59Y1xy1h0LZF8+a9GY++0 | 6 | WrYXtz+6ExRRBg0GYnLSnGgdrCn6P00qX/EhiyOBA2BqFDI26zC4YeNoTCE+77sb |
| 7 | uAGUC24jsXSmypNVzoX+ZKyinA3oYV/etdPYx1W8Ms5XIzUCQQD7xwhMuLok6Kbq | 7 | Tdexbh6G74fXz3wz8yRKWfotABTWzKgnzKk8zy1X7ODHi7CPu52dnaFx433m5bvQ |
| 8 | UEgiSfBTbx+haP3IiqqMF14z8QoEyD3jchydNaXEYdQxN8jEl2aPrMqTc6x8Jq4/ | 8 | 9aDkNDJTAgMBAAECggEACrLFfNnQmD24NGs/S4e2/VpsA9xTZI/3kNkDNgxULANP |
| 9 | ai0OkB+fAkEA59pAmN81HylV7+CsVjLOSbJqzau7NDxSs2uutxhHZRwz0e25wVer | 9 | aNZtxRajwI9A/BCXQ2UTgsZhzWnJxOJYXrlpl7PweY78mUesysb3MOUC6QisUm0M |
| 10 | fA03l08u0ebC/TDHkmHV6ikCryM5HU2FNwJAVZJFzd2S1myEHmr+uTisB49jDrbi | 10 | kimfdktHWOnAKLFFLNleN9DUVjjVkTeslijqhNX80f80py1grG2UuCLKCX4OqYIm |
| 11 | WkBWypo+mCS6JPnxntXvx7auClq9haTSBY73eqldiFPuMZvr6P2rJqHxPQJBAOTM | 11 | qACE8TMmSZLz42AO96TndNtKplQ8LuGLEmByW95wEfhx3Gm4ckkL7qII/U3DnQXr |
| 12 | quaxjti7kATy8N73sD9mBKQGju1TgkFxSK+DFCGhnTnToXY9MAtxd6SoDYoyccYu | 12 | 0T+3xLaj+eNJzYDpIFZiw4sNzOuAyCz+4Cc4sPDuMnzquXF+enpkemoycC1RmEpG |
| 13 | dyPrzJAR/IYc+mYCdC0CQDKlZuMPVXEgvGaQapzMQ++5yJRvMZF4tWvONBs0OCE9 | 13 | KIDTwmFsc8TrbGV0qifC6fsCrDivdYLqL7R/q3IBQQKBgQDmfvO3VYTEKY8NA+AT |
| 14 | QYarsTi5M20cymMBXHOLZIjqwsni4G/C9kqJSvC75Vg= | 14 | 5s6+7NTxRsXxJUCEhCNBWimSH3EzmBAvrodLY6A0oYg8i81bgNX1I9GPVXJZ/QA7 |
| 15 | -----END RSA PRIVATE KEY----- | 15 | ukd84HUIQoGS5Usmo4rp+kz4P6KkLXDemZtWPU5GXxicfajHRQlkbW6St6SpV7IS |
| 16 | ibJcDADeoiaPL1xvue1ToP/LoQKBgQDgOFHjYpep00gabvjXfYW7vhrg1vVwaKUM | ||
| 17 | rf0+UW8Exk4nbBw0eEC2YjxIwzdktlkdbzGaXYULnhg8GnfxYesMOpCLPw1JdB8o | ||
| 18 | ixETAFpW5bKrUsjEFRUGhzWnsCSFIQ4smpmtGLTxOQ8AkoDdORY5Z+Wv7JtFF6Do | ||
| 19 | PSoblckZcwKBgB3TD3YJesRnHDty5OuuUdIikuslXTd2uoJrFqS+JeLibqNeabnB | ||
| 20 | u3/lxDULMbWj4U6VvRmbKOKDC+jY887Gq7lc0cff0yROxwqY3sCnwo3crg7QUmp7 | ||
| 21 | Nb5S8G3qoCSfndcq96wm/Me/O28uCbycVJfUdchY8uRUHIHYbP0FOBQBAoGBAMgh | ||
| 22 | fPX4imaKr1DovDObVkK87EDDnU84GBm5MtDs3qrkVd3aIVK0Aw7HoAdSN58tI12i | ||
| 23 | YiPmVVqJQhhjh6tsOuAvZdTj8ngdrbICbrsHFZt6an+A5LIgHyQ0iy+hiPdLCdvG | ||
| 24 | ImTeKKMmyr04Bs1upueWVO0xw2VoMbcY4Py+NUEBAoGASQqedfCSKGLT+5lLZrhP | ||
| 25 | CbFVMmswEPjBcRb1trcuA09vfExn9FfUNFnnw3i9miprED5kufvAjb+6nduXizKg | ||
| 26 | 7HQYHCwVvakgtXgbiDMaNgYZcjWm+MdnfiwLJjJTO3DfI1JF2PJ8y9R95DPlAkDm | ||
| 27 | xH3OV8KV4UiTEVxS7ksmGzY= | ||
| 28 | -----END PRIVATE KEY----- | ||
diff --git a/plugins/tests/certs/server-cert.pem b/plugins/tests/certs/server-cert.pem index 549e4f7e..b84b91d2 100644 --- a/plugins/tests/certs/server-cert.pem +++ b/plugins/tests/certs/server-cert.pem | |||
| @@ -1,21 +1,24 @@ | |||
| 1 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VcM75UXzXBF5GZyrcMB8GA1UdIwQYMBaA |
| 17 | AwEB/zANBgkqhkiG9w0BAQQFAAOBgQCdqasaIO6JiV5ONFG6Tr1++85UfEdZKMUX | 17 | FG/UH6nGYPlVcM75UXzXBF5GZyrcMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcN |
| 18 | N2NHiNNUunolIZEYR+dW99ezKmHlDiQ/tMgoLVYpl2Ubho2pAkLGQR+W0ZASgWQ1 | 18 | AQELBQADggEBAGwitJPOnlIKLndNf+iCLMIs0dxsl8kAaejFcjoT0n4ja7Y6Zrqz |
| 19 | NjfV27Rv0y6lYQMTA0lVAU93L1x9reo3FMedmL5+H+lIEpLCxEPtAJNISrJOneZB | 19 | VSIidzz9vQWvy24xKJpAOdj/iLRHCUOG+Pf5fA6+/FiuqXr6gE2/lm0eC58BNONr |
| 20 | W5jDadwkoQ== | 20 | E5OzjQ/VoQ8RX4hDntgu6FYbaVa/vhwn16igt9qmdNGGZXf2/+DM3JADwyaA4EK8 |
| 21 | vm7KdofX9zkxXecHPNvf3jiVLPiDDt6tkGpHPEsyP/yc+RUdltUeZvHfliV0cCuC | ||
| 22 | jJX+Fm9ysjSpHIFFr+jUMuMHibWoOD8iy3eYxfCDoWsH488pCbj8MNuAq6vd6DBk | ||
| 23 | bOZxDz43vjWuYMkwXJTxJQh7Pne6kK0vE1g= | ||
| 21 | -----END CERTIFICATE----- | 24 | -----END CERTIFICATE----- |
diff --git a/plugins/tests/certs/server-key.pem b/plugins/tests/certs/server-key.pem index eacaeaa3..11947555 100644 --- a/plugins/tests/certs/server-key.pem +++ b/plugins/tests/certs/server-key.pem | |||
| @@ -1,15 +1,28 @@ | |||
| 1 | -----BEGIN RSA PRIVATE KEY----- | 1 | -----BEGIN PRIVATE KEY----- |
| 2 | MIICWwIBAAKBgQCnFjAbTbX2PL2V5NEjevxGE1Tfyzr2jknoMqFXS6BsLsI2oJPl | 2 | MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgw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10 | 00ZsvbmxY6z0+E5TesCJqQ+9GYTY1V357V7JchvaOxIRxWPqg9urHbru8OCtW/I5 |
| 11 | NoDHMCUql5vNLNdwBruxgGjBB/kUXEfgw60RusFvgt/zLh1wiii844JDawJAGQBF | 11 | Fh5HPUZlgCvlMpjlhyjydIf/oXyVA3RNsXlwe8+2cKuGIrjEzm2j9o3VF0sctTX0 |
| 12 | sYP3urg7zzx7c3qUe5gJ0wLuefjR1PSX4ecbfb7DDMdcSdjIuG1QDiZGmd2f1KG7 | 12 | ItP8A9qDmDQN7GIWX0MW6gncojpS1omC2wcFsdjj/xfPyiDal1X4aq/2YqG8351c |
| 13 | nwSCOtxk5dloW2KGAQJAQh/iBn0QhfKLFAP5eZBVk8E8XlZuw+S2DLy5SnBlIiYJ | 13 | YlM/+6Va0u9WWE/i64gASTAVqpMV4Yg8y0gGycuA0QKBgQDbgI2QeLd3FvMcURiU |
| 14 | GB5I2OClgtudXMv1labFrcST8O9eFrtsrhU1iUGUOw== | 14 | l3w9qJgw/Jp3jaNC/9LkVGGz4f4lKKB67lPZvI4noMK8GqO/LcXgqP/RY1oJojoA |
| 15 | -----END RSA PRIVATE KEY----- | 15 | /6JKVvzYGASZ7VgMoG9bk1AneP1PGdibuTUEwimGlcObxnDFIC/yjwPFu3jIdqdS |
| 16 | zZi1RZzyqAogN5y3SBEypSmn9wKBgQDECKsqqlcizmCl8v5aVk875AzGN+DOHZqx | ||
| 17 | bkmztlnLO/2e2Fmk3G5Vvnui0FYisf8Eq19tUTQCF6lSfJlGQeFAT119wkFZhLu+ | ||
| 18 | FfLGqoEMH0ijJg/8PpdpFRK3I94YcISoTNN6yxMvE6xdDGfKCt5a+IX5bwQi9Zdc | ||
| 19 | B242gEc6tQKBgA6tM8n7KFlAIZU9HuWgk2AUC8kKutFPmSD7tgAqXDYI4FNfugs+ | ||
| 20 | MEEYyHCB4UNujJBV4Ss6YZCAkh6eyD4U2aca1eElCfm40vBVMdzvpqZdAqLtWXxg | ||
| 21 | D9l3mgszrFaYGCY2Fr6jLV9lP5g3xsxUjudf9jSLY9HvpfzjRrMaNATVAoGBALTl | ||
| 22 | /vYfPMucwKlC5B7++J0e4/7iv6vUu9SyHocdZh1anb9AjPDKjXLIlZT4RhQ8R0XK | ||
| 23 | 0wOw5JpttU2uN08TKkbLNk3/vYhbKVjPLjrQSseh8sjDLgsqw1QwIxYnniLVakVY | ||
| 24 | p+rvjSNrNyqicQCMKQavwgocvSd5lJRTMwxOMezlAoGBAKWj71BX+0CK00/2S6lC | ||
| 25 | TcNcuUPG0d8y1czZ4q6tUlG4htwq1FMOpaghATXjkdsOGTLS+H1aA0Kt7Ai9zDhc | ||
| 26 | /bzOJEJ+jvBXV4Gcs7jl1r/HTKv0tT9ZSI5Vzkida0rfqxDGzcMVlLuCdH0cb8Iu | ||
| 27 | N0wdmCAqlQwHR13+F1zrAD7V | ||
| 28 | -----END PRIVATE KEY----- | ||
diff --git a/plugins/tests/check_curl.t b/plugins/tests/check_curl.t new file mode 100755 index 00000000..0caad23d --- /dev/null +++ b/plugins/tests/check_curl.t | |||
| @@ -0,0 +1,508 @@ | |||
| 1 | #! /usr/bin/perl -w -I .. | ||
| 2 | # | ||
| 3 | # Test check_http by having an actual HTTP server running | ||
| 4 | # | ||
| 5 | # To create the https server certificate: | ||
| 6 | # openssl req -new -x509 -keyout server-key.pem -out server-cert.pem -days 3650 -nodes | ||
| 7 | # to create a new expired certificate: | ||
| 8 | # faketime '2008-01-01 12:00:00' openssl req -new -x509 -keyout expired-key.pem -out expired-cert.pem -days 1 -nodes | ||
| 9 | # Country Name (2 letter code) [AU]:DE | ||
| 10 | # State or Province Name (full name) [Some-State]:Bavaria | ||
| 11 | # Locality Name (eg, city) []:Munich | ||
| 12 | # Organization Name (eg, company) [Internet Widgits Pty Ltd]:Monitoring Plugins | ||
| 13 | # Organizational Unit Name (eg, section) []: | ||
| 14 | # Common Name (e.g. server FQDN or YOUR name) []:Monitoring Plugins | ||
| 15 | # Email Address []:devel@monitoring-plugins.org | ||
| 16 | |||
| 17 | use strict; | ||
| 18 | use Test::More; | ||
| 19 | use NPTest; | ||
| 20 | use FindBin qw($Bin); | ||
| 21 | |||
| 22 | $ENV{'LC_TIME'} = "C"; | ||
| 23 | |||
| 24 | my $common_tests = 72; | ||
| 25 | my $ssl_only_tests = 8; | ||
| 26 | # Check that all dependent modules are available | ||
| 27 | eval "use HTTP::Daemon 6.01;"; | ||
| 28 | plan skip_all => 'HTTP::Daemon >= 6.01 required' if $@; | ||
| 29 | eval { | ||
| 30 | require HTTP::Status; | ||
| 31 | require HTTP::Response; | ||
| 32 | }; | ||
| 33 | |||
| 34 | my $plugin = 'check_http'; | ||
| 35 | $plugin = 'check_curl' if $0 =~ m/check_curl/mx; | ||
| 36 | |||
| 37 | # look for libcurl version to see if some advanced checks are possible (>= 7.49.0) | ||
| 38 | my $advanced_checks = 12; | ||
| 39 | my $use_advanced_checks = 0; | ||
| 40 | my $required_version = '7.49.0'; | ||
| 41 | my $virtual_host = 'www.somefunnyhost.com'; | ||
| 42 | my $virtual_port = 42; | ||
| 43 | my $curl_version = ''; | ||
| 44 | open (my $fh, '-|', "./$plugin --version") or die; | ||
| 45 | while (<$fh>) { | ||
| 46 | if (m{libcurl/([\d.]+)\s}) { | ||
| 47 | $curl_version = $1; | ||
| 48 | last; | ||
| 49 | } | ||
| 50 | } | ||
| 51 | close ($fh); | ||
| 52 | if ($curl_version) { | ||
| 53 | my ($major, $minor, $release) = split (/\./, $curl_version); | ||
| 54 | my ($req_major, $req_minor, $req_release) = split (/\./, $required_version); | ||
| 55 | my $check = ($major <=> $req_major or $minor <=> $req_minor or $release <=> $req_release); | ||
| 56 | if ($check >= 0) { | ||
| 57 | $use_advanced_checks = 1; | ||
| 58 | print "Found libcurl $major.$minor.$release. Using advanced checks\n"; | ||
| 59 | } | ||
| 60 | } | ||
| 61 | |||
| 62 | if ($@) { | ||
| 63 | plan skip_all => "Missing required module for test: $@"; | ||
| 64 | } else { | ||
| 65 | if (-x "./$plugin") { | ||
| 66 | plan tests => $common_tests * 2 + $ssl_only_tests + $advanced_checks; | ||
| 67 | } else { | ||
| 68 | plan skip_all => "No $plugin compiled"; | ||
| 69 | } | ||
| 70 | } | ||
| 71 | |||
| 72 | my $servers = { http => 0 }; # HTTP::Daemon should always be available | ||
| 73 | eval { require HTTP::Daemon::SSL }; | ||
| 74 | if ($@) { | ||
| 75 | diag "Cannot load HTTP::Daemon::SSL: $@"; | ||
| 76 | } else { | ||
| 77 | $servers->{https} = 0; | ||
| 78 | } | ||
| 79 | |||
| 80 | # set a fixed version, so the header size doesn't vary | ||
| 81 | $HTTP::Daemon::VERSION = "1.00"; | ||
| 82 | |||
| 83 | my $port_http = 50000 + int(rand(1000)); | ||
| 84 | my $port_https = $port_http + 1; | ||
| 85 | my $port_https_expired = $port_http + 2; | ||
| 86 | |||
| 87 | # This array keeps sockets around for implementing timeouts | ||
| 88 | my @persist; | ||
| 89 | |||
| 90 | # Start up all servers | ||
| 91 | my @pids; | ||
| 92 | my $pid = fork(); | ||
| 93 | if ($pid) { | ||
| 94 | # Parent | ||
| 95 | push @pids, $pid; | ||
| 96 | if (exists $servers->{https}) { | ||
| 97 | # Fork a normal HTTPS server | ||
| 98 | $pid = fork(); | ||
| 99 | if ($pid) { | ||
| 100 | # Parent | ||
| 101 | push @pids, $pid; | ||
| 102 | # Fork an expired cert server | ||
| 103 | $pid = fork(); | ||
| 104 | if ($pid) { | ||
| 105 | push @pids, $pid; | ||
| 106 | } else { | ||
| 107 | my $d = HTTP::Daemon::SSL->new( | ||
| 108 | LocalPort => $port_https_expired, | ||
| 109 | LocalAddr => "127.0.0.1", | ||
| 110 | SSL_cert_file => "$Bin/certs/expired-cert.pem", | ||
| 111 | SSL_key_file => "$Bin/certs/expired-key.pem", | ||
| 112 | ) || die; | ||
| 113 | print "Please contact https expired at: <URL:", $d->url, ">\n"; | ||
| 114 | run_server( $d ); | ||
| 115 | exit; | ||
| 116 | } | ||
| 117 | } else { | ||
| 118 | my $d = HTTP::Daemon::SSL->new( | ||
| 119 | LocalPort => $port_https, | ||
| 120 | LocalAddr => "127.0.0.1", | ||
| 121 | SSL_cert_file => "$Bin/certs/server-cert.pem", | ||
| 122 | SSL_key_file => "$Bin/certs/server-key.pem", | ||
| 123 | ) || die; | ||
| 124 | print "Please contact https at: <URL:", $d->url, ">\n"; | ||
| 125 | run_server( $d ); | ||
| 126 | exit; | ||
| 127 | } | ||
| 128 | } | ||
| 129 | # give our webservers some time to startup | ||
| 130 | sleep(1); | ||
| 131 | } else { | ||
| 132 | # Child | ||
| 133 | #print "child\n"; | ||
| 134 | my $d = HTTP::Daemon->new( | ||
| 135 | LocalPort => $port_http, | ||
| 136 | LocalAddr => "127.0.0.1", | ||
| 137 | ) || die; | ||
| 138 | print "Please contact http at: <URL:", $d->url, ">\n"; | ||
| 139 | run_server( $d ); | ||
| 140 | exit; | ||
| 141 | } | ||
| 142 | |||
| 143 | # Run the same server on http and https | ||
| 144 | sub run_server { | ||
| 145 | my $d = shift; | ||
| 146 | MAINLOOP: while (my $c = $d->accept ) { | ||
| 147 | while (my $r = $c->get_request) { | ||
| 148 | if ($r->method eq "GET" and $r->url->path =~ m^/statuscode/(\d+)^) { | ||
| 149 | $c->send_basic_header($1); | ||
| 150 | $c->send_crlf; | ||
| 151 | } elsif ($r->method eq "GET" and $r->url->path =~ m^/file/(.*)^) { | ||
| 152 | $c->send_basic_header; | ||
| 153 | $c->send_crlf; | ||
| 154 | $c->send_file_response("$Bin/var/$1"); | ||
| 155 | } elsif ($r->method eq "GET" and $r->url->path eq "/slow") { | ||
| 156 | $c->send_basic_header; | ||
| 157 | $c->send_crlf; | ||
| 158 | sleep 1; | ||
| 159 | $c->send_response("slow"); | ||
| 160 | } elsif ($r->url->path eq "/method") { | ||
| 161 | if ($r->method eq "DELETE") { | ||
| 162 | $c->send_error(HTTP::Status->RC_METHOD_NOT_ALLOWED); | ||
| 163 | } elsif ($r->method eq "foo") { | ||
| 164 | $c->send_error(HTTP::Status->RC_NOT_IMPLEMENTED); | ||
| 165 | } else { | ||
| 166 | $c->send_status_line(200, $r->method); | ||
| 167 | } | ||
| 168 | } elsif ($r->url->path eq "/postdata") { | ||
| 169 | $c->send_basic_header; | ||
| 170 | $c->send_crlf; | ||
| 171 | $c->send_response($r->method.":".$r->content); | ||
| 172 | } elsif ($r->url->path eq "/redirect") { | ||
| 173 | $c->send_redirect( "/redirect2" ); | ||
| 174 | } elsif ($r->url->path eq "/redir_external") { | ||
| 175 | $c->send_redirect(($d->isa('HTTP::Daemon::SSL') ? "https" : "http") . "://169.254.169.254/redirect2" ); | ||
| 176 | } elsif ($r->url->path eq "/redirect2") { | ||
| 177 | $c->send_basic_header; | ||
| 178 | $c->send_crlf; | ||
| 179 | $c->send_response(HTTP::Response->new( 200, 'OK', undef, 'redirected' )); | ||
| 180 | } elsif ($r->url->path eq "/redir_timeout") { | ||
| 181 | $c->send_redirect( "/timeout" ); | ||
| 182 | } elsif ($r->url->path eq "/timeout") { | ||
| 183 | # Keep $c from being destroyed, but prevent severe leaks | ||
| 184 | unshift @persist, $c; | ||
| 185 | delete($persist[1000]); | ||
| 186 | next MAINLOOP; | ||
| 187 | } elsif ($r->url->path eq "/header_check") { | ||
| 188 | $c->send_basic_header; | ||
| 189 | $c->send_header('foo'); | ||
| 190 | $c->send_crlf; | ||
| 191 | } elsif ($r->url->path eq "/header_broken_check") { | ||
| 192 | $c->send_basic_header; | ||
| 193 | $c->send_header('foo'); | ||
| 194 | print $c "Test1:: broken\n"; | ||
| 195 | print $c " Test2: leading whitespace\n"; | ||
| 196 | $c->send_crlf; | ||
| 197 | } elsif ($r->url->path eq "/virtual_port") { | ||
| 198 | # return sent Host header | ||
| 199 | $c->send_basic_header; | ||
| 200 | $c->send_crlf; | ||
| 201 | $c->send_response(HTTP::Response->new( 200, 'OK', undef, $r->header ('Host'))); | ||
| 202 | } else { | ||
| 203 | $c->send_error(HTTP::Status->RC_FORBIDDEN); | ||
| 204 | } | ||
| 205 | $c->close; | ||
| 206 | } | ||
| 207 | } | ||
| 208 | } | ||
| 209 | |||
| 210 | END { | ||
| 211 | foreach my $pid (@pids) { | ||
| 212 | if ($pid) { print "Killing $pid\n"; kill "INT", $pid } | ||
| 213 | } | ||
| 214 | }; | ||
| 215 | |||
| 216 | if ($ARGV[0] && $ARGV[0] eq "-d") { | ||
| 217 | while (1) { | ||
| 218 | sleep 100; | ||
| 219 | } | ||
| 220 | } | ||
| 221 | |||
| 222 | my $result; | ||
| 223 | my $command = "./$plugin -H 127.0.0.1"; | ||
| 224 | |||
| 225 | run_common_tests( { command => "$command -p $port_http" } ); | ||
| 226 | SKIP: { | ||
| 227 | skip "HTTP::Daemon::SSL not installed", $common_tests + $ssl_only_tests if ! exists $servers->{https}; | ||
| 228 | run_common_tests( { command => "$command -p $port_https", ssl => 1 } ); | ||
| 229 | |||
| 230 | $result = NPTest->testCmd( "$command -p $port_https -S -C 14" ); | ||
| 231 | is( $result->return_code, 0, "$command -p $port_https -S -C 14" ); | ||
| 232 | is( $result->output, "OK - Certificate 'Monitoring Plugins' will expire on Fri Feb 16 15:31:44 2029 +0000.", "output ok" ); | ||
| 233 | |||
| 234 | $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" ); | ||
| 235 | is( $result->return_code, 1, "$command -p $port_https -S -C 14000" ); | ||
| 236 | like( $result->output, '/WARNING - Certificate \'Monitoring Plugins\' expires in \d+ day\(s\) \(Fri Feb 16 15:31:44 2029 \+0000\)./', "output ok" ); | ||
| 237 | |||
| 238 | # Expired cert tests | ||
| 239 | $result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" ); | ||
| 240 | is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" ); | ||
| 241 | like( $result->output, '/CRITICAL - Certificate \'Monitoring Plugins\' expires in \d+ day\(s\) \(Fri Feb 16 15:31:44 2029 \+0000\)./', "output ok" ); | ||
| 242 | |||
| 243 | $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" ); | ||
| 244 | is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" ); | ||
| 245 | is( $result->output, | ||
| 246 | 'CRITICAL - Certificate \'Monitoring Plugins\' expired on Wed Jan 2 11:00:26 2008 +0000.', | ||
| 247 | "output ok" ); | ||
| 248 | |||
| 249 | } | ||
| 250 | |||
| 251 | my $cmd; | ||
| 252 | |||
| 253 | # advanced checks with virtual hostname and virtual port | ||
| 254 | SKIP: { | ||
| 255 | skip "libcurl version is smaller than $required_version", 6 unless $use_advanced_checks; | ||
| 256 | |||
| 257 | # http without virtual port | ||
| 258 | $cmd = "./$plugin -H $virtual_host -I 127.0.0.1 -p $port_http -u /virtual_port -r ^$virtual_host:$port_http\$"; | ||
| 259 | $result = NPTest->testCmd( $cmd ); | ||
| 260 | is( $result->return_code, 0, $cmd); | ||
| 261 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 262 | |||
| 263 | # http with virtual port (!= 80) | ||
| 264 | $cmd = "./$plugin -H $virtual_host:$virtual_port -I 127.0.0.1 -p $port_http -u /virtual_port -r ^$virtual_host:$virtual_port\$"; | ||
| 265 | $result = NPTest->testCmd( $cmd ); | ||
| 266 | is( $result->return_code, 0, $cmd); | ||
| 267 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 268 | |||
| 269 | # http with virtual port (80) | ||
| 270 | $cmd = "./$plugin -H $virtual_host:80 -I 127.0.0.1 -p $port_http -u /virtual_port -r ^$virtual_host\$"; | ||
| 271 | $result = NPTest->testCmd( $cmd ); | ||
| 272 | is( $result->return_code, 0, $cmd); | ||
| 273 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 274 | } | ||
| 275 | |||
| 276 | # and the same for SSL | ||
| 277 | SKIP: { | ||
| 278 | skip "libcurl version is smaller than $required_version and/or HTTP::Daemon::SSL not installed", 6 if ! exists $servers->{https} or not $use_advanced_checks; | ||
| 279 | # https without virtual port | ||
| 280 | $cmd = "./$plugin -H $virtual_host -I 127.0.0.1 -p $port_https --ssl -u /virtual_port -r ^$virtual_host:$port_https\$"; | ||
| 281 | $result = NPTest->testCmd( $cmd ); | ||
| 282 | is( $result->return_code, 0, $cmd); | ||
| 283 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 284 | |||
| 285 | # https with virtual port (!= 443) | ||
| 286 | $cmd = "./$plugin -H $virtual_host:$virtual_port -I 127.0.0.1 -p $port_https --ssl -u /virtual_port -r ^$virtual_host:$virtual_port\$"; | ||
| 287 | $result = NPTest->testCmd( $cmd ); | ||
| 288 | is( $result->return_code, 0, $cmd); | ||
| 289 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 290 | |||
| 291 | # https with virtual port (443) | ||
| 292 | $cmd = "./$plugin -H $virtual_host:443 -I 127.0.0.1 -p $port_https --ssl -u /virtual_port -r ^$virtual_host\$"; | ||
| 293 | $result = NPTest->testCmd( $cmd ); | ||
| 294 | is( $result->return_code, 0, $cmd); | ||
| 295 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 296 | } | ||
| 297 | |||
| 298 | |||
| 299 | sub run_common_tests { | ||
| 300 | my ($opts) = @_; | ||
| 301 | my $command = $opts->{command}; | ||
| 302 | if ($opts->{ssl}) { | ||
| 303 | $command .= " --ssl"; | ||
| 304 | } | ||
| 305 | |||
| 306 | $result = NPTest->testCmd( "$command -u /file/root" ); | ||
| 307 | is( $result->return_code, 0, "/file/root"); | ||
| 308 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - 274 bytes in [\d\.]+ second/', "Output correct" ); | ||
| 309 | |||
| 310 | $result = NPTest->testCmd( "$command -u /file/root -s Root" ); | ||
| 311 | is( $result->return_code, 0, "/file/root search for string"); | ||
| 312 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - 274 bytes in [\d\.]+ second/', "Output correct" ); | ||
| 313 | |||
| 314 | $result = NPTest->testCmd( "$command -u /file/root -s NonRoot" ); | ||
| 315 | is( $result->return_code, 2, "Missing string check"); | ||
| 316 | like( $result->output, qr%^HTTP CRITICAL: HTTP/1\.1 200 OK - string 'NonRoot' not found on 'https?://127\.0\.0\.1:\d+/file/root'%, "Shows search string and location"); | ||
| 317 | |||
| 318 | $result = NPTest->testCmd( "$command -u /file/root -s NonRootWithOver30charsAndMoreFunThanAWetFish" ); | ||
| 319 | is( $result->return_code, 2, "Missing string check"); | ||
| 320 | 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"); | ||
| 321 | |||
| 322 | $result = NPTest->testCmd( "$command -u /header_check -d foo" ); | ||
| 323 | is( $result->return_code, 0, "header_check search for string"); | ||
| 324 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - 96 bytes in [\d\.]+ second/', "Output correct" ); | ||
| 325 | |||
| 326 | $result = NPTest->testCmd( "$command -u /header_check -d bar" ); | ||
| 327 | is( $result->return_code, 2, "Missing header string check"); | ||
| 328 | like( $result->output, qr%^HTTP CRITICAL: HTTP/1\.1 200 OK - header 'bar' not found on 'https?://127\.0\.0\.1:\d+/header_check'%, "Shows search string and location"); | ||
| 329 | |||
| 330 | $result = NPTest->testCmd( "$command -u /header_broken_check" ); | ||
| 331 | is( $result->return_code, 0, "header_check search for string"); | ||
| 332 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - 138 bytes in [\d\.]+ second/', "Output correct" ); | ||
| 333 | |||
| 334 | my $cmd; | ||
| 335 | $cmd = "$command -u /slow"; | ||
| 336 | $result = NPTest->testCmd( $cmd ); | ||
| 337 | is( $result->return_code, 0, "$cmd"); | ||
| 338 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 339 | $result->output =~ /in ([\d\.]+) second/; | ||
| 340 | cmp_ok( $1, ">", 1, "Time is > 1 second" ); | ||
| 341 | |||
| 342 | $cmd = "$command -u /statuscode/200"; | ||
| 343 | $result = NPTest->testCmd( $cmd ); | ||
| 344 | is( $result->return_code, 0, $cmd); | ||
| 345 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 346 | |||
| 347 | $cmd = "$command -u /statuscode/200 -e 200"; | ||
| 348 | $result = NPTest->testCmd( $cmd ); | ||
| 349 | is( $result->return_code, 0, $cmd); | ||
| 350 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - Status line output matched "200" - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 351 | |||
| 352 | $cmd = "$command -u /statuscode/201"; | ||
| 353 | $result = NPTest->testCmd( $cmd ); | ||
| 354 | is( $result->return_code, 0, $cmd); | ||
| 355 | like( $result->output, '/^HTTP OK: HTTP/1.1 201 Created - \d+ bytes in [\d\.]+ second /', "Output correct: ".$result->output ); | ||
| 356 | |||
| 357 | $cmd = "$command -u /statuscode/201 -e 201"; | ||
| 358 | $result = NPTest->testCmd( $cmd ); | ||
| 359 | is( $result->return_code, 0, $cmd); | ||
| 360 | like( $result->output, '/^HTTP OK: HTTP/1.1 201 Created - Status line output matched "201" - \d+ bytes in [\d\.]+ second /', "Output correct: ".$result->output ); | ||
| 361 | |||
| 362 | $cmd = "$command -u /statuscode/201 -e 200"; | ||
| 363 | $result = NPTest->testCmd( $cmd ); | ||
| 364 | is( $result->return_code, 2, $cmd); | ||
| 365 | like( $result->output, '/^HTTP CRITICAL - Invalid HTTP response received from host on port \d+: HTTP/1.1 201 Created/', "Output correct: ".$result->output ); | ||
| 366 | |||
| 367 | $cmd = "$command -u /statuscode/200 -e 200,201,202"; | ||
| 368 | $result = NPTest->testCmd( $cmd ); | ||
| 369 | is( $result->return_code, 0, $cmd); | ||
| 370 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - Status line output matched "200,201,202" - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 371 | |||
| 372 | $cmd = "$command -u /statuscode/201 -e 200,201,202"; | ||
| 373 | $result = NPTest->testCmd( $cmd ); | ||
| 374 | is( $result->return_code, 0, $cmd); | ||
| 375 | like( $result->output, '/^HTTP OK: HTTP/1.1 201 Created - Status line output matched "200,201,202" - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 376 | |||
| 377 | $cmd = "$command -u /statuscode/203 -e 200,201,202"; | ||
| 378 | $result = NPTest->testCmd( $cmd ); | ||
| 379 | is( $result->return_code, 2, $cmd); | ||
| 380 | like( $result->output, '/^HTTP CRITICAL - Invalid HTTP response received from host on port (\d+): HTTP/1.1 203 Non-Authoritative Information/', "Output correct: ".$result->output ); | ||
| 381 | |||
| 382 | $cmd = "$command -j HEAD -u /method"; | ||
| 383 | $result = NPTest->testCmd( $cmd ); | ||
| 384 | is( $result->return_code, 0, $cmd); | ||
| 385 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 HEAD - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 386 | |||
| 387 | $cmd = "$command -j POST -u /method"; | ||
| 388 | $result = NPTest->testCmd( $cmd ); | ||
| 389 | is( $result->return_code, 0, $cmd); | ||
| 390 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 POST - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 391 | |||
| 392 | $cmd = "$command -j GET -u /method"; | ||
| 393 | $result = NPTest->testCmd( $cmd ); | ||
| 394 | is( $result->return_code, 0, $cmd); | ||
| 395 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 GET - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 396 | |||
| 397 | $cmd = "$command -u /method"; | ||
| 398 | $result = NPTest->testCmd( $cmd ); | ||
| 399 | is( $result->return_code, 0, $cmd); | ||
| 400 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 GET - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 401 | |||
| 402 | $cmd = "$command -P foo -u /method"; | ||
| 403 | $result = NPTest->testCmd( $cmd ); | ||
| 404 | is( $result->return_code, 0, $cmd); | ||
| 405 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 POST - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 406 | |||
| 407 | $cmd = "$command -j DELETE -u /method"; | ||
| 408 | $result = NPTest->testCmd( $cmd ); | ||
| 409 | is( $result->return_code, 1, $cmd); | ||
| 410 | like( $result->output, '/^HTTP WARNING: HTTP/1.1 405 Method Not Allowed/', "Output correct: ".$result->output ); | ||
| 411 | |||
| 412 | $cmd = "$command -j foo -u /method"; | ||
| 413 | $result = NPTest->testCmd( $cmd ); | ||
| 414 | is( $result->return_code, 2, $cmd); | ||
| 415 | like( $result->output, '/^HTTP CRITICAL: HTTP/1.1 501 Not Implemented/', "Output correct: ".$result->output ); | ||
| 416 | |||
| 417 | $cmd = "$command -P stufftoinclude -u /postdata -s POST:stufftoinclude"; | ||
| 418 | $result = NPTest->testCmd( $cmd ); | ||
| 419 | is( $result->return_code, 0, $cmd); | ||
| 420 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 421 | |||
| 422 | $cmd = "$command -j PUT -P stufftoinclude -u /postdata -s PUT:stufftoinclude"; | ||
| 423 | $result = NPTest->testCmd( $cmd ); | ||
| 424 | is( $result->return_code, 0, $cmd); | ||
| 425 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 426 | |||
| 427 | # To confirm that the free doesn't segfault | ||
| 428 | $cmd = "$command -P stufftoinclude -j PUT -u /postdata -s PUT:stufftoinclude"; | ||
| 429 | $result = NPTest->testCmd( $cmd ); | ||
| 430 | is( $result->return_code, 0, $cmd); | ||
| 431 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 432 | |||
| 433 | $cmd = "$command -u /redirect"; | ||
| 434 | $result = NPTest->testCmd( $cmd ); | ||
| 435 | is( $result->return_code, 0, $cmd); | ||
| 436 | like( $result->output, '/^HTTP OK: HTTP/1.1 301 Moved Permanently - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 437 | |||
| 438 | $cmd = "$command -f follow -u /redirect"; | ||
| 439 | $result = NPTest->testCmd( $cmd ); | ||
| 440 | is( $result->return_code, 0, $cmd); | ||
| 441 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 442 | |||
| 443 | $cmd = "$command -u /redirect -k 'follow: me'"; | ||
| 444 | $result = NPTest->testCmd( $cmd ); | ||
| 445 | is( $result->return_code, 0, $cmd); | ||
| 446 | like( $result->output, '/^HTTP OK: HTTP/1.1 301 Moved Permanently - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 447 | |||
| 448 | $cmd = "$command -f follow -u /redirect -k 'follow: me'"; | ||
| 449 | $result = NPTest->testCmd( $cmd ); | ||
| 450 | is( $result->return_code, 0, $cmd); | ||
| 451 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 452 | |||
| 453 | $cmd = "$command -f sticky -u /redirect -k 'follow: me'"; | ||
| 454 | $result = NPTest->testCmd( $cmd ); | ||
| 455 | is( $result->return_code, 0, $cmd); | ||
| 456 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 457 | |||
| 458 | $cmd = "$command -f stickyport -u /redirect -k 'follow: me'"; | ||
| 459 | $result = NPTest->testCmd( $cmd ); | ||
| 460 | is( $result->return_code, 0, $cmd); | ||
| 461 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - \d+ bytes in [\d\.]+ second/', "Output correct: ".$result->output ); | ||
| 462 | |||
| 463 | # These tests may block | ||
| 464 | print "ALRM\n"; | ||
| 465 | |||
| 466 | # stickyport - on full urlS port is set back to 80 otherwise | ||
| 467 | $cmd = "$command -f stickyport -u /redir_external -t 5 -s redirected"; | ||
| 468 | eval { | ||
| 469 | local $SIG{ALRM} = sub { die "alarm\n" }; | ||
| 470 | alarm(2); | ||
| 471 | $result = NPTest->testCmd( $cmd ); | ||
| 472 | alarm(0); }; | ||
| 473 | isnt( $@, "alarm\n", $cmd ); | ||
| 474 | is( $result->return_code, 0, $cmd ); | ||
| 475 | |||
| 476 | # Let's hope there won't be any web server on :80 returning "redirected"! | ||
| 477 | $cmd = "$command -f sticky -u /redir_external -t 5 -s redirected"; | ||
| 478 | eval { | ||
| 479 | local $SIG{ALRM} = sub { die "alarm\n" }; | ||
| 480 | alarm(2); | ||
| 481 | $result = NPTest->testCmd( $cmd ); | ||
| 482 | alarm(0); }; | ||
| 483 | isnt( $@, "alarm\n", $cmd ); | ||
| 484 | isnt( $result->return_code, 0, $cmd ); | ||
| 485 | |||
| 486 | # Test an external address - timeout | ||
| 487 | SKIP: { | ||
| 488 | skip "This doesn't seem to work all the time", 1 unless ($ENV{HTTP_EXTERNAL}); | ||
| 489 | $cmd = "$command -f follow -u /redir_external -t 5"; | ||
| 490 | eval { | ||
| 491 | $result = NPTest->testCmd( $cmd, 2 ); | ||
| 492 | }; | ||
| 493 | like( $@, "/timeout in command: $cmd/", $cmd ); | ||
| 494 | } | ||
| 495 | |||
| 496 | $cmd = "$command -u /timeout -t 5"; | ||
| 497 | eval { | ||
| 498 | $result = NPTest->testCmd( $cmd, 2 ); | ||
| 499 | }; | ||
| 500 | like( $@, "/timeout in command: $cmd/", $cmd ); | ||
| 501 | |||
| 502 | $cmd = "$command -f follow -u /redir_timeout -t 2"; | ||
| 503 | eval { | ||
| 504 | $result = NPTest->testCmd( $cmd, 5 ); | ||
| 505 | }; | ||
| 506 | is( $@, "", $cmd ); | ||
| 507 | |||
| 508 | } | ||
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t index d6d31de1..2f051fad 100755 --- a/plugins/tests/check_http.t +++ b/plugins/tests/check_http.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 | ||
| 15 | use strict; | 17 | use strict; |
| 16 | use Test::More; | 18 | use Test::More; |
| @@ -30,13 +32,16 @@ eval { | |||
| 30 | require HTTP::Response; | 32 | require HTTP::Response; |
| 31 | }; | 33 | }; |
| 32 | 34 | ||
| 35 | my $plugin = 'check_http'; | ||
| 36 | $plugin = 'check_curl' if $0 =~ m/check_curl/mx; | ||
| 37 | |||
| 33 | if ($@) { | 38 | if ($@) { |
| 34 | plan skip_all => "Missing required module for test: $@"; | 39 | plan skip_all => "Missing required module for test: $@"; |
| 35 | } else { | 40 | } else { |
| 36 | if (-x "./check_http") { | 41 | if (-x "./$plugin") { |
| 37 | plan tests => $common_tests * 2 + $ssl_only_tests + $virtual_port_tests; | 42 | plan tests => $common_tests * 2 + $ssl_only_tests + $virtual_port_tests; |
| 38 | } else { | 43 | } else { |
| 39 | plan skip_all => "No check_http compiled"; | 44 | plan skip_all => "No $plugin compiled"; |
| 40 | } | 45 | } |
| 41 | } | 46 | } |
| 42 | 47 | ||
| @@ -185,7 +190,7 @@ if ($ARGV[0] && $ARGV[0] eq "-d") { | |||
| 185 | } | 190 | } |
| 186 | 191 | ||
| 187 | my $result; | 192 | my $result; |
| 188 | my $command = "./check_http -H 127.0.0.1"; | 193 | my $command = "./$plugin -H 127.0.0.1"; |
| 189 | 194 | ||
| 190 | run_common_tests( { command => "$command -p $port_http" } ); | 195 | run_common_tests( { command => "$command -p $port_http" } ); |
| 191 | SKIP: { | 196 | SKIP: { |
| @@ -194,21 +199,21 @@ SKIP: { | |||
| 194 | 199 | ||
| 195 | $result = NPTest->testCmd( "$command -p $port_https -S -C 14" ); | 200 | $result = NPTest->testCmd( "$command -p $port_https -S -C 14" ); |
| 196 | is( $result->return_code, 0, "$command -p $port_https -S -C 14" ); | 201 | is( $result->return_code, 0, "$command -p $port_https -S -C 14" ); |
| 197 | is( $result->output, 'OK - Certificate \'Ton Voon\' will expire on Sun Mar 3 21:41:28 2019 +0000.', "output ok" ); | 202 | is( $result->output, "OK - Certificate 'Monitoring Plugins' will expire on Fri Feb 16 15:31:44 2029 +0000.", "output ok" ); |
| 198 | 203 | ||
| 199 | $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" ); | 204 | $result = NPTest->testCmd( "$command -p $port_https -S -C 14000" ); |
| 200 | is( $result->return_code, 1, "$command -p $port_https -S -C 14000" ); | 205 | is( $result->return_code, 1, "$command -p $port_https -S -C 14000" ); |
| 201 | like( $result->output, '/WARNING - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:28 2019 \+0000\)./', "output ok" ); | 206 | like( $result->output, '/WARNING - Certificate \'Monitoring Plugins\' expires in \d+ day\(s\) \(Fri Feb 16 15:31:44 2029 \+0000\)./', "output ok" ); |
| 202 | 207 | ||
| 203 | # Expired cert tests | 208 | # Expired cert tests |
| 204 | $result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" ); | 209 | $result = NPTest->testCmd( "$command -p $port_https -S -C 13960,14000" ); |
| 205 | is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" ); | 210 | is( $result->return_code, 2, "$command -p $port_https -S -C 13960,14000" ); |
| 206 | like( $result->output, '/CRITICAL - Certificate \'Ton Voon\' expires in \d+ day\(s\) \(Sun Mar 3 21:41:28 2019 \+0000\)./', "output ok" ); | 211 | like( $result->output, '/CRITICAL - Certificate \'Monitoring Plugins\' expires in \d+ day\(s\) \(Fri Feb 16 15:31:44 2029 \+0000\)./', "output ok" ); |
| 207 | 212 | ||
| 208 | $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" ); | 213 | $result = NPTest->testCmd( "$command -p $port_https_expired -S -C 7" ); |
| 209 | is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" ); | 214 | is( $result->return_code, 2, "$command -p $port_https_expired -S -C 7" ); |
| 210 | is( $result->output, | 215 | is( $result->output, |
| 211 | 'CRITICAL - Certificate \'Ton Voon\' expired on Thu Mar 5 00:13:16 2009 +0000.', | 216 | 'CRITICAL - Certificate \'Monitoring Plugins\' expired on Wed Jan 2 11:00:26 2008 +0000.', |
| 212 | "output ok" ); | 217 | "output ok" ); |
| 213 | 218 | ||
| 214 | } | 219 | } |
diff --git a/plugins/tests/check_snmp.t b/plugins/tests/check_snmp.t index 73a68b20..85d6bf55 100755 --- a/plugins/tests/check_snmp.t +++ b/plugins/tests/check_snmp.t | |||
| @@ -7,6 +7,7 @@ use strict; | |||
| 7 | use Test::More; | 7 | use Test::More; |
| 8 | use NPTest; | 8 | use NPTest; |
| 9 | use FindBin qw($Bin); | 9 | use FindBin qw($Bin); |
| 10 | use POSIX qw/strftime/; | ||
| 10 | 11 | ||
| 11 | my $tests = 67; | 12 | my $tests = 67; |
| 12 | # Check that all dependent modules are available | 13 | # Check that all dependent modules are available |
| @@ -37,6 +38,7 @@ if ($@) { | |||
| 37 | 38 | ||
| 38 | my $port_snmp = 16100 + int(rand(100)); | 39 | my $port_snmp = 16100 + int(rand(100)); |
| 39 | 40 | ||
| 41 | my $faketime = -x '/usr/bin/faketime' ? 1 : 0; | ||
| 40 | 42 | ||
| 41 | # Start up server | 43 | # Start up server |
| 42 | my @pids; | 44 | my @pids; |
| @@ -118,77 +120,81 @@ like($res->output, '/'.quotemeta('SNMP OK - And now have fun with with this: \"C | |||
| 118 | "And now have fun with with this: \"C:\\\\\" | 120 | "And now have fun with with this: \"C:\\\\\" |
| 119 | because we\'re not done yet!"').'/m', "Attempt to confuse parser No.3"); | 121 | because we\'re not done yet!"').'/m', "Attempt to confuse parser No.3"); |
| 120 | 122 | ||
| 121 | system("rm -f ".$ENV{'MP_STATE_PATH'}."/check_snmp/*"); | 123 | system("rm -f ".$ENV{'MP_STATE_PATH'}."/*/check_snmp/*"); |
| 122 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -w 600" ); | ||
| 123 | is($res->return_code, 0, "Returns OK"); | ||
| 124 | is($res->output, "No previous data to calculate rate - assume okay"); | ||
| 125 | 124 | ||
| 126 | # Need to sleep, otherwise duration=0 | 125 | # run rate checks with faketime. rate checks depend on the exact amount of time spend between the |
| 127 | sleep 1; | 126 | # plugin runs which may fail on busy machines. |
| 127 | # using faketime removes this race condition and also saves all the sleeps in between. | ||
| 128 | SKIP: { | ||
| 129 | skip "No faketime binary found", 28 if !$faketime; | ||
| 128 | 130 | ||
| 129 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -w 600" ); | 131 | my $ts = time(); |
| 130 | is($res->return_code, 1, "WARNING - due to going above rate calculation" ); | 132 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts))."' ./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -w 600" ); |
| 131 | is($res->output, "SNMP RATE WARNING - *666* | iso.3.6.1.4.1.8072.3.2.67.10=666;600 "); | 133 | is($res->return_code, 0, "Returns OK"); |
| 134 | is($res->output, "No previous data to calculate rate - assume okay"); | ||
| 132 | 135 | ||
| 133 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -w 600" ); | 136 | # test rate 1 second later |
| 134 | is($res->return_code, 3, "UNKNOWN - basically the divide by zero error" ); | 137 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+1))."' ./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -w 600" ); |
| 135 | is($res->output, "Time duration between plugin calls is invalid"); | 138 | is($res->return_code, 1, "WARNING - due to going above rate calculation" ); |
| 139 | is($res->output, "SNMP RATE WARNING - *666* | iso.3.6.1.4.1.8072.3.2.67.10=666;600 "); | ||
| 136 | 140 | ||
| 141 | # test rate with same time | ||
| 142 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+1))."' ./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -w 600" ); | ||
| 143 | is($res->return_code, 3, "UNKNOWN - basically the divide by zero error" ); | ||
| 144 | is($res->output, "Time duration between plugin calls is invalid"); | ||
| 137 | 145 | ||
| 138 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets" ); | ||
| 139 | is($res->return_code, 0, "OK for first call" ); | ||
| 140 | is($res->output, "No previous data to calculate rate - assume okay" ); | ||
| 141 | 146 | ||
| 142 | # Need to sleep, otherwise duration=0 | 147 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts))."' ./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets" ); |
| 143 | sleep 1; | 148 | is($res->return_code, 0, "OK for first call" ); |
| 149 | is($res->output, "No previous data to calculate rate - assume okay" ); | ||
| 144 | 150 | ||
| 145 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets" ); | 151 | # test rate 1 second later |
| 146 | is($res->return_code, 0, "OK as no thresholds" ); | 152 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+1))."' ./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets" ); |
| 147 | is($res->output, "SNMP RATE OK - inoctets 666 | inoctets=666 ", "Check label"); | 153 | is($res->return_code, 0, "OK as no thresholds" ); |
| 154 | is($res->output, "SNMP RATE OK - inoctets 666 | inoctets=666 ", "Check label"); | ||
| 148 | 155 | ||
| 149 | sleep 2; | 156 | # test rate 3 seconds later |
| 157 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+3))."' ./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets" ); | ||
| 158 | is($res->return_code, 0, "OK as no thresholds" ); | ||
| 159 | is($res->output, "SNMP RATE OK - inoctets 333 | inoctets=333 ", "Check rate decreases due to longer interval"); | ||
| 150 | 160 | ||
| 151 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets" ); | ||
| 152 | is($res->return_code, 0, "OK as no thresholds" ); | ||
| 153 | is($res->output, "SNMP RATE OK - inoctets 333 | inoctets=333 ", "Check rate decreases due to longer interval"); | ||
| 154 | 161 | ||
| 162 | # label performance data check | ||
| 163 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l test" ); | ||
| 164 | is($res->return_code, 0, "OK as no thresholds" ); | ||
| 165 | is($res->output, "SNMP OK - test 67996 | test=67996c ", "Check label"); | ||
| 155 | 166 | ||
| 156 | # label performance data check | 167 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l \"test'test\"" ); |
| 157 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l test" ); | 168 | is($res->return_code, 0, "OK as no thresholds" ); |
| 158 | is($res->return_code, 0, "OK as no thresholds" ); | 169 | is($res->output, "SNMP OK - test'test 68662 | \"test'test\"=68662c ", "Check label"); |
| 159 | is($res->output, "SNMP OK - test 67996 | test=67996c ", "Check label"); | ||
| 160 | 170 | ||
| 161 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l \"test'test\"" ); | 171 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l 'test\"test'" ); |
| 162 | is($res->return_code, 0, "OK as no thresholds" ); | 172 | is($res->return_code, 0, "OK as no thresholds" ); |
| 163 | is($res->output, "SNMP OK - test'test 68662 | \"test'test\"=68662c ", "Check label"); | 173 | is($res->output, "SNMP OK - test\"test 69328 | 'test\"test'=69328c ", "Check label"); |
| 164 | 174 | ||
| 165 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l 'test\"test'" ); | 175 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l test -O" ); |
| 166 | is($res->return_code, 0, "OK as no thresholds" ); | 176 | is($res->return_code, 0, "OK as no thresholds" ); |
| 167 | is($res->output, "SNMP OK - test\"test 69328 | 'test\"test'=69328c ", "Check label"); | 177 | is($res->output, "SNMP OK - test 69994 | iso.3.6.1.4.1.8072.3.2.67.10=69994c ", "Check label"); |
| 168 | 178 | ||
| 169 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l test -O" ); | 179 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10" ); |
| 170 | is($res->return_code, 0, "OK as no thresholds" ); | 180 | is($res->return_code, 0, "OK as no thresholds" ); |
| 171 | is($res->output, "SNMP OK - test 69994 | iso.3.6.1.4.1.8072.3.2.67.10=69994c ", "Check label"); | 181 | is($res->output, "SNMP OK - 70660 | iso.3.6.1.4.1.8072.3.2.67.10=70660c ", "Check label"); |
| 172 | 182 | ||
| 173 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10" ); | 183 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l 'test test'" ); |
| 174 | is($res->return_code, 0, "OK as no thresholds" ); | 184 | is($res->return_code, 0, "OK as no thresholds" ); |
| 175 | is($res->output, "SNMP OK - 70660 | iso.3.6.1.4.1.8072.3.2.67.10=70660c ", "Check label"); | 185 | is($res->output, "SNMP OK - test test 71326 | 'test test'=71326c ", "Check label"); |
| 176 | 186 | ||
| 177 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 -l 'test test'" ); | ||
| 178 | is($res->return_code, 0, "OK as no thresholds" ); | ||
| 179 | is($res->output, "SNMP OK - test test 71326 | 'test test'=71326c ", "Check label"); | ||
| 180 | 187 | ||
| 188 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts))."' ./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets_per_minute --rate-multiplier=60" ); | ||
| 189 | is($res->return_code, 0, "OK for first call" ); | ||
| 190 | is($res->output, "No previous data to calculate rate - assume okay" ); | ||
| 181 | 191 | ||
| 182 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets_per_minute --rate-multiplier=60" ); | 192 | # test 1 second later |
| 183 | is($res->return_code, 0, "OK for first call" ); | 193 | $res = NPTest->testCmd("LC_TIME=C TZ=UTC faketime -f '".strftime("%Y-%m-%d %H:%M:%S", localtime($ts+1))."' ./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets_per_minute --rate-multiplier=60" ); |
| 184 | is($res->output, "No previous data to calculate rate - assume okay" ); | 194 | is($res->return_code, 0, "OK as no thresholds" ); |
| 185 | 195 | is($res->output, "SNMP RATE OK - inoctets_per_minute 39960 | inoctets_per_minute=39960 ", "Checking multiplier"); | |
| 186 | # Need to sleep, otherwise duration=0 | 196 | }; |
| 187 | sleep 1; | ||
| 188 | 197 | ||
| 189 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.10 --rate -l inoctets_per_minute --rate-multiplier=60" ); | ||
| 190 | is($res->return_code, 0, "OK as no thresholds" ); | ||
| 191 | is($res->output, "SNMP RATE OK - inoctets_per_minute 39960 | inoctets_per_minute=39960 ", "Checking multiplier"); | ||
| 192 | 198 | ||
| 193 | 199 | ||
| 194 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.11 -s '\"stringtests\"'" ); | 200 | $res = NPTest->testCmd( "./check_snmp -H 127.0.0.1 -C public -p $port_snmp -o .1.3.6.1.4.1.8072.3.2.67.11 -s '\"stringtests\"'" ); |
