Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(804)

Unified Diff: net/dns/host_resolver_impl_unittest.cc

Issue 2567623003: Make ERR_ICANN_NAME_COLLISION work for async DNS resolver. (Closed)
Patch Set: address Matt's comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/dns/host_resolver_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/host_resolver_impl_unittest.cc
diff --git a/net/dns/host_resolver_impl_unittest.cc b/net/dns/host_resolver_impl_unittest.cc
index 0dbed080e9e8a7293fc676b64b2b56340d796218..15822d9a1131524965bcd7eb0a88c90e429e7319 100644
--- a/net/dns/host_resolver_impl_unittest.cc
+++ b/net/dns/host_resolver_impl_unittest.cc
@@ -1486,9 +1486,9 @@ TEST_F(HostResolverImplTest, MultipleAttempts) {
// If a host resolves to a list that includes 127.0.53.53, this is treated as
// an error. 127.0.53.53 is a localhost address, however it has been given a
-// special significance by ICANN to help surfance name collision resulting from
+// special significance by ICANN to help surface name collision resulting from
// the new gTLDs.
-TEST_F(HostResolverImplTest, NameCollision127_0_53_53) {
+TEST_F(HostResolverImplTest, NameCollisionIcann) {
proc_->AddRuleForAllFamilies("single", "127.0.53.53");
proc_->AddRuleForAllFamilies("multiple", "127.0.0.1,127.0.53.53");
proc_->AddRuleForAllFamilies("ipv6", "::127.0.53.53");
@@ -1615,6 +1615,16 @@ class HostResolverImplDnsTest : public HostResolverImplTest {
MockDnsClientRule::OK, true);
AddDnsRule("4slow_6timeout", dns_protocol::kTypeAAAA,
MockDnsClientRule::TIMEOUT, false);
+ AddDnsRule("4collision", dns_protocol::kTypeA, IPAddress(127, 0, 53, 53),
+ false);
+ AddDnsRule("4collision", dns_protocol::kTypeAAAA, MockDnsClientRule::EMPTY,
+ false);
+ AddDnsRule("6collision", dns_protocol::kTypeA, MockDnsClientRule::EMPTY,
+ false);
+ // This isn't the expected IP for collisions (but looks close to it).
+ AddDnsRule("6collision", dns_protocol::kTypeAAAA,
+ IPAddress(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 0, 53, 53),
+ false);
CreateResolver();
}
@@ -1633,6 +1643,22 @@ class HostResolverImplDnsTest : public HostResolverImplTest {
// Adds a rule to |dns_rules_|. Must be followed by |CreateResolver| to apply.
void AddDnsRule(const std::string& prefix,
uint16_t qtype,
+ MockDnsClientRule::ResultType result_type,
+ bool delay) {
+ return AddDnsRule(prefix, qtype, MockDnsClientRule::Result(result_type),
+ delay);
+ }
+
+ void AddDnsRule(const std::string& prefix,
+ uint16_t qtype,
+ const IPAddress& result_ip,
+ bool delay) {
+ return AddDnsRule(prefix, qtype, MockDnsClientRule::Result(result_ip),
+ delay);
+ }
+
+ void AddDnsRule(const std::string& prefix,
+ uint16_t qtype,
MockDnsClientRule::Result result,
bool delay) {
dns_rules_.push_back(MockDnsClientRule(prefix, qtype, result, delay));
@@ -1792,6 +1818,26 @@ TEST_F(HostResolverImplDnsTest, DnsTaskUnspec) {
EXPECT_TRUE(requests_[3]->HasAddress("192.168.1.101", 80));
}
+TEST_F(HostResolverImplDnsTest, NameCollisionIcann) {
+ ChangeDnsConfig(CreateValidDnsConfig());
+
+ // When the resolver returns an A record with 127.0.53.53 it should be mapped
+ // to a special error.
+ EXPECT_THAT(CreateRequest("4collision", 80)->Resolve(),
+ IsError(ERR_IO_PENDING));
+
+ EXPECT_THAT(requests_[0]->WaitForResult(), IsError(ERR_ICANN_NAME_COLLISION));
+
+ // When the resolver returns an AAAA record with ::127.0.53.53 it should
+ // work just like any other IP. (Despite having the same suffix, it is not
+ // considered special)
+ EXPECT_THAT(CreateRequest("6collision", 80)->Resolve(),
+ IsError(ERR_IO_PENDING));
+
+ EXPECT_THAT(requests_[1]->WaitForResult(), IsError(OK));
+ EXPECT_TRUE(requests_[1]->HasAddress("::127.0.53.53", 80));
+}
+
TEST_F(HostResolverImplDnsTest, ServeFromHosts) {
// Initially, use empty HOSTS file.
DnsConfig config = CreateValidDnsConfig();
« no previous file with comments | « net/dns/host_resolver_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698