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

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

Issue 2577503003: Misc HostResolverImpl refactors. (Closed)
Patch Set: 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 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 <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <tuple> 10 #include <tuple>
(...skipping 1485 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 proc_->AddRuleForAllFamilies("not_reserved2", "127.0.53.54"); 1496 proc_->AddRuleForAllFamilies("not_reserved2", "127.0.53.54");
1497 proc_->AddRuleForAllFamilies("not_reserved3", "10.0.53.53"); 1497 proc_->AddRuleForAllFamilies("not_reserved3", "10.0.53.53");
1498 proc_->SignalMultiple(6u); 1498 proc_->SignalMultiple(6u);
1499 1499
1500 Request* request; 1500 Request* request;
1501 1501
1502 request = CreateRequest("single"); 1502 request = CreateRequest("single");
1503 EXPECT_THAT(request->Resolve(), IsError(ERR_IO_PENDING)); 1503 EXPECT_THAT(request->Resolve(), IsError(ERR_IO_PENDING));
1504 EXPECT_THAT(request->WaitForResult(), IsError(ERR_ICANN_NAME_COLLISION)); 1504 EXPECT_THAT(request->WaitForResult(), IsError(ERR_ICANN_NAME_COLLISION));
1505 1505
1506 // ERR_ICANN_NAME_COLLISION is cached like any other error, using a
1507 // fixed TTL for failed entries from proc-based resolver. That said, the
1508 // fixed TTL is 0, so it will never be cached.
1509 request = CreateRequest("single");
1510 EXPECT_THAT(request->ResolveFromCache(), IsError(ERR_DNS_CACHE_MISS));
1511
1506 request = CreateRequest("multiple"); 1512 request = CreateRequest("multiple");
1507 EXPECT_THAT(request->Resolve(), IsError(ERR_IO_PENDING)); 1513 EXPECT_THAT(request->Resolve(), IsError(ERR_IO_PENDING));
1508 EXPECT_THAT(request->WaitForResult(), IsError(ERR_ICANN_NAME_COLLISION)); 1514 EXPECT_THAT(request->WaitForResult(), IsError(ERR_ICANN_NAME_COLLISION));
1509 1515
1510 // Resolving an IP literal of 127.0.53.53 however is allowed. 1516 // Resolving an IP literal of 127.0.53.53 however is allowed.
1511 EXPECT_THAT(CreateRequest("127.0.53.53")->Resolve(), IsOk()); 1517 EXPECT_THAT(CreateRequest("127.0.53.53")->Resolve(), IsOk());
1512 1518
1513 // Moreover the address should not be recognized when embedded in an IPv6 1519 // Moreover the address should not be recognized when embedded in an IPv6
1514 // address. 1520 // address.
1515 request = CreateRequest("ipv6"); 1521 request = CreateRequest("ipv6");
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1829 EXPECT_THAT(requests_[0]->WaitForResult(), IsError(ERR_ICANN_NAME_COLLISION)); 1835 EXPECT_THAT(requests_[0]->WaitForResult(), IsError(ERR_ICANN_NAME_COLLISION));
1830 1836
1831 // When the resolver returns an AAAA record with ::127.0.53.53 it should 1837 // When the resolver returns an AAAA record with ::127.0.53.53 it should
1832 // work just like any other IP. (Despite having the same suffix, it is not 1838 // work just like any other IP. (Despite having the same suffix, it is not
1833 // considered special) 1839 // considered special)
1834 EXPECT_THAT(CreateRequest("6collision", 80)->Resolve(), 1840 EXPECT_THAT(CreateRequest("6collision", 80)->Resolve(),
1835 IsError(ERR_IO_PENDING)); 1841 IsError(ERR_IO_PENDING));
1836 1842
1837 EXPECT_THAT(requests_[1]->WaitForResult(), IsError(OK)); 1843 EXPECT_THAT(requests_[1]->WaitForResult(), IsError(OK));
1838 EXPECT_TRUE(requests_[1]->HasAddress("::127.0.53.53", 80)); 1844 EXPECT_TRUE(requests_[1]->HasAddress("::127.0.53.53", 80));
1845
1846 // The mock responses for 4collision (and 6collision) have a TTL of 1 day.
1847 // Test whether the ERR_ICANN_NAME_COLLISION failure was cached.
1848 // On the one hand caching the failure makes sense, as the error is derived
1849 // from the IP in the response. However for consistency with the the proc-
1850 // based implementation the TTL is unused.
1851 EXPECT_THAT(CreateRequest("4collision", 80)->ResolveFromCache(),
1852 IsError(ERR_DNS_CACHE_MISS));
1839 } 1853 }
1840 1854
1841 TEST_F(HostResolverImplDnsTest, ServeFromHosts) { 1855 TEST_F(HostResolverImplDnsTest, ServeFromHosts) {
1842 // Initially, use empty HOSTS file. 1856 // Initially, use empty HOSTS file.
1843 DnsConfig config = CreateValidDnsConfig(); 1857 DnsConfig config = CreateValidDnsConfig();
1844 ChangeDnsConfig(config); 1858 ChangeDnsConfig(config);
1845 1859
1846 proc_->AddRuleForAllFamilies(std::string(), 1860 proc_->AddRuleForAllFamilies(std::string(),
1847 std::string()); // Default to failures. 1861 std::string()); // Default to failures.
1848 proc_->SignalMultiple(1u); // For the first request which misses. 1862 proc_->SignalMultiple(1u); // For the first request which misses.
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
2502 EXPECT_EQ(1, count2); 2516 EXPECT_EQ(1, count2);
2503 2517
2504 // Make another request to make sure both callbacks were cleared. 2518 // Make another request to make sure both callbacks were cleared.
2505 req = CreateRequest("just.testing", 80); 2519 req = CreateRequest("just.testing", 80);
2506 EXPECT_THAT(req->Resolve(), IsOk()); 2520 EXPECT_THAT(req->Resolve(), IsOk());
2507 EXPECT_EQ(2, count1); 2521 EXPECT_EQ(2, count1);
2508 EXPECT_EQ(1, count2); 2522 EXPECT_EQ(1, count2);
2509 } 2523 }
2510 2524
2511 } // namespace net 2525 } // 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