Commit graph

132 commits

Author SHA1 Message Date
Ahmet Oeztuerk
f8db90c206 check_curl redirection test improvements
previously, the fragment was sent in the request from client, and the
server would parse and increment its value. the incremented value would
be set in the redirected URI.

this does not work as fragments are meaningless to servers and clients
like check_curl strip them in their GET request.

rewrite the fragment handling . if client sends a URI parameter with
'fragment' as its key, the server will set its value for its redirected
URI. it will come up both as a parameter and the fragment at the end.

use this new logic to rewrite the fragment redirection test. remove -p
$http_port argument on tests for this endpoint, which was making https
tests fail. correct the common test count from 75 to 95, as there are 20
total test assertions in the 8 times it uses the new endpoint. remove
unused code on that endpoint as well
2025-12-12 11:29:35 +01:00
Ahmet Oeztuerk
737af667a2 clairfy new check_curl tests
use the parameters in the last redirected URI that that server returns
HTTP OK to. matches the incrementation count of redirection_count from 0
to 3, as they also get incremented three times alongside it. add
comments about what is happening in the test cases, no need to
understand the endpoint completely
2025-12-11 10:37:05 +01:00
Ahmet Oeztuerk
feeade0817 fix typos 2025-12-10 17:09:46 +01:00
Ahmet Oeztuerk
f7df5579ab check_curl add tests for uri field parsing
plugins/tests/check_curl.t forks and runs a http(s) server that responds
to specific uri endpoints. Added another endpoint under
/redirect_with_increment with dynamic redirection points.

This endpoint will parse different parts of the uri that come after the
path: parameters, query and the fragment. If applicable, seperate
elements within each field are parsed into key/value pairs. value is
incremented in redirected URI.

