Commit Graph

49 Commits

Author SHA1 Message Date
Isaac Connor
334994bd3f Fix appending %% instead of % when uri decoding. Add test for URIEncode 2026-02-04 20:45:46 -05:00
Ben Dailey
2dc48e4335 feat: add per-topic alarm expiry using PullMessagesResponse TerminationTime
Cameras like Reolink send alarm=true but never send the corresponding
false, causing alarms to stick indefinitely. Use the TerminationTime
from PullMessagesResponse to auto-expire stale per-topic alarms.

- Add AlarmEntry struct with value and termination_time fields
- Extract TerminationTime from each PullMessagesResponse and attach
  it to alarm entries; refresh on re-trigger so active alarms persist
- Sweep expired alarms after processing messages and on poll timeout
- Add expire_alarms option (default: true) to disable via onvif_options
- Fix TOCTOU race: remove unsynchronized alarms.empty() check before
  acquiring mutex in the timeout sweep path
- Simplify SetNoteSet with C++17 structured bindings
- Add Catch2 tests for alarm expiry logic (mirrored struct to avoid
  gSOAP header dependency)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 05:52:31 -05:00
copilot-swe-agent[bot]
d905753b5e test: add ISO 8601 formatting tests for ONVIF absolute time renewal
Co-authored-by: connortechnology <925519+connortechnology@users.noreply.github.com>
2026-01-13 04:02:21 +00:00
copilot-swe-agent[bot]
e62f0c0e4e feat: add ONVIF subscription cleanup to prevent leaks
Add cleanup_subscription() helper method that properly unsubscribes
from ONVIF cameras with error handling. This prevents subscription
leaks when renewals fail or when restarting subscriptions.

Changes:
- Add cleanup_subscription() method to header and implementation
- Call cleanup on renewal failures in Renew()
- Call cleanup when start() detects existing soap context
- Improve destructor logging for unsubscribe failures
- Add test documentation for cleanup behavior

Refs: ONVIF subscription leak issue

Co-authored-by: connortechnology <925519+connortechnology@users.noreply.github.com>
2026-01-11 14:30:50 +00:00
copilot-swe-agent[bot]
8f2799f0de Implement ONVIF subscription renewal optimization with time tracking
- Add subscription_termination_time and next_renewal_time tracking to ONVIF class
- Add update_renewal_times() helper method to parse and store termination times
- Initialize renewal tracking in constructor
- Capture TerminationTime from CreatePullPointSubscriptionResponse
- Update times after successful Renew operations
- Implement conditional renewal logic in WaitForMessage() to only renew 10 seconds before expiration
- Add unit tests for renewal timing logic

This reduces unnecessary ONVIF traffic by only renewing subscriptions when needed,
following ONVIF specification best practices.

Co-authored-by: connortechnology <925519+connortechnology@users.noreply.github.com>
2026-01-09 19:36:34 +00:00
Isaac Connor
44e47c975f Update to Catch2 v3 2024-05-08 14:16:05 -04:00
Isaac Connor
365830a9ae Rough in remove_password function + tests 2022-07-04 09:53:50 -04:00
Isaac Connor
c3d7c306fc Add tests for mask_authentication 2022-04-18 13:33:22 -04:00
Peter Keresztes Schmidt
46155942c1 Misc: Rename namespace ZM to zm
We had a mixture of both spellings. Unify it according to our code-style.
2021-06-06 19:11:11 +02:00
Peter Keresztes Schmidt
9a983bb321 Crypto: Implement SHA1 hashing 2021-05-30 22:56:21 +02:00
Peter Keresztes Schmidt
d2932b5d68 Utils: Add a ByteArrayToHexString helper 2021-05-30 22:53:05 +02:00
Peter Keresztes Schmidt
2bda413698 Crypto: Implement a generic hashing API
Currently MD5 is implemented
2021-05-30 22:53:05 +02:00
Peter Keresztes Schmidt
9900fc1273 tests/Font: Avoid lambda capture initialization
Remove the use of this language feature until we raise the requirements to C++14.
2021-05-24 00:55:46 +02:00
Peter Keresztes Schmidt
298415fff3 Remove remaining usages of VLAs 2021-05-17 22:12:04 +02:00
Peter Keresztes Schmidt
b1de220958 Polygon: Perform clip operation on existing object instead of returning a new clipped one 2021-05-16 19:42:41 +02:00
Peter Keresztes Schmidt
29488900a1 Box: Make range calculations mathematically correct 2021-05-16 19:41:45 +02:00
Peter Keresztes Schmidt
3c85d63655 Polygon: Implement clipping to a boundary box
Using the Sutherland-Hodgman algorithms convex and concave subject polygons can be clipped
by convex clip polygons.
For now we only need clipping to rectangles (Box), so limit our implementation to that. If needed this can be
trivially extended to convex clip polygons (a check whether the clip polygon is actually convex has to be added).
If convex clip polygons are needed we have to switch to e.g the Vatti algorithm.
2021-05-16 19:41:45 +02:00
Peter Keresztes Schmidt
c2a7f7b593 tests/Box: Add unit tests 2021-05-16 16:42:58 +02:00
Peter Keresztes Schmidt
e6c159fb70 Vector2: Make coordinate components public
The components were already unconditionally/without side-effects writable. Let's make them public so we don't need the setters.
2021-05-16 16:42:58 +02:00
Peter Keresztes Schmidt
707700e24e Vector2: Add unit tests 2021-05-14 20:14:50 +02:00
Peter Keresztes Schmidt
68bedfe48f Fix logging format string mismatches
* Remove SZFMTD format macro and use %zu instead for size_t. %zu is understood by every compiler nowadays.
2021-04-30 00:26:24 +02:00
Peter Keresztes Schmidt
3020acf994 ZmFont: Store character padding in font file
The size/variant specific character padding should be stored with the font data.
Modify the FontBitmapHeader accordingly and introduce a version field in the FontFileHeader
so we are able to check we have a font file with the right structure associated with that version.

