Commit graph

464 commits

Author SHA1 Message Date
Johannes Schmidt
09eaa19b6b Add debug output to find bug in PerfdataWriterConnection 2026-04-02 16:04:31 +02:00
Johannes Schmidt
dc9dbc7bdb Fix PerfdataWriterConnection test-cases on parallel build 2026-04-02 14:09:00 +02:00
Johannes Schmidt
a05e2a3554 Rename EnsureCertFor to GetCertFor 2026-03-31 16:31:49 +02:00
Johannes Schmidt
f9a7e004b5 Generate ctest fixtures for generating CA and certificates 2026-03-31 16:31:49 +02:00
Johannes Schmidt
7c59c11417 Give CTestProperties a polymorphic interface 2026-03-31 16:31:49 +02:00
Johannes Schmidt
20ff982127 Make unit-test data and cache directory unique per test
This is necessary for parallel test execution so that tests don't overwrite
or delete (destructor of the fixture) data in these directories.

This is implemented by generating a unique name for each test with
`Utility::NewUniqueId()`.
2026-03-31 16:31:49 +02:00
Johannes Schmidt
c844a10dd4 Add network label to http tests
Mostly unrelated change to add the network label to test suites
already touched by other changes in this PR. The label is already
used for the perfdata writer tests to make it easy to exclude tests
that need a network connection when building and testing in a sandbox.
2026-03-31 16:31:49 +02:00
Johannes Schmidt
72ebd43ef1 Give base_timer/(invoke|scope) timers a 10x multiplier on Windows 2026-03-31 09:33:09 +02:00
Johannes Schmidt
3f670463f4 Revert "Give timer tests more leeway for inaccurate implementations"
This reverts commit 1430e63e72.
2026-03-31 09:32:28 +02:00
Julian Brost
6592eae21d
Merge pull request #10668 from Icinga/perfdata-writers-connection-handling
Add PerfdatawriterConnection to handle network requests for Perfdata Writers
2026-03-17 15:10:57 +01:00
Johannes Schmidt
75b2ec6d96 Add unit-tests for PerfdataWriterConnection
There's a set of two tests for each perfdatawriter, just
to make sure they can connect and send data that looks reasonably
correct, and to make sure pausing actually works while the connection
is stuck.

Then there's a more in-depth suite of tests for PerfdataWriterConnection
itself, to verify that connection handling works well in all types
of scenarios.

Co-authored-by: Yonas Habteab <yonas.habteab@icinga.com>
2026-03-17 12:11:30 +01:00
Johannes Schmidt
e153e6d079 Fix CertificateFixture error if previous test fails 2026-03-12 09:35:13 +01:00
Johannes Schmidt
d7409aad27 Add a new CTest fixture for dirty_ssl_certs for tlsutility
This doesn't fix any concrete errors in master, but if tests ever get
reordered for some reason and the tlsutility tests run before the
http tests, they will leave broken certificates behind. This could
be solved by cleaning up manually in the tests, but that again could
cause issues if the tlsutility tests ever run in the middle of the
http ones.

The proper solution is using a CTest fixture to establish a dependency
where the tlsutility tests always run before the tests using a new
CTest fixture that provides the cleanup between these test groups.
2026-03-11 14:26:48 +01:00
Johannes Schmidt
1430e63e72 Give timer tests more leeway for inaccurate implementations
On Windows, waiting on system timers is notoriously inaccurate, with
short sleeps taking tens of milliseconds longer than specified.

This led to these tests to sporadically fail on the Windows GHAs with
`check 5 == counter has failed [5 != 4]`, because it couldn't get the
expected five invokations within the given tolerance of 50ms.

