Skip to content

Commit

Permalink
feat: add os version to messages metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasTurina committed Nov 19, 2024
1 parent df31b8d commit 6fb822c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/agent/agent_info/src/agent_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ void AgentInfo::LoadEndpointInfo()
m_endpointInfo["os"] = nlohmann::json::object();
m_endpointInfo["os"]["name"] = osInfo.value("os_name", "Unknown");
m_endpointInfo["os"]["platform"] = osInfo.value("sysname", "Unknown");
m_endpointInfo["os"]["version"] = osInfo.value("os_version", "Unknown");
}

if (m_getNetworksInfo != nullptr)
Expand Down
4 changes: 4 additions & 0 deletions src/agent/agent_info/tests/agent_info_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ TEST_F(AgentInfoTest, TestLoadMetadataInfoRegistration)
os["hostname"] = "test_name";
os["os_name"] = "test_os";
os["sysname"] = "test_platform";
os["os_version"] = "1.0.0";
os["architecture"] = "test_arch";

networks["iface"] = nlohmann::json::array();
Expand Down Expand Up @@ -178,6 +179,7 @@ TEST_F(AgentInfoTest, TestLoadMetadataInfoRegistration)
EXPECT_TRUE(metadataInfo["host"]["os"] != nullptr);
EXPECT_EQ(metadataInfo["host"]["os"]["name"], "test_os");
EXPECT_EQ(metadataInfo["host"]["os"]["platform"], "test_platform");
EXPECT_EQ(metadataInfo["host"]["os"]["version"], "1.0.0");
EXPECT_TRUE(metadataInfo["host"]["ip"] != nullptr);
EXPECT_EQ(metadataInfo["host"]["ip"][0], "127.0.0.1");
EXPECT_EQ(metadataInfo["host"]["ip"][1], "fe80::0000");
Expand All @@ -196,6 +198,7 @@ TEST_F(AgentInfoTest, TestLoadMetadataInfoConnected)
os["hostname"] = "test_name";
os["os_name"] = "test_os";
os["sysname"] = "test_platform";
os["os_version"] = "1.0.0";
os["architecture"] = "test_arch";

networks["iface"] = nlohmann::json::array();
Expand Down Expand Up @@ -227,6 +230,7 @@ TEST_F(AgentInfoTest, TestLoadMetadataInfoConnected)
EXPECT_TRUE(metadataInfo["agent"]["host"]["os"] != nullptr);
EXPECT_EQ(metadataInfo["agent"]["host"]["os"]["name"], "test_os");
EXPECT_EQ(metadataInfo["agent"]["host"]["os"]["platform"], "test_platform");
EXPECT_EQ(metadataInfo["agent"]["host"]["os"]["version"], "1.0.0");
EXPECT_TRUE(metadataInfo["agent"]["host"]["ip"] != nullptr);
EXPECT_EQ(metadataInfo["agent"]["host"]["ip"][0], "127.0.0.1");
EXPECT_EQ(metadataInfo["agent"]["host"]["architecture"], "test_arch");
Expand Down

0 comments on commit 6fb822c

Please sign in to comment.