OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/socket/socks_client_socket.h" | 5 #include "net/socket/socks_client_socket.h" |
6 | 6 |
7 #include "net/base/address_list.h" | 7 #include "net/base/address_list.h" |
8 #include "net/base/net_log.h" | 8 #include "net/base/net_log.h" |
9 #include "net/base/net_log_unittest.h" | 9 #include "net/base/net_log_unittest.h" |
10 #include "net/base/mock_host_resolver.h" | 10 #include "net/base/mock_host_resolver.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 host_resolver_.get(), | 135 host_resolver_.get(), |
136 "localhost", 80, | 136 "localhost", 80, |
137 &log)); | 137 &log)); |
138 | 138 |
139 // At this state the TCP connection is completed but not the SOCKS handshake. | 139 // At this state the TCP connection is completed but not the SOCKS handshake. |
140 EXPECT_TRUE(tcp_sock_->IsConnected()); | 140 EXPECT_TRUE(tcp_sock_->IsConnected()); |
141 EXPECT_FALSE(user_sock_->IsConnected()); | 141 EXPECT_FALSE(user_sock_->IsConnected()); |
142 | 142 |
143 int rv = user_sock_->Connect(&callback_); | 143 int rv = user_sock_->Connect(&callback_); |
144 EXPECT_EQ(ERR_IO_PENDING, rv); | 144 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 145 |
| 146 net::CapturingNetLog::EntryList entries; |
| 147 log.GetEntries(&entries); |
145 EXPECT_TRUE( | 148 EXPECT_TRUE( |
146 LogContainsBeginEvent(log.entries(), 0, NetLog::TYPE_SOCKS_CONNECT)); | 149 LogContainsBeginEvent(entries, 0, NetLog::TYPE_SOCKS_CONNECT)); |
147 EXPECT_FALSE(user_sock_->IsConnected()); | 150 EXPECT_FALSE(user_sock_->IsConnected()); |
| 151 |
148 rv = callback_.WaitForResult(); | 152 rv = callback_.WaitForResult(); |
149 | |
150 EXPECT_EQ(OK, rv); | 153 EXPECT_EQ(OK, rv); |
151 EXPECT_TRUE(user_sock_->IsConnected()); | 154 EXPECT_TRUE(user_sock_->IsConnected()); |
152 EXPECT_EQ(SOCKSClientSocket::kSOCKS4, user_sock_->socks_version_); | 155 EXPECT_EQ(SOCKSClientSocket::kSOCKS4, user_sock_->socks_version_); |
| 156 log.GetEntries(&entries); |
153 EXPECT_TRUE(LogContainsEndEvent( | 157 EXPECT_TRUE(LogContainsEndEvent( |
154 log.entries(), -1, NetLog::TYPE_SOCKS_CONNECT)); | 158 entries, -1, NetLog::TYPE_SOCKS_CONNECT)); |
155 | 159 |
156 scoped_refptr<IOBuffer> buffer(new IOBuffer(payload_write.size())); | 160 scoped_refptr<IOBuffer> buffer(new IOBuffer(payload_write.size())); |
157 memcpy(buffer->data(), payload_write.data(), payload_write.size()); | 161 memcpy(buffer->data(), payload_write.data(), payload_write.size()); |
158 rv = user_sock_->Write(buffer, payload_write.size(), &callback_); | 162 rv = user_sock_->Write(buffer, payload_write.size(), &callback_); |
159 EXPECT_EQ(ERR_IO_PENDING, rv); | 163 EXPECT_EQ(ERR_IO_PENDING, rv); |
160 rv = callback_.WaitForResult(); | 164 rv = callback_.WaitForResult(); |
161 EXPECT_EQ(static_cast<int>(payload_write.size()), rv); | 165 EXPECT_EQ(static_cast<int>(payload_write.size()), rv); |
162 | 166 |
163 buffer = new IOBuffer(payload_read.size()); | 167 buffer = new IOBuffer(payload_read.size()); |
164 rv = user_sock_->Read(buffer, payload_read.size(), &callback_); | 168 rv = user_sock_->Read(buffer, payload_read.size(), &callback_); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 CapturingNetLog log(CapturingNetLog::kUnbounded); | 205 CapturingNetLog log(CapturingNetLog::kUnbounded); |
202 | 206 |
203 user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads), | 207 user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads), |
204 data_writes, arraysize(data_writes), | 208 data_writes, arraysize(data_writes), |
205 host_resolver_.get(), | 209 host_resolver_.get(), |
206 "localhost", 80, | 210 "localhost", 80, |
207 &log)); | 211 &log)); |
208 | 212 |
209 int rv = user_sock_->Connect(&callback_); | 213 int rv = user_sock_->Connect(&callback_); |
210 EXPECT_EQ(ERR_IO_PENDING, rv); | 214 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 215 |
| 216 net::CapturingNetLog::EntryList entries; |
| 217 log.GetEntries(&entries); |
211 EXPECT_TRUE(LogContainsBeginEvent( | 218 EXPECT_TRUE(LogContainsBeginEvent( |
212 log.entries(), 0, NetLog::TYPE_SOCKS_CONNECT)); | 219 entries, 0, NetLog::TYPE_SOCKS_CONNECT)); |
| 220 |
213 rv = callback_.WaitForResult(); | 221 rv = callback_.WaitForResult(); |
214 EXPECT_EQ(tests[i].fail_code, rv); | 222 EXPECT_EQ(tests[i].fail_code, rv); |
215 EXPECT_FALSE(user_sock_->IsConnected()); | 223 EXPECT_FALSE(user_sock_->IsConnected()); |
216 EXPECT_TRUE(tcp_sock_->IsConnected()); | 224 EXPECT_TRUE(tcp_sock_->IsConnected()); |
| 225 log.GetEntries(&entries); |
217 EXPECT_TRUE(LogContainsEndEvent( | 226 EXPECT_TRUE(LogContainsEndEvent( |
218 log.entries(), -1, NetLog::TYPE_SOCKS_CONNECT)); | 227 entries, -1, NetLog::TYPE_SOCKS_CONNECT)); |
219 } | 228 } |
220 } | 229 } |
221 | 230 |
222 // Tests scenario when the server sends the handshake response in | 231 // Tests scenario when the server sends the handshake response in |
223 // more than one packet. | 232 // more than one packet. |
224 TEST_F(SOCKSClientSocketTest, PartialServerReads) { | 233 TEST_F(SOCKSClientSocketTest, PartialServerReads) { |
225 const char kSOCKSPartialReply1[] = { 0x00 }; | 234 const char kSOCKSPartialReply1[] = { 0x00 }; |
226 const char kSOCKSPartialReply2[] = { 0x5A, 0x00, 0x00, 0, 0, 0, 0 }; | 235 const char kSOCKSPartialReply2[] = { 0x5A, 0x00, 0x00, 0, 0, 0, 0 }; |
227 | 236 |
228 MockWrite data_writes[] = { | 237 MockWrite data_writes[] = { |
229 MockWrite(true, kSOCKSOkRequest, arraysize(kSOCKSOkRequest)) }; | 238 MockWrite(true, kSOCKSOkRequest, arraysize(kSOCKSOkRequest)) }; |
230 MockRead data_reads[] = { | 239 MockRead data_reads[] = { |
231 MockRead(true, kSOCKSPartialReply1, arraysize(kSOCKSPartialReply1)), | 240 MockRead(true, kSOCKSPartialReply1, arraysize(kSOCKSPartialReply1)), |
232 MockRead(true, kSOCKSPartialReply2, arraysize(kSOCKSPartialReply2)) }; | 241 MockRead(true, kSOCKSPartialReply2, arraysize(kSOCKSPartialReply2)) }; |
233 CapturingNetLog log(CapturingNetLog::kUnbounded); | 242 CapturingNetLog log(CapturingNetLog::kUnbounded); |
234 | 243 |
235 user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads), | 244 user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads), |
236 data_writes, arraysize(data_writes), | 245 data_writes, arraysize(data_writes), |
237 host_resolver_.get(), | 246 host_resolver_.get(), |
238 "localhost", 80, | 247 "localhost", 80, |
239 &log)); | 248 &log)); |
240 | 249 |
241 int rv = user_sock_->Connect(&callback_); | 250 int rv = user_sock_->Connect(&callback_); |
242 EXPECT_EQ(ERR_IO_PENDING, rv); | 251 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 252 net::CapturingNetLog::EntryList entries; |
| 253 log.GetEntries(&entries); |
243 EXPECT_TRUE(LogContainsBeginEvent( | 254 EXPECT_TRUE(LogContainsBeginEvent( |
244 log.entries(), 0, NetLog::TYPE_SOCKS_CONNECT)); | 255 entries, 0, NetLog::TYPE_SOCKS_CONNECT)); |
| 256 |
245 rv = callback_.WaitForResult(); | 257 rv = callback_.WaitForResult(); |
246 EXPECT_EQ(OK, rv); | 258 EXPECT_EQ(OK, rv); |
247 EXPECT_TRUE(user_sock_->IsConnected()); | 259 EXPECT_TRUE(user_sock_->IsConnected()); |
| 260 log.GetEntries(&entries); |
248 EXPECT_TRUE(LogContainsEndEvent( | 261 EXPECT_TRUE(LogContainsEndEvent( |
249 log.entries(), -1, NetLog::TYPE_SOCKS_CONNECT)); | 262 entries, -1, NetLog::TYPE_SOCKS_CONNECT)); |
250 } | 263 } |
251 | 264 |
252 // Tests scenario when the client sends the handshake request in | 265 // Tests scenario when the client sends the handshake request in |
253 // more than one packet. | 266 // more than one packet. |
254 TEST_F(SOCKSClientSocketTest, PartialClientWrites) { | 267 TEST_F(SOCKSClientSocketTest, PartialClientWrites) { |
255 const char kSOCKSPartialRequest1[] = { 0x04, 0x01 }; | 268 const char kSOCKSPartialRequest1[] = { 0x04, 0x01 }; |
256 const char kSOCKSPartialRequest2[] = { 0x00, 0x50, 127, 0, 0, 1, 0 }; | 269 const char kSOCKSPartialRequest2[] = { 0x00, 0x50, 127, 0, 0, 1, 0 }; |
257 | 270 |
258 MockWrite data_writes[] = { | 271 MockWrite data_writes[] = { |
259 MockWrite(true, arraysize(kSOCKSPartialRequest1)), | 272 MockWrite(true, arraysize(kSOCKSPartialRequest1)), |
260 // simulate some empty writes | 273 // simulate some empty writes |
261 MockWrite(true, 0), | 274 MockWrite(true, 0), |
262 MockWrite(true, 0), | 275 MockWrite(true, 0), |
263 MockWrite(true, kSOCKSPartialRequest2, | 276 MockWrite(true, kSOCKSPartialRequest2, |
264 arraysize(kSOCKSPartialRequest2)) }; | 277 arraysize(kSOCKSPartialRequest2)) }; |
265 MockRead data_reads[] = { | 278 MockRead data_reads[] = { |
266 MockRead(true, kSOCKSOkReply, arraysize(kSOCKSOkReply)) }; | 279 MockRead(true, kSOCKSOkReply, arraysize(kSOCKSOkReply)) }; |
267 CapturingNetLog log(CapturingNetLog::kUnbounded); | 280 CapturingNetLog log(CapturingNetLog::kUnbounded); |
268 | 281 |
269 user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads), | 282 user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads), |
270 data_writes, arraysize(data_writes), | 283 data_writes, arraysize(data_writes), |
271 host_resolver_.get(), | 284 host_resolver_.get(), |
272 "localhost", 80, | 285 "localhost", 80, |
273 &log)); | 286 &log)); |
274 | 287 |
275 int rv = user_sock_->Connect(&callback_); | 288 int rv = user_sock_->Connect(&callback_); |
276 EXPECT_EQ(ERR_IO_PENDING, rv); | 289 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 290 net::CapturingNetLog::EntryList entries; |
| 291 log.GetEntries(&entries); |
277 EXPECT_TRUE(LogContainsBeginEvent( | 292 EXPECT_TRUE(LogContainsBeginEvent( |
278 log.entries(), 0, NetLog::TYPE_SOCKS_CONNECT)); | 293 entries, 0, NetLog::TYPE_SOCKS_CONNECT)); |
| 294 |
279 rv = callback_.WaitForResult(); | 295 rv = callback_.WaitForResult(); |
280 EXPECT_EQ(OK, rv); | 296 EXPECT_EQ(OK, rv); |
281 EXPECT_TRUE(user_sock_->IsConnected()); | 297 EXPECT_TRUE(user_sock_->IsConnected()); |
| 298 log.GetEntries(&entries); |
282 EXPECT_TRUE(LogContainsEndEvent( | 299 EXPECT_TRUE(LogContainsEndEvent( |
283 log.entries(), -1, NetLog::TYPE_SOCKS_CONNECT)); | 300 entries, -1, NetLog::TYPE_SOCKS_CONNECT)); |
284 } | 301 } |
285 | 302 |
286 // Tests the case when the server sends a smaller sized handshake data | 303 // Tests the case when the server sends a smaller sized handshake data |
287 // and closes the connection. | 304 // and closes the connection. |
288 TEST_F(SOCKSClientSocketTest, FailedSocketRead) { | 305 TEST_F(SOCKSClientSocketTest, FailedSocketRead) { |
289 MockWrite data_writes[] = { | 306 MockWrite data_writes[] = { |
290 MockWrite(true, kSOCKSOkRequest, arraysize(kSOCKSOkRequest)) }; | 307 MockWrite(true, kSOCKSOkRequest, arraysize(kSOCKSOkRequest)) }; |
291 MockRead data_reads[] = { | 308 MockRead data_reads[] = { |
292 MockRead(true, kSOCKSOkReply, arraysize(kSOCKSOkReply) - 2), | 309 MockRead(true, kSOCKSOkReply, arraysize(kSOCKSOkReply) - 2), |
293 // close connection unexpectedly | 310 // close connection unexpectedly |
294 MockRead(false, 0) }; | 311 MockRead(false, 0) }; |
295 CapturingNetLog log(CapturingNetLog::kUnbounded); | 312 CapturingNetLog log(CapturingNetLog::kUnbounded); |
296 | 313 |
297 user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads), | 314 user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads), |
298 data_writes, arraysize(data_writes), | 315 data_writes, arraysize(data_writes), |
299 host_resolver_.get(), | 316 host_resolver_.get(), |
300 "localhost", 80, | 317 "localhost", 80, |
301 &log)); | 318 &log)); |
302 | 319 |
303 int rv = user_sock_->Connect(&callback_); | 320 int rv = user_sock_->Connect(&callback_); |
304 EXPECT_EQ(ERR_IO_PENDING, rv); | 321 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 322 net::CapturingNetLog::EntryList entries; |
| 323 log.GetEntries(&entries); |
305 EXPECT_TRUE(LogContainsBeginEvent( | 324 EXPECT_TRUE(LogContainsBeginEvent( |
306 log.entries(), 0, NetLog::TYPE_SOCKS_CONNECT)); | 325 entries, 0, NetLog::TYPE_SOCKS_CONNECT)); |
| 326 |
307 rv = callback_.WaitForResult(); | 327 rv = callback_.WaitForResult(); |
308 EXPECT_EQ(ERR_CONNECTION_CLOSED, rv); | 328 EXPECT_EQ(ERR_CONNECTION_CLOSED, rv); |
309 EXPECT_FALSE(user_sock_->IsConnected()); | 329 EXPECT_FALSE(user_sock_->IsConnected()); |
| 330 log.GetEntries(&entries); |
310 EXPECT_TRUE(LogContainsEndEvent( | 331 EXPECT_TRUE(LogContainsEndEvent( |
311 log.entries(), -1, NetLog::TYPE_SOCKS_CONNECT)); | 332 entries, -1, NetLog::TYPE_SOCKS_CONNECT)); |
312 } | 333 } |
313 | 334 |
314 // Tries to connect to an unknown DNS and on failure should revert to SOCKS4A. | 335 // Tries to connect to an unknown DNS and on failure should revert to SOCKS4A. |
315 TEST_F(SOCKSClientSocketTest, SOCKS4AFailedDNS) { | 336 TEST_F(SOCKSClientSocketTest, SOCKS4AFailedDNS) { |
316 const char hostname[] = "unresolved.ipv4.address"; | 337 const char hostname[] = "unresolved.ipv4.address"; |
317 | 338 |
318 host_resolver_->rules()->AddSimulatedFailure(hostname); | 339 host_resolver_->rules()->AddSimulatedFailure(hostname); |
319 | 340 |
320 std::string request(kSOCKS4aInitialRequest, | 341 std::string request(kSOCKS4aInitialRequest, |
321 arraysize(kSOCKS4aInitialRequest)); | 342 arraysize(kSOCKS4aInitialRequest)); |
322 request.append(hostname, arraysize(hostname)); | 343 request.append(hostname, arraysize(hostname)); |
323 | 344 |
324 MockWrite data_writes[] = { | 345 MockWrite data_writes[] = { |
325 MockWrite(false, request.data(), request.size()) }; | 346 MockWrite(false, request.data(), request.size()) }; |
326 MockRead data_reads[] = { | 347 MockRead data_reads[] = { |
327 MockRead(false, kSOCKSOkReply, arraysize(kSOCKSOkReply)) }; | 348 MockRead(false, kSOCKSOkReply, arraysize(kSOCKSOkReply)) }; |
328 CapturingNetLog log(CapturingNetLog::kUnbounded); | 349 CapturingNetLog log(CapturingNetLog::kUnbounded); |
329 | 350 |
330 user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads), | 351 user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads), |
331 data_writes, arraysize(data_writes), | 352 data_writes, arraysize(data_writes), |
332 host_resolver_.get(), | 353 host_resolver_.get(), |
333 hostname, 80, | 354 hostname, 80, |
334 &log)); | 355 &log)); |
335 | 356 |
336 int rv = user_sock_->Connect(&callback_); | 357 int rv = user_sock_->Connect(&callback_); |
337 EXPECT_EQ(ERR_IO_PENDING, rv); | 358 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 359 net::CapturingNetLog::EntryList entries; |
| 360 log.GetEntries(&entries); |
338 EXPECT_TRUE(LogContainsBeginEvent( | 361 EXPECT_TRUE(LogContainsBeginEvent( |
339 log.entries(), 0, NetLog::TYPE_SOCKS_CONNECT)); | 362 entries, 0, NetLog::TYPE_SOCKS_CONNECT)); |
| 363 |
340 rv = callback_.WaitForResult(); | 364 rv = callback_.WaitForResult(); |
341 EXPECT_EQ(OK, rv); | 365 EXPECT_EQ(OK, rv); |
342 EXPECT_TRUE(user_sock_->IsConnected()); | 366 EXPECT_TRUE(user_sock_->IsConnected()); |
343 EXPECT_EQ(SOCKSClientSocket::kSOCKS4a, user_sock_->socks_version_); | 367 EXPECT_EQ(SOCKSClientSocket::kSOCKS4a, user_sock_->socks_version_); |
| 368 log.GetEntries(&entries); |
344 EXPECT_TRUE(LogContainsEndEvent( | 369 EXPECT_TRUE(LogContainsEndEvent( |
345 log.entries(), -1, NetLog::TYPE_SOCKS_CONNECT)); | 370 entries, -1, NetLog::TYPE_SOCKS_CONNECT)); |
346 } | 371 } |
347 | 372 |
348 // Tries to connect to a domain that resolves to IPv6. | 373 // Tries to connect to a domain that resolves to IPv6. |
349 // Should revert to SOCKS4a. | 374 // Should revert to SOCKS4a. |
350 TEST_F(SOCKSClientSocketTest, SOCKS4AIfDomainInIPv6) { | 375 TEST_F(SOCKSClientSocketTest, SOCKS4AIfDomainInIPv6) { |
351 const char hostname[] = "an.ipv6.address"; | 376 const char hostname[] = "an.ipv6.address"; |
352 | 377 |
353 host_resolver_->rules()->AddIPLiteralRule(hostname, | 378 host_resolver_->rules()->AddIPLiteralRule(hostname, |
354 "2001:db8:8714:3a90::12", ""); | 379 "2001:db8:8714:3a90::12", ""); |
355 | 380 |
356 std::string request(kSOCKS4aInitialRequest, | 381 std::string request(kSOCKS4aInitialRequest, |
357 arraysize(kSOCKS4aInitialRequest)); | 382 arraysize(kSOCKS4aInitialRequest)); |
358 request.append(hostname, arraysize(hostname)); | 383 request.append(hostname, arraysize(hostname)); |
359 | 384 |
360 MockWrite data_writes[] = { | 385 MockWrite data_writes[] = { |
361 MockWrite(false, request.data(), request.size()) }; | 386 MockWrite(false, request.data(), request.size()) }; |
362 MockRead data_reads[] = { | 387 MockRead data_reads[] = { |
363 MockRead(false, kSOCKSOkReply, arraysize(kSOCKSOkReply)) }; | 388 MockRead(false, kSOCKSOkReply, arraysize(kSOCKSOkReply)) }; |
364 CapturingNetLog log(CapturingNetLog::kUnbounded); | 389 CapturingNetLog log(CapturingNetLog::kUnbounded); |
365 | 390 |
366 user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads), | 391 user_sock_.reset(BuildMockSocket(data_reads, arraysize(data_reads), |
367 data_writes, arraysize(data_writes), | 392 data_writes, arraysize(data_writes), |
368 host_resolver_.get(), | 393 host_resolver_.get(), |
369 hostname, 80, | 394 hostname, 80, |
370 &log)); | 395 &log)); |
371 | 396 |
372 int rv = user_sock_->Connect(&callback_); | 397 int rv = user_sock_->Connect(&callback_); |
373 EXPECT_EQ(ERR_IO_PENDING, rv); | 398 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 399 net::CapturingNetLog::EntryList entries; |
| 400 log.GetEntries(&entries); |
374 EXPECT_TRUE(LogContainsBeginEvent( | 401 EXPECT_TRUE(LogContainsBeginEvent( |
375 log.entries(), 0, NetLog::TYPE_SOCKS_CONNECT)); | 402 entries, 0, NetLog::TYPE_SOCKS_CONNECT)); |
| 403 |
376 rv = callback_.WaitForResult(); | 404 rv = callback_.WaitForResult(); |
377 EXPECT_EQ(OK, rv); | 405 EXPECT_EQ(OK, rv); |
378 EXPECT_TRUE(user_sock_->IsConnected()); | 406 EXPECT_TRUE(user_sock_->IsConnected()); |
379 EXPECT_EQ(SOCKSClientSocket::kSOCKS4a, user_sock_->socks_version_); | 407 EXPECT_EQ(SOCKSClientSocket::kSOCKS4a, user_sock_->socks_version_); |
| 408 log.GetEntries(&entries); |
380 EXPECT_TRUE(LogContainsEndEvent( | 409 EXPECT_TRUE(LogContainsEndEvent( |
381 log.entries(), -1, NetLog::TYPE_SOCKS_CONNECT)); | 410 entries, -1, NetLog::TYPE_SOCKS_CONNECT)); |
382 } | 411 } |
383 | 412 |
384 // Calls Disconnect() while a host resolve is in progress. The outstanding host | 413 // Calls Disconnect() while a host resolve is in progress. The outstanding host |
385 // resolve should be cancelled. | 414 // resolve should be cancelled. |
386 TEST_F(SOCKSClientSocketTest, DisconnectWhileHostResolveInProgress) { | 415 TEST_F(SOCKSClientSocketTest, DisconnectWhileHostResolveInProgress) { |
387 scoped_ptr<HangingHostResolver> hanging_resolver(new HangingHostResolver()); | 416 scoped_ptr<HangingHostResolver> hanging_resolver(new HangingHostResolver()); |
388 | 417 |
389 // Doesn't matter what the socket data is, we will never use it -- garbage. | 418 // Doesn't matter what the socket data is, we will never use it -- garbage. |
390 MockWrite data_writes[] = { MockWrite(false, "", 0) }; | 419 MockWrite data_writes[] = { MockWrite(false, "", 0) }; |
391 MockRead data_reads[] = { MockRead(false, "", 0) }; | 420 MockRead data_reads[] = { MockRead(false, "", 0) }; |
(...skipping 17 matching lines...) Expand all Loading... |
409 // Disconnect the SOCKS socket -- this should cancel the outstanding resolve. | 438 // Disconnect the SOCKS socket -- this should cancel the outstanding resolve. |
410 user_sock_->Disconnect(); | 439 user_sock_->Disconnect(); |
411 | 440 |
412 EXPECT_FALSE(hanging_resolver->HasOutstandingRequest()); | 441 EXPECT_FALSE(hanging_resolver->HasOutstandingRequest()); |
413 | 442 |
414 EXPECT_FALSE(user_sock_->IsConnected()); | 443 EXPECT_FALSE(user_sock_->IsConnected()); |
415 EXPECT_FALSE(user_sock_->IsConnectedAndIdle()); | 444 EXPECT_FALSE(user_sock_->IsConnectedAndIdle()); |
416 } | 445 } |
417 | 446 |
418 } // namespace net | 447 } // namespace net |
OLD | NEW |