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

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

Issue 435603008: Fix crash when trying to connect to an IPv6 IP via a SOCKS4 proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Response to eroman's comments Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « net/dns/host_resolver_impl.cc ('k') | net/dns/mock_host_resolver.cc » ('j') | 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 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 1229
1230 EXPECT_EQ("h1", capture_list[1].hostname); 1230 EXPECT_EQ("h1", capture_list[1].hostname);
1231 EXPECT_EQ(ADDRESS_FAMILY_IPV4, capture_list[1].address_family); 1231 EXPECT_EQ(ADDRESS_FAMILY_IPV4, capture_list[1].address_family);
1232 1232
1233 // Now check that the correct resolved IP addresses were returned. 1233 // Now check that the correct resolved IP addresses were returned.
1234 EXPECT_TRUE(requests_[0]->HasOneAddress("::2", 80)); 1234 EXPECT_TRUE(requests_[0]->HasOneAddress("::2", 80));
1235 EXPECT_TRUE(requests_[1]->HasOneAddress("::2", 80)); 1235 EXPECT_TRUE(requests_[1]->HasOneAddress("::2", 80));
1236 EXPECT_TRUE(requests_[2]->HasOneAddress("1.0.0.1", 80)); 1236 EXPECT_TRUE(requests_[2]->HasOneAddress("1.0.0.1", 80));
1237 } 1237 }
1238 1238
1239 // Make sure that the address family parameter is respected when raw IPs are
1240 // passed in.
1241 TEST_F(HostResolverImplTest, AddressFamilyWithRawIPs) {
1242 Request* request =
1243 CreateRequest("127.0.0.1", 80, MEDIUM, ADDRESS_FAMILY_IPV4);
1244 EXPECT_EQ(OK, request->Resolve());
1245 EXPECT_TRUE(request->HasOneAddress("127.0.0.1", 80));
1246
1247 request = CreateRequest("127.0.0.1", 80, MEDIUM, ADDRESS_FAMILY_IPV6);
1248 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, request->Resolve());
1249
1250 request = CreateRequest("127.0.0.1", 80, MEDIUM, ADDRESS_FAMILY_UNSPECIFIED);
1251 EXPECT_EQ(OK, request->Resolve());
1252 EXPECT_TRUE(request->HasOneAddress("127.0.0.1", 80));
1253
1254 request = CreateRequest("::1", 80, MEDIUM, ADDRESS_FAMILY_IPV4);
1255 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, request->Resolve());
1256
1257 request = CreateRequest("::1", 80, MEDIUM, ADDRESS_FAMILY_IPV6);
1258 EXPECT_EQ(OK, request->Resolve());
1259 EXPECT_TRUE(request->HasOneAddress("::1", 80));
1260
1261 request = CreateRequest("::1", 80, MEDIUM, ADDRESS_FAMILY_UNSPECIFIED);
1262 EXPECT_EQ(OK, request->Resolve());
1263 EXPECT_TRUE(request->HasOneAddress("::1", 80));
1264 }
1265
1239 TEST_F(HostResolverImplTest, ResolveFromCache) { 1266 TEST_F(HostResolverImplTest, ResolveFromCache) {
1240 proc_->AddRuleForAllFamilies("just.testing", "192.168.1.42"); 1267 proc_->AddRuleForAllFamilies("just.testing", "192.168.1.42");
1241 proc_->SignalMultiple(1u); // Need only one. 1268 proc_->SignalMultiple(1u); // Need only one.
1242 1269
1243 HostResolver::RequestInfo info(HostPortPair("just.testing", 80)); 1270 HostResolver::RequestInfo info(HostPortPair("just.testing", 80));
1244 1271
1245 // First hit will miss the cache. 1272 // First hit will miss the cache.
1246 EXPECT_EQ(ERR_DNS_CACHE_MISS, 1273 EXPECT_EQ(ERR_DNS_CACHE_MISS,
1247 CreateRequest(info, DEFAULT_PRIORITY)->ResolveFromCache()); 1274 CreateRequest(info, DEFAULT_PRIORITY)->ResolveFromCache());
1248 1275
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
2071 2098
2072 EXPECT_EQ(OK, requests_[0]->WaitForResult()); 2099 EXPECT_EQ(OK, requests_[0]->WaitForResult());
2073 EXPECT_TRUE(requests_[0]->HasOneAddress("192.168.0.1", 80)); 2100 EXPECT_TRUE(requests_[0]->HasOneAddress("192.168.0.1", 80));
2074 EXPECT_EQ(OK, requests_[1]->WaitForResult()); 2101 EXPECT_EQ(OK, requests_[1]->WaitForResult());
2075 EXPECT_TRUE(requests_[1]->HasOneAddress("192.168.0.2", 80)); 2102 EXPECT_TRUE(requests_[1]->HasOneAddress("192.168.0.2", 80));
2076 EXPECT_EQ(OK, requests_[2]->WaitForResult()); 2103 EXPECT_EQ(OK, requests_[2]->WaitForResult());
2077 EXPECT_TRUE(requests_[2]->HasOneAddress("192.168.0.3", 80)); 2104 EXPECT_TRUE(requests_[2]->HasOneAddress("192.168.0.3", 80));
2078 } 2105 }
2079 2106
2080 } // namespace net 2107 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/host_resolver_impl.cc ('k') | net/dns/mock_host_resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698