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

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

Issue 1585022: Make sure to strip the brackets around IPv6 literals when resolving the hostn... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Address wtc's comments Created 10 years, 8 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') | 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 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 TEST_F(FtpNetworkTransactionTest, FailedLookup) { 670 TEST_F(FtpNetworkTransactionTest, FailedLookup) {
671 FtpRequestInfo request_info = GetRequestInfo("ftp://badhost"); 671 FtpRequestInfo request_info = GetRequestInfo("ftp://badhost");
672 host_resolver_->rules()->AddSimulatedFailure("badhost"); 672 host_resolver_->rules()->AddSimulatedFailure("badhost");
673 EXPECT_EQ(LOAD_STATE_IDLE, transaction_.GetLoadState()); 673 EXPECT_EQ(LOAD_STATE_IDLE, transaction_.GetLoadState());
674 ASSERT_EQ(ERR_IO_PENDING, 674 ASSERT_EQ(ERR_IO_PENDING,
675 transaction_.Start(&request_info, &callback_, NULL)); 675 transaction_.Start(&request_info, &callback_, NULL));
676 ASSERT_EQ(ERR_NAME_NOT_RESOLVED, callback_.WaitForResult()); 676 ASSERT_EQ(ERR_NAME_NOT_RESOLVED, callback_.WaitForResult());
677 EXPECT_EQ(LOAD_STATE_IDLE, transaction_.GetLoadState()); 677 EXPECT_EQ(LOAD_STATE_IDLE, transaction_.GetLoadState());
678 } 678 }
679 679
680 // Check that when determining the host, the square brackets decorating IPv6
681 // literals in URLs are stripped.
682 TEST_F(FtpNetworkTransactionTest, StripBracketsFromIPv6Literals) {
683 host_resolver_->rules()->AddSimulatedFailure("[::1]");
684
685 // We start a transaction that is expected to fail with ERR_INVALID_RESPONSE.
686 // The important part of this test is to make sure that we don't fail with
687 // ERR_NAME_NOT_RESOLVED, since that would mean the decorated hostname
688 // was used.
689 FtpSocketDataProviderEvilSize ctrl_socket(
690 "213 99999999999999999999999999999999\r\n",
691 FtpSocketDataProvider::PRE_QUIT);
692 ExecuteTransaction(&ctrl_socket, "ftp://[::1]/file", ERR_INVALID_RESPONSE);
693 }
694
680 TEST_F(FtpNetworkTransactionTest, DirectoryTransaction) { 695 TEST_F(FtpNetworkTransactionTest, DirectoryTransaction) {
681 FtpSocketDataProviderDirectoryListing ctrl_socket; 696 FtpSocketDataProviderDirectoryListing ctrl_socket;
682 ExecuteTransaction(&ctrl_socket, "ftp://host", OK); 697 ExecuteTransaction(&ctrl_socket, "ftp://host", OK);
683 698
684 EXPECT_TRUE(transaction_.GetResponseInfo()->is_directory_listing); 699 EXPECT_TRUE(transaction_.GetResponseInfo()->is_directory_listing);
685 EXPECT_EQ(-1, transaction_.GetResponseInfo()->expected_content_size); 700 EXPECT_EQ(-1, transaction_.GetResponseInfo()->expected_content_size);
686 } 701 }
687 702
688 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionWithTypecode) { 703 TEST_F(FtpNetworkTransactionTest, DirectoryTransactionWithTypecode) {
689 FtpSocketDataProviderDirectoryListingWithTypecode ctrl_socket; 704 FtpSocketDataProviderDirectoryListingWithTypecode ctrl_socket;
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 FtpSocketDataProviderFileDownload ctrl_socket; 1210 FtpSocketDataProviderFileDownload ctrl_socket;
1196 TransactionFailHelper(&ctrl_socket, 1211 TransactionFailHelper(&ctrl_socket,
1197 "ftp://host/file", 1212 "ftp://host/file",
1198 FtpSocketDataProvider::PRE_PWD, 1213 FtpSocketDataProvider::PRE_PWD,
1199 FtpSocketDataProvider::PRE_TYPE, 1214 FtpSocketDataProvider::PRE_TYPE,
1200 "257 \"\"\r\n", 1215 "257 \"\"\r\n",
1201 OK); 1216 OK);
1202 } 1217 }
1203 1218
1204 } // namespace net 1219 } // 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