test for name resolution during *::Config::expand()

This commit is contained in:
Michael Davidsaver
2025-10-01 06:59:35 -07:00
parent 65d2f943c8
commit 6f47d65735
+32 -1
View File
@@ -175,17 +175,48 @@ void testClientAuto()
testFalse(conf.addressList.empty())<<conf.addressList;
}
void testDNS()
{
testShow()<<__func__;
{
std::vector<std::string> expect({"127.0.0.1"});
client::Config conf;
conf.addressList = expect; // copy
conf.autoAddrList = false;
conf.expand();
testArrEq(conf.addressList, expect)<<" numeric address";
}
{
std::vector<std::string> expect({"127.0.0.1"});
client::Config conf;
conf.addressList.push_back("localhost"); // copy
conf.autoAddrList = false;
conf.expand();
testArrEq(conf.addressList, expect)<<" localhost";
}
{
std::vector<std::string> expect;
client::Config conf;
conf.addressList.push_back("16name.invalid"); // expect failure unless host resolver is hijacking
conf.autoAddrList = false;
conf.expand();
testArrEq(conf.addressList, expect)<<" invalid hostname";
}
}
} // namespace
MAIN(testconfig)
{
testPlan(31);
testPlan(34);
testSetup();
testDefs();
logger_config_env();
testParse();
testServerAuto();
testClientAuto();
testDNS();
cleanup_for_valgrind();
return testDone();
}