diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-02 08:25:50 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-02 08:25:50 +0000 |
commit | 071990ccaf6a865287b62a387ed729a6c261a50f (patch) | |
tree | a99e3d039701d2520ba113a1da940a7c5fff2369 /net/ftp/ftp_network_transaction_unittest.cc | |
parent | 56a6f0fd7b3f731f85e902d13f5658817a89dbbf (diff) | |
download | chromium_src-071990ccaf6a865287b62a387ed729a6c261a50f.zip chromium_src-071990ccaf6a865287b62a387ed729a6c261a50f.tar.gz chromium_src-071990ccaf6a865287b62a387ed729a6c261a50f.tar.bz2 |
Correctly handle FTP servers which unexpectedly close the control connection.
TEST=Covered by net_unittests.
BUG=25023
Review URL: http://codereview.chromium.org/340054
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30693 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/ftp/ftp_network_transaction_unittest.cc')
-rw-r--r-- | net/ftp/ftp_network_transaction_unittest.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/net/ftp/ftp_network_transaction_unittest.cc b/net/ftp/ftp_network_transaction_unittest.cc index af86b13..169e788 100644 --- a/net/ftp/ftp_network_transaction_unittest.cc +++ b/net/ftp/ftp_network_transaction_unittest.cc @@ -502,6 +502,27 @@ class FtpMockControlSocketEvilLogin : public FtpMockControlSocketFileDownload { DISALLOW_COPY_AND_ASSIGN(FtpMockControlSocketEvilLogin); }; +class FtpMockControlSocketCloseConnection : public FtpMockControlSocket { + public: + FtpMockControlSocketCloseConnection() { + } + + virtual MockWriteResult OnWrite(const std::string& data) { + if (InjectFault()) + return MockWriteResult(true, data.length()); + switch (state()) { + case PRE_USER: + return Verify("USER anonymous\r\n", data, + PRE_QUIT, ""); + default: + return FtpMockControlSocket::OnWrite(data); + } + } + + private: + DISALLOW_COPY_AND_ASSIGN(FtpMockControlSocketCloseConnection); +}; + class FtpNetworkTransactionTest : public PlatformTest { public: FtpNetworkTransactionTest() @@ -849,6 +870,12 @@ TEST_F(FtpNetworkTransactionTest, Escaping) { OK); } +// Regression test for http://crbug.com/25023. +TEST_F(FtpNetworkTransactionTest, CloseConnection) { + FtpMockControlSocketCloseConnection ctrl_socket; + ExecuteTransaction(&ctrl_socket, "ftp://host", ERR_EMPTY_RESPONSE); +} + TEST_F(FtpNetworkTransactionTest, DirectoryTransactionFailUser) { FtpMockControlSocketDirectoryListing ctrl_socket; TransactionFailHelper(&ctrl_socket, |