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

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

Issue 8340026: Use AuthCredentials throughout the network stack instead of username/password. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix comments Created 9 years, 1 month 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') | net/ftp/ftp_transaction.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 MockRead("221 Goodbye!\r\n"), 1183 MockRead("221 Goodbye!\r\n"),
1184 MockRead(false, OK), 1184 MockRead(false, OK),
1185 }; 1185 };
1186 MockWrite ctrl_writes[] = { 1186 MockWrite ctrl_writes[] = {
1187 MockWrite("QUIT\r\n"), 1187 MockWrite("QUIT\r\n"),
1188 }; 1188 };
1189 StaticSocketDataProvider ctrl_socket2(ctrl_reads, arraysize(ctrl_reads), 1189 StaticSocketDataProvider ctrl_socket2(ctrl_reads, arraysize(ctrl_reads),
1190 ctrl_writes, arraysize(ctrl_writes)); 1190 ctrl_writes, arraysize(ctrl_writes));
1191 mock_socket_factory_.AddSocketDataProvider(&ctrl_socket2); 1191 mock_socket_factory_.AddSocketDataProvider(&ctrl_socket2);
1192 ASSERT_EQ(ERR_IO_PENDING, 1192 ASSERT_EQ(ERR_IO_PENDING,
1193 transaction_.RestartWithAuth(ASCIIToUTF16("foo\nownz0red"), 1193 transaction_.RestartWithAuth(
1194 ASCIIToUTF16("innocent"), 1194 AuthCredentials(
1195 &callback_)); 1195 ASCIIToUTF16("foo\nownz0red"),
1196 ASCIIToUTF16("innocent")),
1197 &callback_));
1196 EXPECT_EQ(ERR_MALFORMED_IDENTITY, callback_.WaitForResult()); 1198 EXPECT_EQ(ERR_MALFORMED_IDENTITY, callback_.WaitForResult());
1197 } 1199 }
1198 1200
1199 TEST_F(FtpNetworkTransactionTest, EvilRestartPassword) { 1201 TEST_F(FtpNetworkTransactionTest, EvilRestartPassword) {
1200 FtpSocketDataProvider ctrl_socket1; 1202 FtpSocketDataProvider ctrl_socket1;
1201 ctrl_socket1.InjectFailure(FtpSocketDataProvider::PRE_PASSWD, 1203 ctrl_socket1.InjectFailure(FtpSocketDataProvider::PRE_PASSWD,
1202 FtpSocketDataProvider::PRE_QUIT, 1204 FtpSocketDataProvider::PRE_QUIT,
1203 "530 Login authentication failed\r\n"); 1205 "530 Login authentication failed\r\n");
1204 mock_socket_factory_.AddSocketDataProvider(&ctrl_socket1); 1206 mock_socket_factory_.AddSocketDataProvider(&ctrl_socket1);
1205 1207
(...skipping 10 matching lines...) Expand all
1216 MockRead(false, OK), 1218 MockRead(false, OK),
1217 }; 1219 };
1218 MockWrite ctrl_writes[] = { 1220 MockWrite ctrl_writes[] = {
1219 MockWrite("USER innocent\r\n"), 1221 MockWrite("USER innocent\r\n"),
1220 MockWrite("QUIT\r\n"), 1222 MockWrite("QUIT\r\n"),
1221 }; 1223 };
1222 StaticSocketDataProvider ctrl_socket2(ctrl_reads, arraysize(ctrl_reads), 1224 StaticSocketDataProvider ctrl_socket2(ctrl_reads, arraysize(ctrl_reads),
1223 ctrl_writes, arraysize(ctrl_writes)); 1225 ctrl_writes, arraysize(ctrl_writes));
1224 mock_socket_factory_.AddSocketDataProvider(&ctrl_socket2); 1226 mock_socket_factory_.AddSocketDataProvider(&ctrl_socket2);
1225 ASSERT_EQ(ERR_IO_PENDING, 1227 ASSERT_EQ(ERR_IO_PENDING,
1226 transaction_.RestartWithAuth(ASCIIToUTF16("innocent"), 1228 transaction_.RestartWithAuth(
1227 ASCIIToUTF16("foo\nownz0red"), 1229 AuthCredentials(ASCIIToUTF16("innocent"),
1228 &callback_)); 1230 ASCIIToUTF16("foo\nownz0red")),
1231 &callback_));
1229 EXPECT_EQ(ERR_MALFORMED_IDENTITY, callback_.WaitForResult()); 1232 EXPECT_EQ(ERR_MALFORMED_IDENTITY, callback_.WaitForResult());
1230 } 1233 }
1231 1234
1232 TEST_F(FtpNetworkTransactionTest, Escaping) { 1235 TEST_F(FtpNetworkTransactionTest, Escaping) {
1233 FtpSocketDataProviderEscaping ctrl_socket; 1236 FtpSocketDataProviderEscaping ctrl_socket;
1234 ExecuteTransaction(&ctrl_socket, "ftp://host/%20%21%22%23%24%25%79%80%81", 1237 ExecuteTransaction(&ctrl_socket, "ftp://host/%20%21%22%23%24%25%79%80%81",
1235 OK); 1238 OK);
1236 } 1239 }
1237 1240
1238 // Test for http://crbug.com/23794. 1241 // Test for http://crbug.com/23794.
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 FtpSocketDataProviderFileDownload ctrl_socket; 1461 FtpSocketDataProviderFileDownload ctrl_socket;
1459 TransactionFailHelper(&ctrl_socket, 1462 TransactionFailHelper(&ctrl_socket,
1460 "ftp://host/file", 1463 "ftp://host/file",
1461 FtpSocketDataProvider::PRE_PWD, 1464 FtpSocketDataProvider::PRE_PWD,
1462 FtpSocketDataProvider::PRE_TYPE, 1465 FtpSocketDataProvider::PRE_TYPE,
1463 "257 \"\"\r\n", 1466 "257 \"\"\r\n",
1464 OK); 1467 OK);
1465 } 1468 }
1466 1469
1467 } // namespace net 1470 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_network_transaction.cc ('k') | net/ftp/ftp_transaction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698