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

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: Add 3 more test cases 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
« no previous file with comments | « 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_->AddRuleForAllFamilies("not_reserved1", "53.53.0.127");
1331 proc_->AddRuleForAllFamilies("not_reserved2", "127.0.53.54");
1332 proc_->AddRuleForAllFamilies("not_reserved3", "10.0.53.53");
1333 proc_->SignalMultiple(6u);
1334
1335 Request* request;
1336
1337 request = CreateRequest("single");
1338 EXPECT_EQ(ERR_IO_PENDING, request->Resolve());
1339 EXPECT_EQ(ERR_ICANN_NAME_COLLISION, request->WaitForResult());
1340
1341 request = CreateRequest("multiple");
1342 EXPECT_EQ(ERR_IO_PENDING, request->Resolve());
1343 EXPECT_EQ(ERR_ICANN_NAME_COLLISION, request->WaitForResult());
1344
1345 // Resolving an IP literal of 127.0.53.53 however is allowed.
1346 EXPECT_EQ(OK, CreateRequest("127.0.53.53")->Resolve());
1347
1348 // Moreover the address should not be recognized when embedded in an IPv6
1349 // address.
1350 request = CreateRequest("ipv6");
1351 EXPECT_EQ(ERR_IO_PENDING, request->Resolve());
1352 EXPECT_EQ(OK, request->WaitForResult());
1353
1354 // Try some other IPs which are similar, but NOT an exact match on
1355 // 127.0.53.53.
1356 request = CreateRequest("not_reserved1");
1357 EXPECT_EQ(ERR_IO_PENDING, request->Resolve());
1358 EXPECT_EQ(OK, request->WaitForResult());
1359
1360 request = CreateRequest("not_reserved2");
1361 EXPECT_EQ(ERR_IO_PENDING, request->Resolve());
1362 EXPECT_EQ(OK, request->WaitForResult());
1363
1364 request = CreateRequest("not_reserved3");
1365 EXPECT_EQ(ERR_IO_PENDING, request->Resolve());
1366 EXPECT_EQ(OK, request->WaitForResult());
1367 }
1368
1322 DnsConfig CreateValidDnsConfig() { 1369 DnsConfig CreateValidDnsConfig() {
1323 IPAddressNumber dns_ip; 1370 IPAddressNumber dns_ip;
1324 bool rv = ParseIPLiteralToNumber("192.168.1.0", &dns_ip); 1371 bool rv = ParseIPLiteralToNumber("192.168.1.0", &dns_ip);
1325 EXPECT_TRUE(rv); 1372 EXPECT_TRUE(rv);
1326 1373
1327 DnsConfig config; 1374 DnsConfig config;
1328 config.nameservers.push_back(IPEndPoint(dns_ip, dns_protocol::kDefaultPort)); 1375 config.nameservers.push_back(IPEndPoint(dns_ip, dns_protocol::kDefaultPort));
1329 EXPECT_TRUE(config.IsValid()); 1376 EXPECT_TRUE(config.IsValid());
1330 return config; 1377 return config;
1331 } 1378 }
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
2096 2143
2097 EXPECT_EQ(OK, requests_[0]->WaitForResult()); 2144 EXPECT_EQ(OK, requests_[0]->WaitForResult());
2098 EXPECT_TRUE(requests_[0]->HasOneAddress("192.168.0.1", 80)); 2145 EXPECT_TRUE(requests_[0]->HasOneAddress("192.168.0.1", 80));
2099 EXPECT_EQ(OK, requests_[1]->WaitForResult()); 2146 EXPECT_EQ(OK, requests_[1]->WaitForResult());
2100 EXPECT_TRUE(requests_[1]->HasOneAddress("192.168.0.2", 80)); 2147 EXPECT_TRUE(requests_[1]->HasOneAddress("192.168.0.2", 80));
2101 EXPECT_EQ(OK, requests_[2]->WaitForResult()); 2148 EXPECT_EQ(OK, requests_[2]->WaitForResult());
2102 EXPECT_TRUE(requests_[2]->HasOneAddress("192.168.0.3", 80)); 2149 EXPECT_TRUE(requests_[2]->HasOneAddress("192.168.0.3", 80));
2103 } 2150 }
2104 2151
2105 } // namespace net 2152 } // namespace net
OLDNEW
« 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