Currently on master, the tests check if a timer triggers five times
in 550ms with a 100ms interval, only leaving those 50ms to spare.
This commit extends the tolerance of to 75ms. This is a pretty
conservative increase (when we could have gone to 99ms), but it
might be enough to satisfy the windows GHAs.
2026-03-03 14:10:33 +01:00
Johannes Schmidt
11d099f4bb Add Assert-Macros for the TestLogger
Also add a Clear() function to clear existing log content.
2026-02-26 13:31:10 +01:00
Johannes Schmidt
6fc9130983 Move and extend ReceiveCheckResults function 2026-02-26 13:31:10 +01:00
Johannes Schmidt
e339a229ba Add TestThread class to not get unit-tests stuck in join()s 2026-02-26 13:31:10 +01:00
Yonas Habteab
d4d46a9780 HTTP: stream responses where appropriate 2026-02-11 09:47:39 +01:00
Yonas Habteab
32887884e5 Make ValueGenerator more flexible & easy to use
This commit refactors the ValueGenerator class to be a template that can
work with any container type. Previously, one has to manually take care
of the used container by lazily iterating over it within a lambda. Now,
the `ValueGenerator` class itself takes care of all the iteration,
making it easier to use and less error-prone. The new base `Generator`
class is required to allow the `JsonEncoder` to handle generators in a
type-erased manner.
2026-02-10 16:57:56 +01:00
Julian Brost
4b4d15ce72
Merge pull request #10700 from Icinga/license-gpl3-later
Some checks failed
Container Image / Container Image (push) Has been cancelled
Linux / alpine:bash (push) Has been cancelled
Linux / amazonlinux:2 (push) Has been cancelled
Linux / amazonlinux:2023 (push) Has been cancelled
Linux / debian:11 (linux/386) (push) Has been cancelled
Linux / debian:11 (push) Has been cancelled
Linux / debian:12 (linux/386) (push) Has been cancelled
Linux / debian:12 (push) Has been cancelled
Linux / debian:13 (push) Has been cancelled
Linux / fedora:41 (push) Has been cancelled
Linux / fedora:42 (push) Has been cancelled
Linux / fedora:43 (push) Has been cancelled
Linux / opensuse/leap:15.6 (push) Has been cancelled
Linux / opensuse/leap:16.0 (push) Has been cancelled
Linux / registry.suse.com/bci/bci-base:16.0 (push) Has been cancelled
Linux / registry.suse.com/suse/sle15:15.6 (push) Has been cancelled
Linux / registry.suse.com/suse/sle15:15.7 (push) Has been cancelled
Linux / rockylinux/rockylinux:10 (push) Has been cancelled
Linux / rockylinux:8 (push) Has been cancelled
Linux / rockylinux:9 (push) Has been cancelled
Linux / ubuntu:22.04 (push) Has been cancelled
Linux / ubuntu:24.04 (push) Has been cancelled
Linux / ubuntu:25.04 (push) Has been cancelled
Linux / ubuntu:25.10 (push) Has been cancelled
Windows / Windows (push) Has been cancelled
Upgrade license to GPLv3 & replace existing copyright with SPDX header
2026-02-05 13:14:54 +01:00
Johannes Schmidt
e26b1041c7 Use noop lambda in dummy NotificationCommand
The dummy command would sometimes fail with a "broken pipe" error
on slow runners like the arm64 container image one, so this commit
replaces them with executing a noop lambda. Using "/bin/echo" might
also have been fine, but with this there isn't even a process spawned
that can get a broken pipe.
2026-02-05 10:15:55 +01:00
Johannes Schmidt
f8c15b1b28 Fix notificationcomponent test-cases with fixed TestLoggerFixture
Due to the changes in the previous commit, the test-cases for
notitificationcomponent now also pick up LogDebug level messages that
also fit the pattern. To get the test-cases working again a second
pattern is needed to exclude these.
2026-02-05 10:09:15 +01:00
Yonas Habteab
161f16641f tests: fix min severity doesn't get updated
If the logger is started with `Activate()` before `SetActive()`, it won't
log anything, as the logger updates the "min severity" value of loggers
only when starting them, and if they're not active at that point, they
will just be ignored, so the min severity remains at info.
2026-02-05 09:47:47 +01:00
Yonas Habteab
91c7e60df8 Replace all existing copyright headers with SPDX headers
I've used the following command to replace the original copyright header
lines in a C-style comment block:

```
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f -exec perl -pi -e 's{/\*[^*]*\(\s*c\s*\)\s*(\d{4})\s*Icinga\s+GmbH[^*]*\*/}{// SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n// SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
```

