OLD | NEW |
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/socket/socks_client_socket.h" | 5 #include "net/socket/socks_client_socket.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "net/base/address_list.h" | 8 #include "net/base/address_list.h" |
9 #include "net/base/net_log.h" | 9 #include "net/base/net_log.h" |
10 #include "net/base/net_log_unittest.h" | 10 #include "net/base/net_log_unittest.h" |
11 #include "net/base/test_completion_callback.h" | 11 #include "net/base/test_completion_callback.h" |
12 #include "net/base/winsock_init.h" | 12 #include "net/base/winsock_init.h" |
| 13 #include "net/dns/host_resolver.h" |
13 #include "net/dns/mock_host_resolver.h" | 14 #include "net/dns/mock_host_resolver.h" |
14 #include "net/socket/client_socket_factory.h" | 15 #include "net/socket/client_socket_factory.h" |
15 #include "net/socket/socket_test_util.h" | 16 #include "net/socket/socket_test_util.h" |
16 #include "net/socket/tcp_client_socket.h" | 17 #include "net/socket/tcp_client_socket.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "testing/platform_test.h" | 19 #include "testing/platform_test.h" |
19 | 20 |
20 //----------------------------------------------------------------------------- | 21 //----------------------------------------------------------------------------- |
21 | 22 |
22 namespace net { | 23 namespace net { |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 | 408 |
408 // Disconnect the SOCKS socket -- this should cancel the outstanding resolve. | 409 // Disconnect the SOCKS socket -- this should cancel the outstanding resolve. |
409 user_sock_->Disconnect(); | 410 user_sock_->Disconnect(); |
410 | 411 |
411 EXPECT_FALSE(hanging_resolver->HasOutstandingRequest()); | 412 EXPECT_FALSE(hanging_resolver->HasOutstandingRequest()); |
412 | 413 |
413 EXPECT_FALSE(user_sock_->IsConnected()); | 414 EXPECT_FALSE(user_sock_->IsConnected()); |
414 EXPECT_FALSE(user_sock_->IsConnectedAndIdle()); | 415 EXPECT_FALSE(user_sock_->IsConnectedAndIdle()); |
415 } | 416 } |
416 | 417 |
| 418 // Tries to connect to an IPv6 IP. Should fail, as SOCKS4 does not support |
| 419 // IPv6. |
| 420 TEST_F(SOCKSClientSocketTest, NoIPv6) { |
| 421 const char kHostName[] = "::1"; |
| 422 |
| 423 user_sock_ = BuildMockSocket(NULL, 0, |
| 424 NULL, 0, |
| 425 host_resolver_.get(), |
| 426 kHostName, 80, |
| 427 NULL); |
| 428 |
| 429 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, |
| 430 callback_.GetResult(user_sock_->Connect(callback_.callback()))); |
| 431 } |
| 432 |
| 433 // Same as above, but with a real resolver, to protect against regressions. |
| 434 TEST_F(SOCKSClientSocketTest, NoIPv6RealResolver) { |
| 435 const char kHostName[] = "::1"; |
| 436 |
| 437 scoped_ptr<HostResolver> host_resolver( |
| 438 HostResolver::CreateSystemResolver(HostResolver::Options(), NULL)); |
| 439 |
| 440 user_sock_ = BuildMockSocket(NULL, 0, |
| 441 NULL, 0, |
| 442 host_resolver.get(), |
| 443 kHostName, 80, |
| 444 NULL); |
| 445 |
| 446 EXPECT_EQ(ERR_NAME_NOT_RESOLVED, |
| 447 callback_.GetResult(user_sock_->Connect(callback_.callback()))); |
| 448 } |
| 449 |
417 } // namespace net | 450 } // namespace net |
OLD | NEW |