The version field is set to 1 in this changeset.
2021-04-25 23:13:21 +02:00
Peter Keresztes Schmidt
07e49e47af utils: Add a clamping function mimicking std::clamp
This can be replaced with std::clamp in C++17.
2021-04-25 23:13:21 +02:00
Peter Keresztes Schmidt
4d14347c42 tests: Add tests for ZmFont 2021-04-25 23:13:21 +02:00
Peter Keresztes Schmidt
369fb68bb4 tests/comms: Disable tests which bind TCP sockets on CI runs
Those tests timeout on Cirrus. Disable them for now.
This introduces a new tag [notCI] with which tests can be marked which shouldn't be run during CI.
2021-04-11 02:46:56 +02:00
Peter Keresztes Schmidt
f84d23817e tests/comms: Add tests for TcpInetClient/Server 2021-04-11 01:28:23 +02:00
Peter Keresztes Schmidt
25e6b70381 tests/comms: Add tests for ZM::UdpUnixSocket 2021-04-11 01:28:23 +02:00
Peter Keresztes Schmidt
17485f3547 tests/comms: Add tests for ZM::UdpInetSocket 2021-04-11 01:28:23 +02:00
Peter Keresztes Schmidt
45986c8ee2 tests/comms: Add some tests for SockAddrInet/Unix 2021-04-11 01:28:23 +02:00
Peter Keresztes Schmidt
5aa508bc74 tests/comms: Add read/write tests for ZM::Pipe 2021-04-11 01:28:23 +02:00
Peter Keresztes Schmidt
a06d374292 tests/comms: Add some basic tests for ZM::Pipe 2021-04-11 01:28:23 +02:00
Peter Keresztes Schmidt
545f0dbb96 utils: cleanup Base64Encode 2021-04-04 00:39:40 +02:00
Peter Keresztes Schmidt
e330f8553d utils: cleanup Split and Join 2021-04-04 00:30:18 +02:00
Peter Keresztes Schmidt
39a896f5b6 utils: cleanup StartsWith 2021-04-03 23:51:12 +02:00
Peter Keresztes Schmidt
3dbf13e00b utils: cleanup ReplaceAll 2021-04-03 23:50:35 +02:00
Peter Keresztes Schmidt
664cd649f8 utils: cleanup Trim (was trimSet) and TrimSpaces 2021-04-03 23:30:59 +02:00
Peter Keresztes Schmidt
3968a411a0 tests/utils: Add tests for QueryString 2021-04-03 22:37:44 +02:00
Peter Keresztes Schmidt
fa7c420442 tests/utils: Add tests for UriDecode 2021-04-03 22:37:44 +02:00
Peter Keresztes Schmidt
46a4b615c8 tests/utils: Add tests for base64Encode
Test vectors according to RFC4648
2021-04-03 22:37:44 +02:00
Peter Keresztes Schmidt
bbc4afcf1b tests/utils: Add tests for join 2021-04-03 22:37:44 +02:00
Peter Keresztes Schmidt
e54c10fdb4 tests/utils: Add tests for StringVector split(const std::string&, const std::string&, int limit=0) 2021-04-03 22:37:44 +02:00
Peter Keresztes Schmidt
64cf69ebc1 tests/utils: Add tests for int split(const char*, const char, std::vector<std::string>&) 2021-04-03 22:37:44 +02:00
Peter Keresztes Schmidt
bde0bde066 tests/utils: Add tests for startsWith 2021-04-03 22:35:03 +02:00
Peter Keresztes Schmidt
13f91b5826 tests/utils: Add tests for replaceAll 2021-04-03 22:35:03 +02:00
Peter Keresztes Schmidt
6150ceeb17 tests/utils: Add tests for trimSpaces 2021-04-03 22:35:03 +02:00
Peter Keresztes Schmidt
4529e59b1d tests/utils: Add tests for trimSet 2021-04-03 22:35:03 +02:00
Peter Keresztes Schmidt
00104b020c Build: Link our libs and executable targets against zm-core-interface 2021-02-08 23:08:22 +01:00
Peter Keresztes Schmidt
bb067c065b tests: Add unit tests for JWT validation 2021-02-04 18:53:58 +01:00
Peter Keresztes Schmidt
bef4e4032f Add Catch2 as C++ test framework
Use -DCMAKE_BUILD_TEST_SUITE=1 during CMake invocation to activate building the tests.
The 'tests' target builds the unit tests which can then be executed using the 'test' target.

We depend on the Catch2 version of the system.
Since development normally takes place on current OSs, this shouldn't pose a problem.
2021-02-04 18:53:54 +01:00