Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <memory> | 5 #include <memory> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 9840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9851 } | 9851 } |
| 9852 #endif // !defined(OS_IOS) | 9852 #endif // !defined(OS_IOS) |
| 9853 | 9853 |
| 9854 #if !defined(DISABLE_FTP_SUPPORT) && !defined(OS_ANDROID) | 9854 #if !defined(DISABLE_FTP_SUPPORT) && !defined(OS_ANDROID) |
| 9855 // These tests aren't passing on Android. Either the RemoteTestServer isn't | 9855 // These tests aren't passing on Android. Either the RemoteTestServer isn't |
| 9856 // starting up successfully, or it can't access the test files. | 9856 // starting up successfully, or it can't access the test files. |
| 9857 // TODO(mmenke): Fix this. See http://crbug.com/495220 | 9857 // TODO(mmenke): Fix this. See http://crbug.com/495220 |
| 9858 class URLRequestTestFTP : public URLRequestTest { | 9858 class URLRequestTestFTP : public URLRequestTest { |
| 9859 public: | 9859 public: |
| 9860 URLRequestTestFTP() | 9860 URLRequestTestFTP() |
| 9861 : ftp_transaction_factory_(&host_resolver_), | 9861 : ftp_test_server_(SpawnedTestServer::TYPE_FTP, |
| 9862 ftp_test_server_(SpawnedTestServer::TYPE_FTP, | |
| 9863 SpawnedTestServer::kLocalhost, | 9862 SpawnedTestServer::kLocalhost, |
| 9864 base::FilePath(kTestFilePath)) { | 9863 base::FilePath(kTestFilePath)) { |
| 9865 // Can't use |default_context_|'s HostResolver to set up the | 9864 // Can't use |default_context_|'s HostResolver to set up the |
| 9866 // FTPTransactionFactory because it hasn't been created yet. | 9865 // FTPTransactionFactory because it hasn't been created yet. |
| 9867 default_context_.set_host_resolver(&host_resolver_); | 9866 default_context_.set_host_resolver(&host_resolver_); |
| 9868 } | 9867 } |
| 9869 | 9868 |
| 9870 // URLRequestTest interface: | 9869 // URLRequestTest interface: |
| 9871 void SetUpFactory() override { | 9870 void SetUpFactory() override { |
| 9872 // Add FTP support to the default URLRequestContext. | 9871 // Add FTP support to the default URLRequestContext. |
| 9873 job_factory_impl_->SetProtocolHandler( | 9872 job_factory_impl_->SetProtocolHandler( |
| 9874 "ftp", base::MakeUnique<FtpProtocolHandler>(&ftp_transaction_factory_)); | 9873 "ftp", FtpProtocolHandler::Create(&host_resolver_)); |
| 9875 } | 9874 } |
| 9876 | 9875 |
| 9877 std::string GetTestFileContents() { | 9876 std::string GetTestFileContents() { |
| 9878 base::FilePath path; | 9877 base::FilePath path; |
| 9879 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &path)); | 9878 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &path)); |
| 9880 path = path.Append(kTestFilePath); | 9879 path = path.Append(kTestFilePath); |
| 9881 path = path.AppendASCII(kFtpTestFile); | 9880 path = path.AppendASCII(kFtpTestFile); |
| 9882 std::string contents; | 9881 std::string contents; |
| 9883 EXPECT_TRUE(base::ReadFileToString(path, &contents)); | 9882 EXPECT_TRUE(base::ReadFileToString(path, &contents)); |
| 9884 return contents; | 9883 return contents; |
| 9885 } | 9884 } |
| 9886 | 9885 |
| 9887 protected: | 9886 protected: |
| 9888 MockHostResolver host_resolver_; | 9887 MockHostResolver host_resolver_; |
|
eroman
2016/10/19 16:29:51
Note this does mean that now the ftp protocol hand
mmenke
2016/10/19 17:09:35
Added a comment (This was the case with the FtpPro
| |
| 9889 FtpNetworkLayer ftp_transaction_factory_; | |
| 9890 | 9888 |
| 9891 SpawnedTestServer ftp_test_server_; | 9889 SpawnedTestServer ftp_test_server_; |
| 9892 }; | 9890 }; |
| 9893 | 9891 |
| 9894 // Make sure an FTP request using an unsafe ports fails. | 9892 // Make sure an FTP request using an unsafe ports fails. |
| 9895 TEST_F(URLRequestTestFTP, UnsafePort) { | 9893 TEST_F(URLRequestTestFTP, UnsafePort) { |
| 9896 GURL url("ftp://127.0.0.1:7"); | 9894 GURL url("ftp://127.0.0.1:7"); |
| 9897 | 9895 |
| 9898 TestDelegate d; | 9896 TestDelegate d; |
| 9899 { | 9897 { |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10217 AddTestInterceptor()->set_main_intercept_job(std::move(job)); | 10215 AddTestInterceptor()->set_main_intercept_job(std::move(job)); |
| 10218 | 10216 |
| 10219 req->Start(); | 10217 req->Start(); |
| 10220 req->Cancel(); | 10218 req->Cancel(); |
| 10221 base::RunLoop().RunUntilIdle(); | 10219 base::RunLoop().RunUntilIdle(); |
| 10222 EXPECT_EQ(ERR_ABORTED, d.request_status()); | 10220 EXPECT_EQ(ERR_ABORTED, d.request_status()); |
| 10223 EXPECT_EQ(0, d.received_redirect_count()); | 10221 EXPECT_EQ(0, d.received_redirect_count()); |
| 10224 } | 10222 } |
| 10225 | 10223 |
| 10226 } // namespace net | 10224 } // namespace net |
| OLD | NEW |