aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver-test/zenserver-test.cpp
diff options
context:
space:
mode:
authorzousar <[email protected]>2024-02-06 10:02:45 -0500
committerGitHub <[email protected]>2024-02-06 16:02:45 +0100
commit3eecbb0c8a6e9bd906b4d313c3d690a2c4365ca4 (patch)
treee7b9bcae2e1e3df11b8789ebe987ec41fe7159c6 /src/zenserver-test/zenserver-test.cpp
parent5.4.1-pre1 (diff)
downloadzen-3eecbb0c8a6e9bd906b4d313c3d690a2c4365ca4.tar.xz
zen-3eecbb0c8a6e9bd906b4d313c3d690a2c4365ca4.zip
Add testcase and fix for ASIO ipv4 localhost support (#649)
- Bugfix: Implement two listening sockets in ASIO (ipv4+ipv6) when either we start with `--http-forceloopback` or we resort to that mode because of a failure to bind to the "any" address
Diffstat (limited to 'src/zenserver-test/zenserver-test.cpp')
-rw-r--r--src/zenserver-test/zenserver-test.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/zenserver-test/zenserver-test.cpp b/src/zenserver-test/zenserver-test.cpp
index 5dfbc6327..9074485b6 100644
--- a/src/zenserver-test/zenserver-test.cpp
+++ b/src/zenserver-test/zenserver-test.cpp
@@ -198,6 +198,33 @@ TEST_CASE("default.single")
zen::NiceRate(RequestCount, (uint32_t)Elapsed, "req"));
}
+TEST_CASE("default.loopback")
+{
+ std::filesystem::path TestDir = TestEnv.CreateNewTestDir();
+
+ ZenServerInstance Instance(TestEnv);
+ Instance.SetTestDir(TestDir);
+ const uint16_t PortNumber = Instance.SpawnServerAndWaitUntilReady("--http-forceloopback");
+
+ ZEN_INFO("Running loopback server test...");
+
+ SUBCASE("ipv4 endpoint connectivity")
+ {
+ cpr::Session cli;
+ cli.SetUrl(cpr::Url{fmt::format("http://127.0.0.1:{}/test/hello", PortNumber)});
+ auto res = cli.Get();
+ CHECK(!res.error);
+ }
+
+ SUBCASE("ipv6 endpoint connectivity")
+ {
+ cpr::Session cli;
+ cli.SetUrl(cpr::Url{fmt::format("http://[::1]:{}/test/hello", PortNumber)});
+ auto res = cli.Get();
+ CHECK(!res.error);
+ }
+}
+
TEST_CASE("multi.basic")
{
ZenServerInstance Instance1(TestEnv);