summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2021-10-05 03:03:52 +0300
committerEd Tanous <ed@tanous.net>2023-07-14 20:00:46 +0300
commite1452bea2809f7189a69ee562e5078e452f0a251 (patch)
tree1286ff33b8c03a083af928f905f8f1e908d1abee /test
parent4a2e485d4d846ef7b6e03749795e9dc827b50ba1 (diff)
downloadbmcweb-e1452bea2809f7189a69ee562e5078e452f0a251.tar.xz
AsyncResolve cleanups and error handling
The Async DBus resolver really has nothing to do with crow, which is our core http library namespace and has some opportunistic cleanups that can be done. This commit moves it into the bmcweb namespace (unimportantly) and breaks out one of the larger functions such that it can be unit tested, and unit tests it. Tested: Unit tests pass. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ie3cfbb0ef81a027a1ad42358c04967a517471117
Diffstat (limited to 'test')
-rw-r--r--test/include/async_resolve_test.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/include/async_resolve_test.cpp b/test/include/async_resolve_test.cpp
new file mode 100644
index 0000000000..be1e8a34d2
--- /dev/null
+++ b/test/include/async_resolve_test.cpp
@@ -0,0 +1,25 @@
+#include "async_resolve.hpp"
+
+#include <boost/asio/ip/tcp.hpp>
+
+#include <gmock/gmock.h>
+
+TEST(AsyncResolve, ipv4Positive)
+{
+ boost::asio::ip::tcp::endpoint ep;
+ ASSERT_TRUE(async_resolve::endpointFromResolveTuple({1, 2, 3, 4}, ep));
+ EXPECT_TRUE(ep.address().is_v4());
+ EXPECT_FALSE(ep.address().is_v6());
+
+ EXPECT_EQ(ep.address().to_string(), "1.2.3.4");
+}
+
+TEST(AsyncResolve, ipv6Positive)
+{
+ boost::asio::ip::tcp::endpoint ep;
+ ASSERT_TRUE(async_resolve::endpointFromResolveTuple(
+ {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, ep));
+ EXPECT_FALSE(ep.address().is_v4());
+ EXPECT_TRUE(ep.address().is_v6());
+ EXPECT_EQ(ep.address().to_string(), "102:304:506:708:90a:b0c:d0e:f10");
+}