|
|
|
@ -737,182 +737,6 @@ TEST_P(MockChannelTestAI, FamilyV4ServiceName) { |
|
|
|
|
EXPECT_EQ("{addr=[1.1.1.1:80], addr=[2.2.2.2:80]}", ss.str()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONTAINER |
|
|
|
|
|
|
|
|
|
class ContainedMockChannelAISysConfig |
|
|
|
|
: public MockChannelOptsTest, |
|
|
|
|
public ::testing::WithParamInterface<std::pair<int, bool>> { |
|
|
|
|
public: |
|
|
|
|
ContainedMockChannelAISysConfig() |
|
|
|
|
: MockChannelOptsTest(1, GetParam().first, GetParam().second, true, nullptr, 0) {} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static NameContentList files_no_ndots = { |
|
|
|
|
{"/etc/resolv.conf", "nameserver 1.2.3.4\n" // Will be replaced
|
|
|
|
|
"search example.com example.org\n" |
|
|
|
|
"options edns0 trust-ad\n"}, // ndots:1 is default
|
|
|
|
|
{"/etc/hosts", "3.4.5.6 ahostname.com\n"}, |
|
|
|
|
{"/etc/nsswitch.conf", "hosts: files dns\n"}}; |
|
|
|
|
|
|
|
|
|
/* These tests should still work even with /etc/hosts not having any localhost
|
|
|
|
|
* entries */ |
|
|
|
|
CONTAINED_TEST_P(ContainedMockChannelAISysConfig, NoHostsLocalHostv4, |
|
|
|
|
"myhostname", "mydomainname.org", files_no_ndots) { |
|
|
|
|
AddrInfoResult result = {}; |
|
|
|
|
struct ares_addrinfo_hints hints = {0, 0, 0, 0}; |
|
|
|
|
hints.ai_family = AF_INET; |
|
|
|
|
hints.ai_flags = ARES_AI_NOSORT; |
|
|
|
|
ares_getaddrinfo(channel_, "localhost", NULL, &hints, AddrInfoCallback, &result); |
|
|
|
|
Process(); |
|
|
|
|
EXPECT_TRUE(result.done_); |
|
|
|
|
EXPECT_EQ(result.status_, ARES_SUCCESS); |
|
|
|
|
EXPECT_THAT(result.ai_, IncludesNumAddresses(1)); |
|
|
|
|
EXPECT_THAT(result.ai_, IncludesV4Address("127.0.0.1")); |
|
|
|
|
return HasFailure(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CONTAINED_TEST_P(ContainedMockChannelAISysConfig, NoHostsLocalHostv6, |
|
|
|
|
"myhostname", "mydomainname.org", files_no_ndots) { |
|
|
|
|
AddrInfoResult result = {}; |
|
|
|
|
struct ares_addrinfo_hints hints = {0, 0, 0, 0}; |
|
|
|
|
hints.ai_family = AF_INET6; |
|
|
|
|
hints.ai_flags = ARES_AI_NOSORT; |
|
|
|
|
ares_getaddrinfo(channel_, "localhost", NULL, &hints, AddrInfoCallback, &result); |
|
|
|
|
Process(); |
|
|
|
|
EXPECT_TRUE(result.done_); |
|
|
|
|
EXPECT_EQ(result.status_, ARES_SUCCESS); |
|
|
|
|
EXPECT_THAT(result.ai_, IncludesNumAddresses(1)); |
|
|
|
|
EXPECT_THAT(result.ai_, IncludesV6Address("0000:0000:0000:0000:0000:0000:0000:0001")); |
|
|
|
|
return HasFailure(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CONTAINED_TEST_P(ContainedMockChannelAISysConfig, NoHostsLocalHostUnspec, |
|
|
|
|
"myhostname", "mydomainname.org", files_no_ndots) { |
|
|
|
|
AddrInfoResult result = {}; |
|
|
|
|
struct ares_addrinfo_hints hints = {0, 0, 0, 0}; |
|
|
|
|
hints.ai_family = AF_UNSPEC; |
|
|
|
|
hints.ai_flags = ARES_AI_NOSORT; |
|
|
|
|
ares_getaddrinfo(channel_, "localhost", NULL, &hints, AddrInfoCallback, &result); |
|
|
|
|
Process(); |
|
|
|
|
EXPECT_TRUE(result.done_); |
|
|
|
|
EXPECT_EQ(result.status_, ARES_SUCCESS); |
|
|
|
|
EXPECT_THAT(result.ai_, IncludesNumAddresses(2)); |
|
|
|
|
EXPECT_THAT(result.ai_, IncludesV4Address("127.0.0.1")); |
|
|
|
|
EXPECT_THAT(result.ai_, IncludesV6Address("0000:0000:0000:0000:0000:0000:0000:0001")); |
|
|
|
|
return HasFailure(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Issue #946 says if a v4 localhost entry exists, but not a v6 entry, v6
|
|
|
|
|
* isn't output correctly. */ |
|
|
|
|
static NameContentList files_localhost_v4localhostonly = { |
|
|
|
|
{"/etc/resolv.conf", "nameserver 1.2.3.4\n" // Will be replaced
|
|
|
|
|
"search example.com example.org\n" |
|
|
|
|
"options edns0 trust-ad\n"}, // ndots:1 is default
|
|
|
|
|
{"/etc/hosts", "127.0.0.1 localhost\n"}, |
|
|
|
|
{"/etc/nsswitch.conf", "hosts: files dns\n"}}; |
|
|
|
|
CONTAINED_TEST_P(ContainedMockChannelAISysConfig, v4OnlyLocalHostv4, |
|
|
|
|
"myhostname", "mydomainname.org", files_localhost_v4localhostonly) { |
|
|
|
|
AddrInfoResult result = {}; |
|
|
|
|
struct ares_addrinfo_hints hints = {0, 0, 0, 0}; |
|
|
|
|
hints.ai_family = AF_INET; |
|
|
|
|
hints.ai_flags = ARES_AI_NOSORT; |
|
|
|
|
ares_getaddrinfo(channel_, "localhost", NULL, &hints, AddrInfoCallback, &result); |
|
|
|
|
Process(); |
|
|
|
|
EXPECT_TRUE(result.done_); |
|
|
|
|
EXPECT_EQ(result.status_, ARES_SUCCESS); |
|
|
|
|
EXPECT_THAT(result.ai_, IncludesNumAddresses(1)); |
|
|
|
|
EXPECT_THAT(result.ai_, IncludesV4Address("127.0.0.1")); |
|
|
|
|
return HasFailure(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CONTAINED_TEST_P(ContainedMockChannelAISysConfig, v4OnlyLocalHostv6, |
|
|
|
|
"myhostname", "mydomainname.org", files_localhost_v4localhostonly) { |
|
|
|
|
AddrInfoResult result = {}; |
|
|
|
|
struct ares_addrinfo_hints hints = {0, 0, 0, 0}; |
|
|
|
|
hints.ai_family = AF_INET6; |
|
|
|
|
hints.ai_flags = ARES_AI_NOSORT; |
|
|
|
|
ares_getaddrinfo(channel_, "localhost", NULL, &hints, AddrInfoCallback, &result); |
|
|
|
|
Process(); |
|
|
|
|
EXPECT_TRUE(result.done_); |
|
|
|
|
EXPECT_EQ(result.status_, ARES_SUCCESS); |
|
|
|
|
EXPECT_THAT(result.ai_, IncludesNumAddresses(1)); |
|
|
|
|
EXPECT_THAT(result.ai_, IncludesV6Address("0000:0000:0000:0000:0000:0000:0000:0001")); |
|
|
|
|
return HasFailure(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CONTAINED_TEST_P(ContainedMockChannelAISysConfig, v4OnlyLocalHostUnspec, |
|
|
|
|
"myhostname", "mydomainname.org", files_localhost_v4localhostonly) { |
|
|
|
|
AddrInfoResult result = {}; |
|
|
|
|
struct ares_addrinfo_hints hints = {0, 0, 0, 0}; |
|
|
|
|
hints.ai_family = AF_UNSPEC; |
|
|
|
|
hints.ai_flags = ARES_AI_NOSORT; |
|
|
|
|
ares_getaddrinfo(channel_, "localhost", NULL, &hints, AddrInfoCallback, &result); |
|
|
|
|
Process(); |
|
|
|
|
EXPECT_TRUE(result.done_); |
|
|
|
|
EXPECT_EQ(result.status_, ARES_SUCCESS); |
|
|
|
|
EXPECT_THAT(result.ai_, IncludesNumAddresses(2)); |
|
|
|
|
EXPECT_THAT(result.ai_, IncludesV4Address("127.0.0.1")); |
|
|
|
|
EXPECT_THAT(result.ai_, IncludesV6Address("0000:0000:0000:0000:0000:0000:0000:0001")); |
|
|
|
|
return HasFailure(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static NameContentList files_localhost_v6localhostonly = { |
|
|
|
|
{"/etc/resolv.conf", "nameserver 1.2.3.4\n" // Will be replaced
|
|
|
|
|
"search example.com example.org\n" |
|
|
|
|
"options edns0 trust-ad\n"}, // ndots:1 is default
|
|
|
|
|
{"/etc/hosts", "::1 localhost\n"}, |
|
|
|
|
{"/etc/nsswitch.conf", "hosts: files dns\n"}}; |
|
|
|
|
CONTAINED_TEST_P(ContainedMockChannelAISysConfig, v6OnlyLocalHostv4, |
|
|
|
|
"myhostname", "mydomainname.org", files_localhost_v6localhostonly) { |
|
|
|
|
AddrInfoResult result = {}; |
|
|
|
|
struct ares_addrinfo_hints hints = {0, 0, 0, 0}; |
|
|
|
|
hints.ai_family = AF_INET; |
|
|
|
|
hints.ai_flags = ARES_AI_NOSORT; |
|
|
|
|
ares_getaddrinfo(channel_, "localhost", NULL, &hints, AddrInfoCallback, &result); |
|
|
|
|
Process(); |
|
|
|
|
EXPECT_TRUE(result.done_); |
|
|
|
|
EXPECT_EQ(result.status_, ARES_SUCCESS); |
|
|
|
|
EXPECT_THAT(result.ai_, IncludesNumAddresses(1)); |
|
|
|
|
EXPECT_THAT(result.ai_, IncludesV4Address("127.0.0.1")); |
|
|
|
|
return HasFailure(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CONTAINED_TEST_P(ContainedMockChannelAISysConfig, v6OnlyLocalHostv6, |
|
|
|
|
"myhostname", "mydomainname.org", files_localhost_v6localhostonly) { |
|
|
|
|
AddrInfoResult result = {}; |
|
|
|
|
struct ares_addrinfo_hints hints = {0, 0, 0, 0}; |
|
|
|
|
hints.ai_family = AF_INET6; |
|
|
|
|
hints.ai_flags = ARES_AI_NOSORT; |
|
|
|
|
ares_getaddrinfo(channel_, "localhost", NULL, &hints, AddrInfoCallback, &result); |
|
|
|
|
Process(); |
|
|
|
|
EXPECT_TRUE(result.done_); |
|
|
|
|
EXPECT_EQ(result.status_, ARES_SUCCESS); |
|
|
|
|
EXPECT_THAT(result.ai_, IncludesNumAddresses(1)); |
|
|
|
|
EXPECT_THAT(result.ai_, IncludesV6Address("0000:0000:0000:0000:0000:0000:0000:0001")); |
|
|
|
|
return HasFailure(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CONTAINED_TEST_P(ContainedMockChannelAISysConfig, v6OnlyLocalHostUnspec, |
|
|
|
|
"myhostname", "mydomainname.org", files_localhost_v6localhostonly) { |
|
|
|
|
AddrInfoResult result = {}; |
|
|
|
|
struct ares_addrinfo_hints hints = {0, 0, 0, 0}; |
|
|
|
|
hints.ai_family = AF_UNSPEC; |
|
|
|
|
hints.ai_flags = ARES_AI_NOSORT; |
|
|
|
|
ares_getaddrinfo(channel_, "localhost", NULL, &hints, AddrInfoCallback, &result); |
|
|
|
|
Process(); |
|
|
|
|
EXPECT_TRUE(result.done_); |
|
|
|
|
EXPECT_EQ(result.status_, ARES_SUCCESS); |
|
|
|
|
EXPECT_THAT(result.ai_, IncludesNumAddresses(2)); |
|
|
|
|
EXPECT_THAT(result.ai_, IncludesV4Address("127.0.0.1")); |
|
|
|
|
EXPECT_THAT(result.ai_, IncludesV6Address("0000:0000:0000:0000:0000:0000:0000:0001")); |
|
|
|
|
return HasFailure(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_SUITE_P(AddressFamiliesAI, ContainedMockChannelAISysConfig, ::testing::ValuesIn(ares::test::families_modes), PrintFamilyMode); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_SUITE_P(AddressFamiliesAI, MockChannelTestAI, |
|
|
|
|
::testing::ValuesIn(ares::test::families_modes)); |
|
|
|
|
|
|
|
|
|