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

Side by Side Diff: net/ftp/ftp_network_transaction_unittest.cc

Issue 10309002: Reimplements net::AddressList without struct addrinfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: get_canonical_name -> canonical_name. iterator to indexing Created 8 years, 7 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/ftp/ftp_network_transaction.cc ('k') | net/http/http_auth_handler_negotiate.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/ftp/ftp_network_transaction.h" 5 #include "net/ftp/ftp_network_transaction.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "net/base/host_port_pair.h" 13 #include "net/base/host_port_pair.h"
14 #include "net/base/io_buffer.h" 14 #include "net/base/io_buffer.h"
15 #include "net/base/mock_host_resolver.h" 15 #include "net/base/mock_host_resolver.h"
16 #include "net/base/net_util.h" 16 #include "net/base/net_util.h"
17 #include "net/base/sys_addrinfo.h"
18 #include "net/base/test_completion_callback.h" 17 #include "net/base/test_completion_callback.h"
19 #include "net/ftp/ftp_network_session.h" 18 #include "net/ftp/ftp_network_session.h"
20 #include "net/ftp/ftp_request_info.h" 19 #include "net/ftp/ftp_request_info.h"
21 #include "net/socket/socket_test_util.h" 20 #include "net/socket/socket_test_util.h"
22 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
23 #include "testing/platform_test.h" 22 #include "testing/platform_test.h"
24 23
25 namespace { 24 namespace {
26 25
27 // Size we use for IOBuffers used to receive data from the test data socket. 26 // Size we use for IOBuffers used to receive data from the test data socket.
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 // The transaction fires the callback when we can start reading data. That 1061 // The transaction fires the callback when we can start reading data. That
1063 // means that the data socket should be open. 1062 // means that the data socket should be open.
1064 MockTCPClientSocket* data_socket = 1063 MockTCPClientSocket* data_socket =
1065 static_cast<MockTCPClientSocket*>(transaction_.data_socket_.get()); 1064 static_cast<MockTCPClientSocket*>(transaction_.data_socket_.get());
1066 ASSERT_TRUE(data_socket); 1065 ASSERT_TRUE(data_socket);
1067 ASSERT_TRUE(data_socket->IsConnected()); 1066 ASSERT_TRUE(data_socket->IsConnected());
1068 1067
1069 // Even if the PASV response specified some other address, we connect 1068 // Even if the PASV response specified some other address, we connect
1070 // to the address we used for control connection (which could be 127.0.0.1 1069 // to the address we used for control connection (which could be 127.0.0.1
1071 // or ::1 depending on whether we use IPv6). 1070 // or ::1 depending on whether we use IPv6).
1072 const struct addrinfo* addrinfo = data_socket->addresses().head(); 1071 for (AddressList::const_iterator it = data_socket->addresses().begin();
1073 while (addrinfo) { 1072 it != data_socket->addresses().end(); ++it) {
1074 EXPECT_NE("10.1.2.3", NetAddressToString(addrinfo)); 1073 EXPECT_NE("10.1.2.3", it->ToStringWithoutPort());
1075 addrinfo = addrinfo->ai_next;
1076 } 1074 }
1077 } 1075 }
1078 1076
1079 TEST_F(FtpNetworkTransactionTest, DownloadTransactionEvilEpsvReallyBadFormat1) { 1077 TEST_F(FtpNetworkTransactionTest, DownloadTransactionEvilEpsvReallyBadFormat1) {
1080 FtpSocketDataProviderEvilEpsv ctrl_socket("227 Portscan (|||22)\r\n", 1078 FtpSocketDataProviderEvilEpsv ctrl_socket("227 Portscan (|||22)\r\n",
1081 FtpSocketDataProvider::PRE_QUIT); 1079 FtpSocketDataProvider::PRE_QUIT);
1082 ExecuteTransaction(&ctrl_socket, "ftp://host/file", ERR_INVALID_RESPONSE); 1080 ExecuteTransaction(&ctrl_socket, "ftp://host/file", ERR_INVALID_RESPONSE);
1083 } 1081 }
1084 1082
1085 TEST_F(FtpNetworkTransactionTest, DownloadTransactionEvilEpsvReallyBadFormat2) { 1083 TEST_F(FtpNetworkTransactionTest, DownloadTransactionEvilEpsvReallyBadFormat2) {
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 FtpSocketDataProviderFileDownload ctrl_socket; 1466 FtpSocketDataProviderFileDownload ctrl_socket;
1469 TransactionFailHelper(&ctrl_socket, 1467 TransactionFailHelper(&ctrl_socket,
1470 "ftp://host/file", 1468 "ftp://host/file",
1471 FtpSocketDataProvider::PRE_PWD, 1469 FtpSocketDataProvider::PRE_PWD,
1472 FtpSocketDataProvider::PRE_TYPE, 1470 FtpSocketDataProvider::PRE_TYPE,
1473 "257 \"\"\r\n", 1471 "257 \"\"\r\n",
1474 OK); 1472 OK);
1475 } 1473 }
1476 1474
1477 } // namespace net 1475 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_network_transaction.cc ('k') | net/http/http_auth_handler_negotiate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698