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

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

Issue 2985012: FTP: add more detailed error codes based on RFC 959. (Closed)
Patch Set: fixes Created 10 years, 5 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
« no previous file with comments | « net/ftp/ftp_network_transaction.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/ref_counted.h" 9 #include "base/ref_counted.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 return Verify("PWD\r\n", data, PRE_TYPE, 75 return Verify("PWD\r\n", data, PRE_TYPE,
76 "257 \"/\" is your current location\r\n"); 76 "257 \"/\" is your current location\r\n");
77 case PRE_TYPE: 77 case PRE_TYPE:
78 return Verify(std::string("TYPE ") + data_type_ + "\r\n", data, 78 return Verify(std::string("TYPE ") + data_type_ + "\r\n", data,
79 PRE_EPSV, "200 TYPE set successfully\r\n"); 79 PRE_EPSV, "200 TYPE set successfully\r\n");
80 case PRE_EPSV: 80 case PRE_EPSV:
81 return Verify("EPSV\r\n", data, PRE_SIZE, 81 return Verify("EPSV\r\n", data, PRE_SIZE,
82 "227 Entering Extended Passive Mode (|||31744|)\r\n"); 82 "227 Entering Extended Passive Mode (|||31744|)\r\n");
83 case PRE_NOPASV: 83 case PRE_NOPASV:
84 return Verify("PASV\r\n", data, PRE_QUIT, 84 return Verify("PASV\r\n", data, PRE_QUIT,
85 "500 not going to happen\r\n"); 85 "599 fail\r\n");
wtc 2010/07/20 18:37:09 Just curious: what do you use the "599" response s
86 case PRE_QUIT: 86 case PRE_QUIT:
87 return Verify("QUIT\r\n", data, QUIT, "221 Goodbye.\r\n"); 87 return Verify("QUIT\r\n", data, QUIT, "221 Goodbye.\r\n");
88 default: 88 default:
89 NOTREACHED() << "State not handled " << state(); 89 NOTREACHED() << "State not handled " << state();
90 return MockWriteResult(true, ERR_UNEXPECTED); 90 return MockWriteResult(true, ERR_UNEXPECTED);
91 } 91 }
92 } 92 }
93 93
94 void InjectFailure(State state, State next_state, const char* response) { 94 void InjectFailure(State state, State next_state, const char* response) {
95 DCHECK_EQ(NONE, failure_injection_state_); 95 DCHECK_EQ(NONE, failure_injection_state_);
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 public: 467 public:
468 FtpSocketDataProviderFileDownloadInvalidResponse() { 468 FtpSocketDataProviderFileDownloadInvalidResponse() {
469 } 469 }
470 470
471 virtual MockWriteResult OnWrite(const std::string& data) { 471 virtual MockWriteResult OnWrite(const std::string& data) {
472 if (InjectFault()) 472 if (InjectFault())
473 return MockWriteResult(true, data.length()); 473 return MockWriteResult(true, data.length());
474 switch (state()) { 474 switch (state()) {
475 case PRE_SIZE: 475 case PRE_SIZE:
476 return Verify("SIZE /file\r\n", data, PRE_QUIT, 476 return Verify("SIZE /file\r\n", data, PRE_QUIT,
477 "500 Evil Response\r\n" 477 "599 Evil Response\r\n"
478 "500 More Evil\r\n"); 478 "599 More Evil\r\n");
479 default: 479 default:
480 return FtpSocketDataProviderFileDownload::OnWrite(data); 480 return FtpSocketDataProviderFileDownload::OnWrite(data);
481 } 481 }
482 } 482 }
483 483
484 private: 484 private:
485 DISALLOW_COPY_AND_ASSIGN(FtpSocketDataProviderFileDownloadInvalidResponse); 485 DISALLOW_COPY_AND_ASSIGN(FtpSocketDataProviderFileDownloadInvalidResponse);
486 }; 486 };
487 487
488 class FtpSocketDataProviderEvilEpsv : public FtpSocketDataProviderFileDownload { 488 class FtpSocketDataProviderEvilEpsv : public FtpSocketDataProviderFileDownload {
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 FtpSocketDataProvider ctrl_socket1; 1024 FtpSocketDataProvider ctrl_socket1;
1025 ctrl_socket1.InjectFailure(FtpSocketDataProvider::PRE_PASSWD, 1025 ctrl_socket1.InjectFailure(FtpSocketDataProvider::PRE_PASSWD,
1026 FtpSocketDataProvider::PRE_QUIT, 1026 FtpSocketDataProvider::PRE_QUIT,
1027 "530 Login authentication failed\r\n"); 1027 "530 Login authentication failed\r\n");
1028 mock_socket_factory_.AddSocketDataProvider(&ctrl_socket1); 1028 mock_socket_factory_.AddSocketDataProvider(&ctrl_socket1);
1029 1029
1030 FtpRequestInfo request_info = GetRequestInfo("ftp://host/file"); 1030 FtpRequestInfo request_info = GetRequestInfo("ftp://host/file");
1031 1031
1032 ASSERT_EQ(ERR_IO_PENDING, 1032 ASSERT_EQ(ERR_IO_PENDING,
1033 transaction_.Start(&request_info, &callback_, BoundNetLog())); 1033 transaction_.Start(&request_info, &callback_, BoundNetLog()));
1034 ASSERT_EQ(ERR_FAILED, callback_.WaitForResult()); 1034 ASSERT_EQ(ERR_FTP_FAILED, callback_.WaitForResult());
1035 1035
1036 MockRead ctrl_reads[] = { 1036 MockRead ctrl_reads[] = {
1037 MockRead("220 host TestFTPd\r\n"), 1037 MockRead("220 host TestFTPd\r\n"),
1038 MockRead("221 Goodbye!\r\n"), 1038 MockRead("221 Goodbye!\r\n"),
1039 MockRead(false, OK), 1039 MockRead(false, OK),
1040 }; 1040 };
1041 MockWrite ctrl_writes[] = { 1041 MockWrite ctrl_writes[] = {
1042 MockWrite("QUIT\r\n"), 1042 MockWrite("QUIT\r\n"),
1043 }; 1043 };
1044 StaticSocketDataProvider ctrl_socket2(ctrl_reads, arraysize(ctrl_reads), 1044 StaticSocketDataProvider ctrl_socket2(ctrl_reads, arraysize(ctrl_reads),
1045 ctrl_writes, arraysize(ctrl_writes)); 1045 ctrl_writes, arraysize(ctrl_writes));
1046 mock_socket_factory_.AddSocketDataProvider(&ctrl_socket2); 1046 mock_socket_factory_.AddSocketDataProvider(&ctrl_socket2);
1047 ASSERT_EQ(ERR_IO_PENDING, transaction_.RestartWithAuth(L"foo\nownz0red", 1047 ASSERT_EQ(ERR_IO_PENDING, transaction_.RestartWithAuth(L"foo\nownz0red",
1048 L"innocent", 1048 L"innocent",
1049 &callback_)); 1049 &callback_));
1050 EXPECT_EQ(ERR_MALFORMED_IDENTITY, callback_.WaitForResult()); 1050 EXPECT_EQ(ERR_MALFORMED_IDENTITY, callback_.WaitForResult());
1051 } 1051 }
1052 1052
1053 TEST_F(FtpNetworkTransactionTest, EvilRestartPassword) { 1053 TEST_F(FtpNetworkTransactionTest, EvilRestartPassword) {
1054 FtpSocketDataProvider ctrl_socket1; 1054 FtpSocketDataProvider ctrl_socket1;
1055 ctrl_socket1.InjectFailure(FtpSocketDataProvider::PRE_PASSWD, 1055 ctrl_socket1.InjectFailure(FtpSocketDataProvider::PRE_PASSWD,
1056 FtpSocketDataProvider::PRE_QUIT, 1056 FtpSocketDataProvider::PRE_QUIT,
1057 "530 Login authentication failed\r\n"); 1057 "530 Login authentication failed\r\n");
1058 mock_socket_factory_.AddSocketDataProvider(&ctrl_socket1); 1058 mock_socket_factory_.AddSocketDataProvider(&ctrl_socket1);
1059 1059
1060 FtpRequestInfo request_info = GetRequestInfo("ftp://host/file"); 1060 FtpRequestInfo request_info = GetRequestInfo("ftp://host/file");
1061 1061
1062 ASSERT_EQ(ERR_IO_PENDING, 1062 ASSERT_EQ(ERR_IO_PENDING,
1063 transaction_.Start(&request_info, &callback_, BoundNetLog())); 1063 transaction_.Start(&request_info, &callback_, BoundNetLog()));
1064 ASSERT_EQ(ERR_FAILED, callback_.WaitForResult()); 1064 ASSERT_EQ(ERR_FTP_FAILED, callback_.WaitForResult());
1065 1065
1066 MockRead ctrl_reads[] = { 1066 MockRead ctrl_reads[] = {
1067 MockRead("220 host TestFTPd\r\n"), 1067 MockRead("220 host TestFTPd\r\n"),
1068 MockRead("331 User okay, send password\r\n"), 1068 MockRead("331 User okay, send password\r\n"),
1069 MockRead("221 Goodbye!\r\n"), 1069 MockRead("221 Goodbye!\r\n"),
1070 MockRead(false, OK), 1070 MockRead(false, OK),
1071 }; 1071 };
1072 MockWrite ctrl_writes[] = { 1072 MockWrite ctrl_writes[] = {
1073 MockWrite("USER innocent\r\n"), 1073 MockWrite("USER innocent\r\n"),
1074 MockWrite("QUIT\r\n"), 1074 MockWrite("QUIT\r\n"),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 FtpSocketDataProviderCloseConnection ctrl_socket; 1113 FtpSocketDataProviderCloseConnection ctrl_socket;
1114 ExecuteTransaction(&ctrl_socket, "ftp://host", ERR_EMPTY_RESPONSE); 1114 ExecuteTransaction(&ctrl_socket, "ftp://host", ERR_EMPTY_RESPONSE);
1115 } 1115 }
1116 1116
1117 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionFailUser) { 1117 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionFailUser) {
1118 FtpSocketDataProviderDirectoryListing ctrl_socket; 1118 FtpSocketDataProviderDirectoryListing ctrl_socket;
1119 TransactionFailHelper(&ctrl_socket, 1119 TransactionFailHelper(&ctrl_socket,
1120 "ftp://host", 1120 "ftp://host",
1121 FtpSocketDataProvider::PRE_USER, 1121 FtpSocketDataProvider::PRE_USER,
1122 FtpSocketDataProvider::PRE_QUIT, 1122 FtpSocketDataProvider::PRE_QUIT,
1123 "500 no such user\r\n", 1123 "599 fail\r\n",
1124 ERR_FAILED); 1124 ERR_FTP_FAILED);
1125 } 1125 }
1126 1126
1127 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionFailPass) { 1127 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionFailPass) {
1128 FtpSocketDataProviderDirectoryListing ctrl_socket; 1128 FtpSocketDataProviderDirectoryListing ctrl_socket;
1129 TransactionFailHelper(&ctrl_socket, 1129 TransactionFailHelper(&ctrl_socket,
1130 "ftp://host", 1130 "ftp://host",
1131 FtpSocketDataProvider::PRE_PASSWD, 1131 FtpSocketDataProvider::PRE_PASSWD,
1132 FtpSocketDataProvider::PRE_QUIT, 1132 FtpSocketDataProvider::PRE_QUIT,
1133 "530 Login authentication failed\r\n", 1133 "530 Login authentication failed\r\n",
1134 ERR_FAILED); 1134 ERR_FTP_FAILED);
1135 } 1135 }
1136 1136
1137 // Regression test for http://crbug.com/38707. 1137 // Regression test for http://crbug.com/38707.
1138 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionFailPass503) { 1138 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionFailPass503) {
1139 FtpSocketDataProviderDirectoryListing ctrl_socket; 1139 FtpSocketDataProviderDirectoryListing ctrl_socket;
1140 TransactionFailHelper(&ctrl_socket, 1140 TransactionFailHelper(&ctrl_socket,
1141 "ftp://host", 1141 "ftp://host",
1142 FtpSocketDataProvider::PRE_PASSWD, 1142 FtpSocketDataProvider::PRE_PASSWD,
1143 FtpSocketDataProvider::PRE_QUIT, 1143 FtpSocketDataProvider::PRE_QUIT,
1144 "503 Bad sequence of commands\r\n", 1144 "503 Bad sequence of commands\r\n",
1145 ERR_FAILED); 1145 ERR_FTP_BAD_COMMAND_SEQUENCE);
1146 } 1146 }
1147 1147
1148 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionFailSyst) { 1148 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionFailSyst) {
1149 FtpSocketDataProviderDirectoryListing ctrl_socket; 1149 FtpSocketDataProviderDirectoryListing ctrl_socket;
1150 TransactionFailHelper(&ctrl_socket, 1150 TransactionFailHelper(&ctrl_socket,
1151 "ftp://host", 1151 "ftp://host",
1152 FtpSocketDataProvider::PRE_SYST, 1152 FtpSocketDataProvider::PRE_SYST,
1153 FtpSocketDataProvider::PRE_PWD, 1153 FtpSocketDataProvider::PRE_PWD,
1154 "500 failed syst\r\n", 1154 "599 fail\r\n",
1155 OK); 1155 OK);
1156 } 1156 }
1157 1157
1158 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionFailPwd) { 1158 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionFailPwd) {
1159 FtpSocketDataProviderDirectoryListing ctrl_socket; 1159 FtpSocketDataProviderDirectoryListing ctrl_socket;
1160 TransactionFailHelper(&ctrl_socket, 1160 TransactionFailHelper(&ctrl_socket,
1161 "ftp://host", 1161 "ftp://host",
1162 FtpSocketDataProvider::PRE_PWD, 1162 FtpSocketDataProvider::PRE_PWD,
1163 FtpSocketDataProvider::PRE_QUIT, 1163 FtpSocketDataProvider::PRE_QUIT,
1164 "500 failed pwd\r\n", 1164 "599 fail\r\n",
1165 ERR_FAILED); 1165 ERR_FTP_FAILED);
1166 } 1166 }
1167 1167
1168 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionFailType) { 1168 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionFailType) {
1169 FtpSocketDataProviderDirectoryListing ctrl_socket; 1169 FtpSocketDataProviderDirectoryListing ctrl_socket;
1170 TransactionFailHelper(&ctrl_socket, 1170 TransactionFailHelper(&ctrl_socket,
1171 "ftp://host", 1171 "ftp://host",
1172 FtpSocketDataProvider::PRE_TYPE, 1172 FtpSocketDataProvider::PRE_TYPE,
1173 FtpSocketDataProvider::PRE_QUIT, 1173 FtpSocketDataProvider::PRE_QUIT,
1174 "500 failed type\r\n", 1174 "599 fail\r\n",
1175 ERR_FAILED); 1175 ERR_FTP_FAILED);
1176 } 1176 }
1177 1177
1178 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionFailEpsv) { 1178 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionFailEpsv) {
1179 FtpSocketDataProviderDirectoryListing ctrl_socket; 1179 FtpSocketDataProviderDirectoryListing ctrl_socket;
1180 TransactionFailHelper(&ctrl_socket, 1180 TransactionFailHelper(&ctrl_socket,
1181 "ftp://host", 1181 "ftp://host",
1182 FtpSocketDataProvider::PRE_EPSV, 1182 FtpSocketDataProvider::PRE_EPSV,
1183 FtpSocketDataProvider::PRE_NOPASV, 1183 FtpSocketDataProvider::PRE_NOPASV,
1184 "500 failed epsv\r\n", 1184 "599 fail\r\n",
1185 ERR_FTP_PASV_COMMAND_FAILED); 1185 ERR_FTP_FAILED);
1186 } 1186 }
1187 1187
1188 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionFailCwd) { 1188 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionFailCwd) {
1189 FtpSocketDataProviderDirectoryListing ctrl_socket; 1189 FtpSocketDataProviderDirectoryListing ctrl_socket;
1190 TransactionFailHelper(&ctrl_socket, 1190 TransactionFailHelper(&ctrl_socket,
1191 "ftp://host", 1191 "ftp://host",
1192 FtpSocketDataProvider::PRE_CWD, 1192 FtpSocketDataProvider::PRE_CWD,
1193 FtpSocketDataProvider::PRE_QUIT, 1193 FtpSocketDataProvider::PRE_QUIT,
1194 "500 failed cwd\r\n", 1194 "599 fail\r\n",
1195 ERR_FAILED); 1195 ERR_FTP_FAILED);
1196 } 1196 }
1197 1197
1198 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionFileNotFound) { 1198 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionFileNotFound) {
1199 FtpSocketDataProviderDirectoryListing ctrl_socket; 1199 FtpSocketDataProviderDirectoryListing ctrl_socket;
1200 TransactionFailHelper(&ctrl_socket, 1200 TransactionFailHelper(&ctrl_socket,
1201 "ftp://host", 1201 "ftp://host",
1202 FtpSocketDataProvider::PRE_CWD, 1202 FtpSocketDataProvider::PRE_CWD,
1203 FtpSocketDataProvider::PRE_QUIT, 1203 FtpSocketDataProvider::PRE_QUIT,
1204 "550 cannot open file\r\n", 1204 "550 cannot open file\r\n",
1205 ERR_FILE_NOT_FOUND); 1205 ERR_FILE_NOT_FOUND);
1206 } 1206 }
1207 1207
1208 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionFailMlsd) { 1208 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionFailMlsd) {
1209 FtpSocketDataProviderDirectoryListing ctrl_socket; 1209 FtpSocketDataProviderDirectoryListing ctrl_socket;
1210 TransactionFailHelper(&ctrl_socket, 1210 TransactionFailHelper(&ctrl_socket,
1211 "ftp://host", 1211 "ftp://host",
1212 FtpSocketDataProvider::PRE_MLSD, 1212 FtpSocketDataProvider::PRE_MLSD,
1213 FtpSocketDataProvider::PRE_LIST, 1213 FtpSocketDataProvider::PRE_LIST,
1214 "500 Unrecognized command\r\n", 1214 "500 Unrecognized command\r\n",
1215 OK); 1215 OK);
1216 } 1216 }
1217 1217
1218 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionFailList) { 1218 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionFailList) {
1219 FtpSocketDataProviderVMSDirectoryListing ctrl_socket; 1219 FtpSocketDataProviderVMSDirectoryListing ctrl_socket;
1220 TransactionFailHelper(&ctrl_socket, 1220 TransactionFailHelper(&ctrl_socket,
1221 "ftp://host/dir", 1221 "ftp://host/dir",
1222 FtpSocketDataProvider::PRE_LIST, 1222 FtpSocketDataProvider::PRE_LIST,
1223 FtpSocketDataProvider::PRE_QUIT, 1223 FtpSocketDataProvider::PRE_QUIT,
1224 "500 failed list\r\n", 1224 "599 fail\r\n",
1225 ERR_FAILED); 1225 ERR_FTP_FAILED);
1226 } 1226 }
1227 1227
1228 TEST_F(FtpNetworkTransactionTest, DownloadTransactionFailUser) { 1228 TEST_F(FtpNetworkTransactionTest, DownloadTransactionFailUser) {
1229 FtpSocketDataProviderFileDownload ctrl_socket; 1229 FtpSocketDataProviderFileDownload ctrl_socket;
1230 TransactionFailHelper(&ctrl_socket, 1230 TransactionFailHelper(&ctrl_socket,
1231 "ftp://host/file", 1231 "ftp://host/file",
1232 FtpSocketDataProvider::PRE_USER, 1232 FtpSocketDataProvider::PRE_USER,
1233 FtpSocketDataProvider::PRE_QUIT, 1233 FtpSocketDataProvider::PRE_QUIT,
1234 "500 no such user\r\n", 1234 "599 fail\r\n",
1235 ERR_FAILED); 1235 ERR_FTP_FAILED);
1236 } 1236 }
1237 1237
1238 TEST_F(FtpNetworkTransactionTest, DownloadTransactionFailPass) { 1238 TEST_F(FtpNetworkTransactionTest, DownloadTransactionFailPass) {
1239 FtpSocketDataProviderFileDownload ctrl_socket; 1239 FtpSocketDataProviderFileDownload ctrl_socket;
1240 TransactionFailHelper(&ctrl_socket, 1240 TransactionFailHelper(&ctrl_socket,
1241 "ftp://host/file", 1241 "ftp://host/file",
1242 FtpSocketDataProvider::PRE_PASSWD, 1242 FtpSocketDataProvider::PRE_PASSWD,
1243 FtpSocketDataProvider::PRE_QUIT, 1243 FtpSocketDataProvider::PRE_QUIT,
1244 "530 Login authentication failed\r\n", 1244 "530 Login authentication failed\r\n",
1245 ERR_FAILED); 1245 ERR_FTP_FAILED);
1246 } 1246 }
1247 1247
1248 TEST_F(FtpNetworkTransactionTest, DownloadTransactionFailSyst) { 1248 TEST_F(FtpNetworkTransactionTest, DownloadTransactionFailSyst) {
1249 FtpSocketDataProviderFileDownload ctrl_socket; 1249 FtpSocketDataProviderFileDownload ctrl_socket;
1250 TransactionFailHelper(&ctrl_socket, 1250 TransactionFailHelper(&ctrl_socket,
1251 "ftp://host/file", 1251 "ftp://host/file",
1252 FtpSocketDataProvider::PRE_SYST, 1252 FtpSocketDataProvider::PRE_SYST,
1253 FtpSocketDataProvider::PRE_PWD, 1253 FtpSocketDataProvider::PRE_PWD,
1254 "500 failed syst\r\n", 1254 "599 fail\r\n",
1255 OK); 1255 OK);
1256 } 1256 }
1257 1257
1258 TEST_F(FtpNetworkTransactionTest, DownloadTransactionFailPwd) { 1258 TEST_F(FtpNetworkTransactionTest, DownloadTransactionFailPwd) {
1259 FtpSocketDataProviderFileDownload ctrl_socket; 1259 FtpSocketDataProviderFileDownload ctrl_socket;
1260 TransactionFailHelper(&ctrl_socket, 1260 TransactionFailHelper(&ctrl_socket,
1261 "ftp://host/file", 1261 "ftp://host/file",
1262 FtpSocketDataProvider::PRE_PWD, 1262 FtpSocketDataProvider::PRE_PWD,
1263 FtpSocketDataProvider::PRE_QUIT, 1263 FtpSocketDataProvider::PRE_QUIT,
1264 "500 failed pwd\r\n", 1264 "599 fail\r\n",
1265 ERR_FAILED); 1265 ERR_FTP_FAILED);
1266 } 1266 }
1267 1267
1268 TEST_F(FtpNetworkTransactionTest, DownloadTransactionFailType) { 1268 TEST_F(FtpNetworkTransactionTest, DownloadTransactionFailType) {
1269 FtpSocketDataProviderFileDownload ctrl_socket; 1269 FtpSocketDataProviderFileDownload ctrl_socket;
1270 TransactionFailHelper(&ctrl_socket, 1270 TransactionFailHelper(&ctrl_socket,
1271 "ftp://host/file", 1271 "ftp://host/file",
1272 FtpSocketDataProvider::PRE_TYPE, 1272 FtpSocketDataProvider::PRE_TYPE,
1273 FtpSocketDataProvider::PRE_QUIT, 1273 FtpSocketDataProvider::PRE_QUIT,
1274 "500 failed type\r\n", 1274 "599 fail\r\n",
1275 ERR_FAILED); 1275 ERR_FTP_FAILED);
1276 } 1276 }
1277 1277
1278 TEST_F(FtpNetworkTransactionTest, DownloadTransactionFailEpsv) { 1278 TEST_F(FtpNetworkTransactionTest, DownloadTransactionFailEpsv) {
1279 FtpSocketDataProviderFileDownload ctrl_socket; 1279 FtpSocketDataProviderFileDownload ctrl_socket;
1280 TransactionFailHelper(&ctrl_socket, 1280 TransactionFailHelper(&ctrl_socket,
1281 "ftp://host/file", 1281 "ftp://host/file",
1282 FtpSocketDataProvider::PRE_EPSV, 1282 FtpSocketDataProvider::PRE_EPSV,
1283 FtpSocketDataProvider::PRE_NOPASV, 1283 FtpSocketDataProvider::PRE_NOPASV,
1284 "500 failed pasv\r\n", 1284 "599 fail\r\n",
1285 ERR_FTP_PASV_COMMAND_FAILED); 1285 ERR_FTP_FAILED);
1286 } 1286 }
1287 1287
1288 TEST_F(FtpNetworkTransactionTest, DownloadTransactionFailRetr) { 1288 TEST_F(FtpNetworkTransactionTest, DownloadTransactionFailRetr) {
1289 FtpSocketDataProviderFileDownload ctrl_socket; 1289 FtpSocketDataProviderFileDownload ctrl_socket;
1290 TransactionFailHelper(&ctrl_socket, 1290 TransactionFailHelper(&ctrl_socket,
1291 "ftp://host/file", 1291 "ftp://host/file",
1292 FtpSocketDataProvider::PRE_RETR, 1292 FtpSocketDataProvider::PRE_RETR,
1293 FtpSocketDataProvider::PRE_QUIT, 1293 FtpSocketDataProvider::PRE_QUIT,
1294 "500 failed retr\r\n", 1294 "599 fail\r\n",
1295 ERR_FAILED); 1295 ERR_FTP_FAILED);
1296 } 1296 }
1297 1297
1298 TEST_F(FtpNetworkTransactionTest, DownloadTransactionFileNotFound) { 1298 TEST_F(FtpNetworkTransactionTest, DownloadTransactionFileNotFound) {
1299 FtpSocketDataProviderFileDownload ctrl_socket; 1299 FtpSocketDataProviderFileDownload ctrl_socket;
1300 TransactionFailHelper(&ctrl_socket, 1300 TransactionFailHelper(&ctrl_socket,
1301 "ftp://host/file;type=i", 1301 "ftp://host/file;type=i",
1302 FtpSocketDataProvider::PRE_SIZE, 1302 FtpSocketDataProvider::PRE_SIZE,
1303 FtpSocketDataProvider::PRE_QUIT, 1303 FtpSocketDataProvider::PRE_QUIT,
1304 "550 File Not Found\r\n", 1304 "550 File Not Found\r\n",
1305 ERR_FAILED); 1305 ERR_FTP_FAILED);
1306 } 1306 }
1307 1307
1308 // Test for http://crbug.com/38845. 1308 // Test for http://crbug.com/38845.
1309 TEST_F(FtpNetworkTransactionTest, ZeroLengthDirInPWD) { 1309 TEST_F(FtpNetworkTransactionTest, ZeroLengthDirInPWD) {
1310 FtpSocketDataProviderFileDownload ctrl_socket; 1310 FtpSocketDataProviderFileDownload ctrl_socket;
1311 TransactionFailHelper(&ctrl_socket, 1311 TransactionFailHelper(&ctrl_socket,
1312 "ftp://host/file", 1312 "ftp://host/file",
1313 FtpSocketDataProvider::PRE_PWD, 1313 FtpSocketDataProvider::PRE_PWD,
1314 FtpSocketDataProvider::PRE_TYPE, 1314 FtpSocketDataProvider::PRE_TYPE,
1315 "257 \"\"\r\n", 1315 "257 \"\"\r\n",
1316 OK); 1316 OK);
1317 } 1317 }
1318 1318
1319 } // namespace net 1319 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_network_transaction.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698