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
diff --git a/test/include/async_resolve_test.cpp b/test/include/async_resolve_test.cpp
new file mode 100644
index 0000000..be1e8a3
--- /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");
+}