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

Side by Side Diff: net/dns/host_resolver_impl_unittest.cc

Issue 1035803003: Fail DNS resolution if the result contains 127.0.53.53. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months 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 unified diff | Download patch
« net/dns/host_resolver_impl.cc ('K') | « net/dns/host_resolver_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/dns/host_resolver_impl.h" 5 #include "net/dns/host_resolver_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 EXPECT_EQ(-4, req->WaitForResult()); 1312 EXPECT_EQ(-4, req->WaitForResult());
1313 1313
1314 resolver_proc->WaitForAllAttemptsToFinish( 1314 resolver_proc->WaitForAllAttemptsToFinish(
1315 base::TimeDelta::FromMilliseconds(60000)); 1315 base::TimeDelta::FromMilliseconds(60000));
1316 base::MessageLoop::current()->RunUntilIdle(); 1316 base::MessageLoop::current()->RunUntilIdle();
1317 1317
1318 EXPECT_EQ(resolver_proc->total_attempts_resolved(), kTotalAttempts); 1318 EXPECT_EQ(resolver_proc->total_attempts_resolved(), kTotalAttempts);
1319 EXPECT_EQ(resolver_proc->resolved_attempt_number(), kAttemptNumberToResolve); 1319 EXPECT_EQ(resolver_proc->resolved_attempt_number(), kAttemptNumberToResolve);
1320 } 1320 }
1321 1321
1322 // If a host resolves to a list that includes 127.0.53.53, this is treated as
1323 // an error. 127.0.53.53 is a localhost address, however it has been given a
1324 // special significance by ICANN to help surfance name collision resulting from
1325 // the new gTLDs.
1326 TEST_F(HostResolverImplTest, NameCollision127_0_53_53) {
1327 proc_->AddRuleForAllFamilies("single", "127.0.53.53");
1328 proc_->AddRuleForAllFamilies("multiple", "127.0.0.1,127.0.53.53");
1329 proc_->AddRuleForAllFamilies("ipv6", "::127.0.53.53");
1330 proc_->SignalMultiple(3u);
1331
1332 Request* request;
1333
1334 request = CreateRequest("single");
1335 EXPECT_EQ(ERR_IO_PENDING, request->Resolve());
1336 EXPECT_EQ(ERR_FAILED, request->WaitForResult());
Ryan Sleevi 2015/03/26 00:32:29 We don't give a better error here? To ensure that
eroman 2015/03/26 00:39:31 d'oh, forgot to update the unittest after adding t
1337
1338 request = CreateRequest("multiple");
1339 EXPECT_EQ(ERR_IO_PENDING, request->Resolve());
1340 EXPECT_EQ(ERR_FAILED, request->WaitForResult());
1341
1342 // Resolving an IP literal of 127.0.53.53 however is allowed.
1343 EXPECT_EQ(OK, CreateRequest("127.0.53.53")->Resolve());
1344
1345 // Moreover the address should not be recognized when embedded in an IPv6
1346 // address.
1347 request = CreateRequest("ipv6");
1348 EXPECT_EQ(ERR_IO_PENDING, request->Resolve());
1349 EXPECT_EQ(OK, request->WaitForResult());
1350 }
1351
1322 DnsConfig CreateValidDnsConfig() { 1352 DnsConfig CreateValidDnsConfig() {
1323 IPAddressNumber dns_ip; 1353 IPAddressNumber dns_ip;
1324 bool rv = ParseIPLiteralToNumber("192.168.1.0", &dns_ip); 1354 bool rv = ParseIPLiteralToNumber("192.168.1.0", &dns_ip);
1325 EXPECT_TRUE(rv); 1355 EXPECT_TRUE(rv);
1326 1356
1327 DnsConfig config; 1357 DnsConfig config;
1328 config.nameservers.push_back(IPEndPoint(dns_ip, dns_protocol::kDefaultPort)); 1358 config.nameservers.push_back(IPEndPoint(dns_ip, dns_protocol::kDefaultPort));
1329 EXPECT_TRUE(config.IsValid()); 1359 EXPECT_TRUE(config.IsValid());
1330 return config; 1360 return config;
1331 } 1361 }
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
2096 2126
2097 EXPECT_EQ(OK, requests_[0]->WaitForResult()); 2127 EXPECT_EQ(OK, requests_[0]->WaitForResult());
2098 EXPECT_TRUE(requests_[0]->HasOneAddress("192.168.0.1", 80)); 2128 EXPECT_TRUE(requests_[0]->HasOneAddress("192.168.0.1", 80));
2099 EXPECT_EQ(OK, requests_[1]->WaitForResult()); 2129 EXPECT_EQ(OK, requests_[1]->WaitForResult());
2100 EXPECT_TRUE(requests_[1]->HasOneAddress("192.168.0.2", 80)); 2130 EXPECT_TRUE(requests_[1]->HasOneAddress("192.168.0.2", 80));
2101 EXPECT_EQ(OK, requests_[2]->WaitForResult()); 2131 EXPECT_EQ(OK, requests_[2]->WaitForResult());
2102 EXPECT_TRUE(requests_[2]->HasOneAddress("192.168.0.3", 80)); 2132 EXPECT_TRUE(requests_[2]->HasOneAddress("192.168.0.3", 80));
2103 } 2133 }
2104 2134
2105 } // namespace net 2135 } // namespace net
OLDNEW
« net/dns/host_resolver_impl.cc ('K') | « net/dns/host_resolver_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698