For files that use shell-style comments (#) like CMakeLists.txt, I've
used this command:

```
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f -exec perl -pi -e 's{#.*\(\s*c\s*\)\s(\d{4})\sIcinga\s+GmbH.*}{# SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n# SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
```

And for SQL files:

```
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f \( -name '*.sql' \) -exec perl -pi -e 's{--.*\(c\)\s(\d{4})\sIcinga\sGmbH.*}{-- SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n-- SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
$ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f \( -name '*.sql' \) -exec perl -pi -e 's{-- Copyright \(c\)\s(\d{4})\sIcinga\s+Development\sTeam.*}{-- SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n-- SPDX-License-Identifier: GPL-2.0-or-later}gi' {} +
```
2026-02-04 14:00:05 +01:00
Johannes Schmidt
1505f09ed6 Refactor HttpMessage into generalized templated types
This adds generalized IncomingHttpMessage and OutgoingHttpMessage templates
that support different types of streams (via a std::variant) and can both
be used for either requests or responses.

The tacked on metadata from the old HttpRequest and server connection from
the old HttpServerConnection have been moved to HttpApi(Request|Response)
classes that derive from the above generalized message types.
2026-01-22 17:20:32 +01:00
Johannes Schmidt
a0f603f608 Update names of HttpRequest and HttpResponse 2026-01-22 12:41:21 +01:00
Johannes Schmidt
5145e2f526 Add test-case to verify delayed (times) notifications feature 2026-01-13 10:55:24 +01:00
Johannes Schmidt
f7b801d367 Add test-case to reproduce a race condition in NotificationComponent
The race is between `NotificationTimerHandler`, which sends a reminder notification
after a certain inverval during problem states and `SendNotificationsHandler` which
sends out the notifications on state changes.

When the timer handler runs just before a state change triggers a notification, the
timer handler might pick up that state-change before the send notification handler
can set its no_more_notifications flag. In that case a "reminder" notification will
be sent out before the initial one, and despite `interval = 0` on the notification
object.
2026-01-12 10:49:48 +01:00
Yonas Habteab
213ae2e1f3 tests: verify statically provided certs as well
Co-Authored-By: Alexander A. Klimov <alexander.klimov@icinga.com>
2025-12-05 10:26:21 +01:00
Yonas Habteab
949e5d3e1d Test internal cert generation & verification process 2025-12-04 13:25:38 +01:00
Yonas Habteab
dc8cf202ad tests: skip superfluous cert generation in EnsureCertFor()
The certificate generated by `PkiUtility::NewCert()` is self-signed,
and so the subsequent `PkiUtility::SignCsr()` call is required.
However, `PkiUtility::SignCsr()` doesn't reuse existin cert, instead
it'll generate a fresh one on its own. So, skip the first one entirely!
2025-12-04 13:01:48 +01:00
Julian Brost
aca67f6d88 HttpUtility: add functions for validating HTTP header names and values 2025-11-28 16:19:19 +01:00
Yonas Habteab
ed9014103f
Merge pull request #10609 from Icinga/fix-misc-compiler-warnings
Some checks failed
Container Image / Container Image (push) Has been cancelled
Linux / alpine:bash (push) Has been cancelled
Linux / amazonlinux:2 (push) Has been cancelled
Linux / amazonlinux:2023 (push) Has been cancelled
Linux / debian:11 (linux/386) (push) Has been cancelled
Linux / debian:11 (push) Has been cancelled
Linux / debian:12 (linux/386) (push) Has been cancelled
Linux / debian:12 (push) Has been cancelled
Linux / debian:13 (push) Has been cancelled
Linux / fedora:41 (push) Has been cancelled
Linux / fedora:42 (push) Has been cancelled
Linux / opensuse/leap:15.6 (push) Has been cancelled
Linux / opensuse/leap:16.0 (push) Has been cancelled
Linux / registry.suse.com/suse/sle15:15.6 (push) Has been cancelled
Linux / registry.suse.com/suse/sle15:15.7 (push) Has been cancelled
Linux / rockylinux/rockylinux:10 (push) Has been cancelled
Linux / rockylinux:8 (push) Has been cancelled
Linux / rockylinux:9 (push) Has been cancelled
Linux / ubuntu:22.04 (push) Has been cancelled
Linux / ubuntu:24.04 (push) Has been cancelled
Linux / ubuntu:25.04 (push) Has been cancelled
Windows / Windows (push) Has been cancelled
Fix misc compiler warnings
2025-11-19 14:26:57 +01:00
Johannes Schmidt
a2e0ce426f Fix -Wunused-variable warnings 2025-11-19 12:00:58 +01:00
Johannes Schmidt
c55c191aba Fix -Wunknown-pragmas warnings 2025-11-19 12:00:58 +01:00
Johannes Schmidt
93e69ed0e8 Fix -Wsign-compare warnings 2025-11-19 12:00:58 +01:00
Johannes Schmidt
75c7d28bb1 Adapt the unit-test to reflect fix in the previous commit 2025-11-03 15:39:39 +01:00
Johannes Schmidt
68b3b9fd3a Add unit-tests for NotificationComponent
This includes a few common scenarios and a reproduction of the current behavior
affected by the underlying bug of issue #10575. This is done both to document
the change in behavior, as well as to ensure the behavior of the other scenarios
stays the same before and after the fix is applied.
2025-11-03 15:39:35 +01:00
Johannes Schmidt
84cdddb176 Add ClearTestLogger method to TestLoggerFixture 2025-10-22 10:31:17 +02:00
Alexander Aleksandrovič Klimov
c25297e26a
Merge pull request #9729 from Icinga/fix-compiler-warnings-by-removing-unused-variables
Some checks are pending
Container Image / Container Image (push) Waiting to run
Linux / alpine:bash (push) Waiting to run
Linux / amazonlinux:2 (push) Waiting to run
Linux / amazonlinux:2023 (push) Waiting to run
Linux / debian:11 (linux/386) (push) Waiting to run
Linux / debian:11 (push) Waiting to run
Linux / debian:12 (linux/386) (push) Waiting to run
Linux / debian:12 (push) Waiting to run
Linux / debian:13 (push) Waiting to run
Linux / fedora:41 (push) Waiting to run
Linux / fedora:42 (push) Waiting to run
Linux / opensuse/leap:15.6 (push) Waiting to run
Linux / opensuse/leap:16.0 (push) Waiting to run
Linux / registry.suse.com/suse/sle15:15.6 (push) Waiting to run
Linux / registry.suse.com/suse/sle15:15.7 (push) Waiting to run
Linux / rockylinux/rockylinux:10 (push) Waiting to run
Linux / rockylinux:8 (push) Waiting to run
Linux / rockylinux:9 (push) Waiting to run
Linux / ubuntu:22.04 (push) Waiting to run
Linux / ubuntu:24.04 (push) Waiting to run
Linux / ubuntu:25.04 (push) Waiting to run
Windows / Windows (push) Waiting to run
Fix compiler warnings by removing unused variables
2025-10-17 15:12:05 +02:00
Alexander A. Klimov
3d69a31043 Fix compiler warnings by removing unused variables 2025-10-17 09:56:46 +02:00
Julian Brost
cfff82ba05
Merge commit from fork
Some checks are pending
Container Image / Container Image (push) Waiting to run
Linux / alpine:bash (push) Waiting to run
Linux / amazonlinux:2 (push) Waiting to run
Linux / amazonlinux:2023 (push) Waiting to run
Linux / debian:11 (linux/386) (push) Waiting to run
Linux / debian:11 (push) Waiting to run
Linux / debian:12 (linux/386) (push) Waiting to run
Linux / debian:12 (push) Waiting to run
Linux / debian:13 (push) Waiting to run
Linux / fedora:41 (push) Waiting to run
Linux / fedora:42 (push) Waiting to run
Linux / opensuse/leap:15.6 (push) Waiting to run
Linux / registry.suse.com/suse/sle15:15.6 (push) Waiting to run
Linux / registry.suse.com/suse/sle15:15.7 (push) Waiting to run
Linux / rockylinux/rockylinux:10 (push) Waiting to run
Linux / rockylinux:8 (push) Waiting to run
Linux / rockylinux:9 (push) Waiting to run
Linux / ubuntu:22.04 (push) Waiting to run
Linux / ubuntu:24.04 (push) Waiting to run
Linux / ubuntu:25.04 (push) Waiting to run
Windows / Windows (push) Waiting to run
DerefExpression: Add missing nullptr check
2025-10-16 14:14:45 +02:00
Julian Brost
56255ac7a6
Merge commit from fork
Check for permissions when evaluating object filters
2025-10-16 14:13:36 +02:00
Julian Brost
3de8975223
Merge pull request #10551 from Icinga/add-github-problem-matchers
Add Github Problem Matchers actions for GCC/MSVC
2025-10-16 11:32:28 +02:00
Julian Brost
a02a4594f4 DerefExpression: Add missing nullptr check
Due to this missing check, evaluating a DSL expression can result in a null
dereference, crashing the Icinga 2 process. Given that API users can also
provide DSL expression as filters, this can be triggered over the network as
well.

This issue was assigned CVE-2025-61908.
2025-10-08 10:04:52 +02:00
Johannes Schmidt
578ad5115e Add test-cases for checking permissions in filter exprs 2025-10-02 15:51:42 +02:00
Johannes Schmidt
ec1f44879a Remove MSVC warnings about unknown pragmas GCC/clang 2025-09-24 15:43:09 +02:00
Alexander A. Klimov
4b2b45c8a1 Introduce AtomicDuration 2025-09-23 11:04:58 +02:00
Johannes Schmidt
9469478d7c Rename/Move existing certs/ca instead of symlinking 2025-09-16 13:35:18 +02:00
Yonas Habteab
5f862ce3bb HttpServerConnection: use std::chrono for m_Seen 2025-09-12 13:40:36 +02:00