Tests if check_url redirection logic retains different parts of the url
when parsing the uri and building the new redirected URL. Current tests
show that it ignores the fragment part.
2025-12-09 00:13:15 +01:00
Lorenz Kästle
30a9908d8d
Remove check_nt (#2195)
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Spellcheck / codespell (push) Waiting to run
Tests / Running unit and integrationt tests (push) Waiting to run
Tests / Running rpm build test on almalinux:9 (push) Waiting to run
Tests / Running rpm build test on fedora:latest (push) Waiting to run
Tests / Running rpm build test on rockylinux:8 (push) Waiting to run
check_nt was used to connect NSclient++ on windows, both the method
and the target are pretty much dead.
Therefor check_nt gets removed.
2025-12-03 22:39:19 +01:00
Lorenz Kästle
802e46f8ea Run clang-format again 2025-09-15 12:59:37 +02:00
Lorenz Kästle
404d52efb9 Fix/adapt tests 2025-09-15 01:58:26 +02:00
Lorenz Kästle
6ae8ba9110 check_curl: test adaption and output adaption 2025-09-13 12:49:06 +02:00
Lorenz Kästle
87195f5511 check_snmp: refactoring + fixes
This commit moves the state retention logic to check_snmp as it is only
used there and I do not want it to be used at all, so it doesn't get a
place in the lib.

Otherwise this adapts tests and fixes the rate computing in the
refactored version of check_snmp.
Also fixes some bugs detected with the tests
2025-09-08 15:57:06 +02:00
Lorenz Kästle
1aefb1f9df snmp: fix complaint of snmpd about paths 2025-09-08 15:54:08 +02:00
Lorenz Kästle
76971dea75 Address check_disk changes in tests 2025-03-30 22:38:12 +02:00
Lorenz Kästle
42531fa92a Refactor test_check_disk.c 2025-03-18 16:23:33 +01:00
Lorenz Kästle
59e0a258f9 Migrate disk tests from lib, tool 2025-03-18 15:57:44 +01:00
Lorenz Kästle
ecbd9e9cb3 test_check_swap: declare verbose in tests for now 2024-11-10 01:30:40 +01:00
Lorenz Kästle
801d0faf45 test_check_swap: improvements and updates to unit test code 2024-11-10 01:28:52 +01:00
Lorenz Kästle
3faeed07c4 Merge branch 'master' into check_swap_again 2024-11-02 13:37:39 +01:00
Sven Nierlein
acbfbf3de6 check_curl: fix relative redirects on non-standard port
Having a webserver respond with a relative redirect as for ex. in `Location: /path/to.html`
check_curl would use the wrong standard http/https port instead
of crafting the absolute url using the given scheme/hostname and port.

Adding a new test case for this for check_http and check_curl. check_http did
it correct already, so no fix necessary there.

before:

    %>./check_curl -H 127.0.0.1 -p 50493 -f follow -u /redirect_rel -s redirected -vvv
    **** HEADER ****
    HTTP/1.1 302 Found
    ...
    Location: /redirect2

    ...
    * Seen redirect location /redirect2
    ** scheme: (null)
    ** host: (null)
    ** port: (null)
    ** path: /redirect2
    Redirection to http://127.0.0.1:80/redirect2

fixed:

    %>./check_curl -H 127.0.0.1 -p 50493 -f follow -u /redirect_rel -s redirected -vvv
    **** HEADER ****
    HTTP/1.1 302 Found
    ...
    Location: /redirect2

    ...
    * Seen redirect location /redirect2
    ** scheme: (null)
    ** host: (null)
    ** port: (null)
    ** path: /redirect2
    Redirection to http://127.0.0.1:50493/redirect2

Signed-off-by: Sven Nierlein <sven@nierlein.de>
2024-07-30 17:13:03 +02:00
RincewindsHat
735b04eff7 Fix tests 2024-01-04 02:37:26 +01:00
RincewindsHat
08c3f0f737 Add test proc/meminfo file and corresponding test 2023-12-20 10:02:47 +01:00
RincewindsHat
6fcbbaafc4 Implement first unit test for check_swap 2023-12-20 10:02:47 +01:00
RincewindsHat
e1e1291b72 Fix some more typos 2023-10-03 22:22:51 +02:00
Jan Wagner
0f3703e641 Fix a lot of typos reported by codespell 2023-04-14 18:35:00 +00:00
Christian Kujau
3e3e225b3f check_procs: add a test for the newly added -X option.
$ make test
[...]
perl -I .. -I .. ../test.pl
No application (check_curl) found for test harness (check_curl.t)
No application (check_snmp) found for test harness (check_snmp.t)
./t/check_procs.t ...... ok
./tests/check_nt.t ..... ok
./tests/check_procs.t .. ok
All tests successful.
Files=4, Tests=73,  8 wallclock secs ( 0.05 usr  0.02 sys +  0.38 cusr
0.22 csys =  0.67 CPU)
Result: PASS

Signed-off-by: Christian Kujau <lists@nerdbynature.de>
2023-03-21 11:49:08 +01:00
RincewindsHat
03efbb8e4f check_http: Implement special case test for zero size chunk only 2023-02-06 12:15:46 +01:00
Sven Nierlein
07561a67ab tests: fix chunked encoding test server 2023-01-07 18:34:46 +01:00
Sven Nierlein
c256af44fb check_http/check_curl: add chunked encoding test 2023-01-07 18:34:46 +01:00
Sven Nierlein
9ba8f5ed66 check_snmp: always apply format when applying multiplier 2022-12-22 12:54:51 +01:00
Robert Bohne
def946bd97 Improve tests for check_snmp & multiply option 2022-12-22 12:54:51 +01:00
Wolfgang Nieder
c35bf8966a add 'multiplier' to modify current value 2022-12-22 12:54:51 +01:00
Tobias Wiese
31bdbfce92 sslutils: use chain from client certificates
sslutils used to load only the first certificate when it was given a
client certificate file.

Added tests for check_http to connect to a http server that expects a
client certificate (simple and with chain).

Signed-off-by: Tobias Wiese <tobias@tobiaswiese.com>
2022-01-30 12:25:56 +01:00
RincewindsHat
4549a95243
Merge pull request #1654 from wolfgangkarall/master
check_procs -- exchange needle and haystack in strstr() for proper st…
2021-11-17 18:09:25 +01:00
Sven Nierlein
024d268386 check_snmp: fix performance thresholds when using multiple oids
when using check_snmp with multiple oids it simply printed the unparsed content
from -w/-c into the thresholds for each oid. So each oid contained the hole -w
from all oids.

./check_snmp ... -o iso.3.6.1.2.1.25.1.3.0,iso.3.6.1.2.1.25.1.5.0 -w '1,2' -c '3,4'

before:
  SNMP ... | HOST-RESOURCES-MIB::hrSystemInitialLoadDevice.0=393216;1,2;3,4 HOST-RESOURCES-MIB::hrSystemNumUsers.0=24;1,2;3,4

after:
  SNMP ... | HOST-RESOURCES-MIB::hrSystemInitialLoadDevice.0=393216;1;3 HOST-RESOURCES-MIB::hrSystemNumUsers.0=24;2;4

This also applies to fixed thresholds since check_snmp translates negative infinities from: '~:-1' to '@-1:~'
2021-11-17 14:04:09 +01:00
Sven Nierlein
c3abdb9267 check_procs: add test for elapsed time 2021-11-01 13:35:11 +01:00
Sven Nierlein
1fda28f124 remove unused test file
Signed-off-by: Sven Nierlein <sven@nierlein.de>
2021-11-01 13:35:11 +01:00
Sven Nierlein
282ccd4a8b check_procs: improve ps args autodetection
one of the first ps commands in the configure.ac is `axwo 'stat comm vsz rss user uid pid ppid args'` which
works on most modern linux systems (checked debian 10/11 and centos 7/8). But this test misses the etime
argument. Therefore `check_procs --metric=ELAPSED` does not work.

To fix this, we simply do the same test including etime before that one.

Signed-off-by: Sven Nierlein <sven@nierlein.de>
2021-11-01 13:35:11 +01:00
Sven Nierlein
b428cc17f7 tests: ignore sigpipes in https test daemon
check_http closes the connection after checking the certificate with -C. This leads to sigpipe
errors when the ssl daemon wants to send a response and the daemon quits which makes the
subsequent tests fail.
2021-05-20 20:57:59 +02:00
Sven Nierlein
eb75d847ae tests: increase startup sleep
github action might fail from to time otherwise
2021-05-20 18:04:49 +02:00
Sven Nierlein
5cfc93d995 fix check_curl crash if http header contains leading spaces
check_curl crashes when a (broken) http server returns invalid http header with
leading spaces or double colons. This PR adds a fix and a test case for this.

Signed-off-by: Sven Nierlein <sven@nierlein.de>
2021-03-11 13:33:16 +01:00
Wolfgang Karall-Ahlborn
9076ea36f7 check_procs -- update test data too 2021-01-03 12:18:31 +01:00
Sven Nierlein
d54f14a092 merge test changes from check_http
the example certificate has changed since.
2020-05-15 14:24:18 +02:00
Sven Nierlein
072e97d5de tests: update expired test certificate
the certificate used to test expired http checks is to old to be used
with recent ssl libraries and results in:

> SSL routines:SSL_CTX_use_certificate:ee key too small

unfortunatly the error is only visible when setting $IO::Socket::SSL::DEBUG in
the check_http.t file.
2020-05-15 14:24:18 +02:00
Andreas Baumann
2f4d6764d7 Merge branch 'master' into feature_check_curl 2019-04-04 13:09:15 +02:00
Sven Nierlein
8442ed5b41 renew test certificates
Signed-off-by: Sven Nierlein <sven@nierlein.de>
2019-02-19 16:35:28 +01:00
Sven Nierlein
22f47fc0c5 tests: make check_snmp test more reliable
The check_snmp rate tests depend on the exact amount of time spend between the
plugin runs and will fail on busy machines, ex. the ci servers. Using faketime
mitigates this issue and also removes all the sleeps.

Signed-off-by: Sven Nierlein <sven@nierlein.de>
2019-01-21 17:41:02 +01:00
Christopher Odenbach
7e9d9a5629 added some advanced tests for check_curl 2018-10-22 16:30:31 +02:00
Andreas Baumann
28a4c7076a synched tests/check_http.t test changes (virtualhost) into tests/check_curl.t 2018-10-22 16:30:31 +02:00
Andreas Baumann
54c8f76c72 fixed test outputs for status line checks
handling empty data in POST and PUT
handling data upload (from -P <postdata>) also in PUT
2018-10-22 16:30:31 +02:00
Andreas Baumann
bbec77c7ec made check_curl tests copies of check_http tests because they will differ slightly 2018-10-22 16:30:31 +02:00
Sven Nierlein
e9239b556a check_curl: make check_curl use the same tests as check_http 2018-10-22 16:30:31 +02:00
Christopher Odenbach
9326543c2e Added tests for virtual port behaviour. Separated from all other tests this time. 2017-03-26 22:36:58 +02:00