Context fill-in and CI tests
This commit adds common units tests and CI sanitasion.
Additional context for commit b64d9c4498:
- Fixed macOS/Linux non-portable and unsafe shell usage by adding a posix_spawn helper and replacing system() calls in virtual_interface.cpp.
- Fixed SessionRegistry::erase() to remove mIPSessions and mSessionIPs entries in session_registry.cpp.
- Prevented message-length truncation in tcp_message_handler.cpp by rejecting payloads > 65535 bytes.
- Validated handshake message sizes and removed silent truncation in:
- tcp_connection.cpp
- tcp_client.cpp
- Canonicalized and validated config and whitelist paths in utils.cpp using std::filesystem.
- Hardened environment-provided config path handling in main.cpp.
- Validated UDP ciphertext lengths and fixed session ID endianness in udp_client.cpp.
- Scheduled periodic SessionRegistry::cleanupExpired() in main.cpp (every 5 minutes).
This commit is contained in:
30
tests/test_tcp_message_handler_static.cpp
Normal file
30
tests/test_tcp_message_handler_static.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
// Tests for TCP MessageHandler static helpers
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
#include <columnlynx/common/net/tcp/tcp_message_handler.hpp>
|
||||
#include <columnlynx/common/net/tcp/tcp_message_type.hpp>
|
||||
|
||||
int main() {
|
||||
using namespace ColumnLynx::Net::TCP;
|
||||
|
||||
// server message special codes
|
||||
auto t1 = MessageHandler::decodeMessageType(0xFE);
|
||||
// Expect GRACEFUL_DISCONNECT mapped
|
||||
// Compare by converting back to uint8
|
||||
assert(MessageHandler::toUint8(t1) == 0xFE);
|
||||
|
||||
auto t2 = MessageHandler::decodeMessageType(0xFF);
|
||||
assert(MessageHandler::toUint8(t2) == 0xFF);
|
||||
|
||||
// Client message range (>= 0xA0)
|
||||
auto t3 = MessageHandler::decodeMessageType(0xA5);
|
||||
assert(MessageHandler::toUint8(t3) == 0xA5);
|
||||
|
||||
// Server message range (< 0xA0) and not special
|
||||
auto t4 = MessageHandler::decodeMessageType(0x10);
|
||||
assert(MessageHandler::toUint8(t4) == 0x10);
|
||||
|
||||
std::cout << "TCP MessageHandler static helpers tests passed\n";
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user