| Index: net/url_request/url_request_unittest.cc
|
| diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
|
| index a1cc679eef112961b19bb2a75eb1db28181bd9c3..05f8801bf53e72b867d745ff12897e707b78320c 100644
|
| --- a/net/url_request/url_request_unittest.cc
|
| +++ b/net/url_request/url_request_unittest.cc
|
| @@ -16,6 +16,7 @@
|
| #include "base/basictypes.h"
|
| #include "base/bind.h"
|
| #include "base/compiler_specific.h"
|
| +#include "base/files/file_path.h"
|
| #include "base/files/file_util.h"
|
| #include "base/files/scoped_temp_dir.h"
|
| #include "base/format_macros.h"
|
| @@ -55,7 +56,6 @@
|
| #include "net/cookies/cookie_store_test_helpers.h"
|
| #include "net/disk_cache/disk_cache.h"
|
| #include "net/dns/mock_host_resolver.h"
|
| -#include "net/ftp/ftp_network_layer.h"
|
| #include "net/http/http_byte_range.h"
|
| #include "net/http/http_cache.h"
|
| #include "net/http/http_network_layer.h"
|
| @@ -92,7 +92,8 @@
|
| #include "net/url_request/url_request_file_dir_job.h"
|
| #endif
|
|
|
| -#if !defined(DISABLE_FTP_SUPPORT)
|
| +#if !defined(DISABLE_FTP_SUPPORT) && !defined(OS_ANDROID)
|
| +#include "net/ftp/ftp_network_layer.h"
|
| #include "net/url_request/ftp_protocol_handler.h"
|
| #endif
|
|
|
| @@ -114,6 +115,14 @@ const base::string16 kChrome(ASCIIToUTF16("chrome"));
|
| const base::string16 kSecret(ASCIIToUTF16("secret"));
|
| const base::string16 kUser(ASCIIToUTF16("user"));
|
|
|
| +const base::FilePath::CharType kTestFilePath[] =
|
| + FILE_PATH_LITERAL("net/data/url_request_unittest");
|
| +
|
| +#if !defined(DISABLE_FTP_SUPPORT) && !defined(OS_ANDROID)
|
| +// Test file used in most FTP tests.
|
| +const char kFtpTestFile[] = "BullRunSpeech.txt";
|
| +#endif
|
| +
|
| // Tests load timing information in the case a fresh connection was used, with
|
| // no proxy.
|
| void TestLoadTimingNotReused(const LoadTimingInfo& load_timing_info,
|
| @@ -223,7 +232,7 @@ void TestLoadTimingCacheHitNoNetwork(
|
| EXPECT_TRUE(load_timing_info.proxy_resolve_end.is_null());
|
| }
|
|
|
| -#if !defined(DISABLE_FTP_SUPPORT)
|
| +#if !defined(DISABLE_FTP_SUPPORT) && !defined(OS_ANDROID)
|
| // Tests load timing in the case that there is no HTTP response. This can be
|
| // used to test in the case of errors or non-HTTP requests.
|
| void TestLoadTimingNoHttpResponse(
|
| @@ -974,9 +983,7 @@ TEST_F(URLRequestTest, FileDirOutputSanity) {
|
|
|
| base::FilePath path;
|
| PathService::Get(base::DIR_SOURCE_ROOT, &path);
|
| - path = path.Append(FILE_PATH_LITERAL("net"));
|
| - path = path.Append(FILE_PATH_LITERAL("data"));
|
| - path = path.Append(FILE_PATH_LITERAL("url_request_unittest"));
|
| + path = path.Append(kTestFilePath);
|
|
|
| TestDelegate d;
|
| scoped_ptr<URLRequest> req(default_context_.CreateRequest(
|
| @@ -1011,9 +1018,7 @@ TEST_F(URLRequestTest, FileDirRedirectNoCrash) {
|
|
|
| base::FilePath path;
|
| PathService::Get(base::DIR_SOURCE_ROOT, &path);
|
| - path = path.Append(FILE_PATH_LITERAL("net"));
|
| - path = path.Append(FILE_PATH_LITERAL("data"));
|
| - path = path.Append(FILE_PATH_LITERAL("url_request_unittest"));
|
| + path = path.Append(kTestFilePath);
|
|
|
| TestDelegate d;
|
| scoped_ptr<URLRequest> req(default_context_.CreateRequest(
|
| @@ -1076,9 +1081,7 @@ TEST_F(URLRequestTest, InvalidReferrerTest) {
|
| TEST_F(URLRequestTest, ResolveShortcutTest) {
|
| base::FilePath app_path;
|
| PathService::Get(base::DIR_SOURCE_ROOT, &app_path);
|
| - app_path = app_path.AppendASCII("net");
|
| - app_path = app_path.AppendASCII("data");
|
| - app_path = app_path.AppendASCII("url_request_unittest");
|
| + app_path = app_path.Append(kTestFilePath);
|
| app_path = app_path.AppendASCII("with-headers.html");
|
|
|
| std::wstring lnk_path = app_path.value() + L".lnk";
|
| @@ -2819,10 +2822,7 @@ TEST_F(URLRequestTest, DoNotOverrideReferrer) {
|
|
|
| class URLRequestTestHTTP : public URLRequestTest {
|
| public:
|
| - URLRequestTestHTTP()
|
| - : test_server_(base::FilePath(FILE_PATH_LITERAL(
|
| - "net/data/url_request_unittest"))) {
|
| - }
|
| + URLRequestTestHTTP() : test_server_(base::FilePath(kTestFilePath)) {}
|
|
|
| protected:
|
| // Requests |redirect_url|, which must return a HTTP 3xx redirect.
|
| @@ -5161,9 +5161,7 @@ TEST_F(URLRequestTestHTTP, PostFileTest) {
|
|
|
| base::FilePath path;
|
| PathService::Get(base::DIR_SOURCE_ROOT, &path);
|
| - path = path.Append(FILE_PATH_LITERAL("net"));
|
| - path = path.Append(FILE_PATH_LITERAL("data"));
|
| - path = path.Append(FILE_PATH_LITERAL("url_request_unittest"));
|
| + path = path.Append(kTestFilePath);
|
| path = path.Append(FILE_PATH_LITERAL("with-headers.html"));
|
| element_readers.push_back(
|
| new UploadFileElementReader(base::MessageLoopProxy::current().get(),
|
| @@ -5321,10 +5319,9 @@ TEST_F(URLRequestTestHTTP, ResponseHeadersTest) {
|
| TEST_F(URLRequestTestHTTP, ProcessSTS) {
|
| SpawnedTestServer::SSLOptions ssl_options(
|
| SpawnedTestServer::SSLOptions::CERT_COMMON_NAME_IS_DOMAIN);
|
| - SpawnedTestServer https_test_server(
|
| - SpawnedTestServer::TYPE_HTTPS,
|
| - ssl_options,
|
| - base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest")));
|
| + SpawnedTestServer https_test_server(SpawnedTestServer::TYPE_HTTPS,
|
| + ssl_options,
|
| + base::FilePath(kTestFilePath));
|
| ASSERT_TRUE(https_test_server.Start());
|
|
|
| std::string test_server_hostname = https_test_server.GetURL("").host();
|
| @@ -5353,9 +5350,9 @@ TEST_F(URLRequestTestHTTP, ProcessSTS) {
|
| }
|
|
|
| TEST_F(URLRequestTestHTTP, STSNotProcessedOnIP) {
|
| - SpawnedTestServer https_test_server(
|
| - SpawnedTestServer::TYPE_HTTPS, SpawnedTestServer::SSLOptions(),
|
| - base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest")));
|
| + SpawnedTestServer https_test_server(SpawnedTestServer::TYPE_HTTPS,
|
| + SpawnedTestServer::SSLOptions(),
|
| + base::FilePath(kTestFilePath));
|
| ASSERT_TRUE(https_test_server.Start());
|
| // Make sure this test fails if the test server is changed to not
|
| // listen on an IP by default.
|
| @@ -5390,10 +5387,9 @@ TEST_F(URLRequestTestHTTP, STSNotProcessedOnIP) {
|
| TEST_F(URLRequestTestHTTP, MAYBE_ProcessPKP) {
|
| SpawnedTestServer::SSLOptions ssl_options(
|
| SpawnedTestServer::SSLOptions::CERT_COMMON_NAME_IS_DOMAIN);
|
| - SpawnedTestServer https_test_server(
|
| - SpawnedTestServer::TYPE_HTTPS,
|
| - ssl_options,
|
| - base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest")));
|
| + SpawnedTestServer https_test_server(SpawnedTestServer::TYPE_HTTPS,
|
| + ssl_options,
|
| + base::FilePath(kTestFilePath));
|
| ASSERT_TRUE(https_test_server.Start());
|
|
|
| std::string test_server_hostname = https_test_server.GetURL("").host();
|
| @@ -5419,9 +5415,9 @@ TEST_F(URLRequestTestHTTP, MAYBE_ProcessPKP) {
|
| }
|
|
|
| TEST_F(URLRequestTestHTTP, PKPNotProcessedOnIP) {
|
| - SpawnedTestServer https_test_server(
|
| - SpawnedTestServer::TYPE_HTTPS, SpawnedTestServer::SSLOptions(),
|
| - base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest")));
|
| + SpawnedTestServer https_test_server(SpawnedTestServer::TYPE_HTTPS,
|
| + SpawnedTestServer::SSLOptions(),
|
| + base::FilePath(kTestFilePath));
|
| ASSERT_TRUE(https_test_server.Start());
|
| // Make sure this test fails if the test server is changed to not
|
| // listen on an IP by default.
|
| @@ -5445,10 +5441,9 @@ TEST_F(URLRequestTestHTTP, PKPNotProcessedOnIP) {
|
| TEST_F(URLRequestTestHTTP, ProcessSTSOnce) {
|
| SpawnedTestServer::SSLOptions ssl_options(
|
| SpawnedTestServer::SSLOptions::CERT_COMMON_NAME_IS_DOMAIN);
|
| - SpawnedTestServer https_test_server(
|
| - SpawnedTestServer::TYPE_HTTPS,
|
| - ssl_options,
|
| - base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest")));
|
| + SpawnedTestServer https_test_server(SpawnedTestServer::TYPE_HTTPS,
|
| + ssl_options,
|
| + base::FilePath(kTestFilePath));
|
| ASSERT_TRUE(https_test_server.Start());
|
|
|
| std::string test_server_hostname = https_test_server.GetURL("").host();
|
| @@ -5475,10 +5470,9 @@ TEST_F(URLRequestTestHTTP, ProcessSTSOnce) {
|
| TEST_F(URLRequestTestHTTP, ProcessSTSAndPKP) {
|
| SpawnedTestServer::SSLOptions ssl_options(
|
| SpawnedTestServer::SSLOptions::CERT_COMMON_NAME_IS_DOMAIN);
|
| - SpawnedTestServer https_test_server(
|
| - SpawnedTestServer::TYPE_HTTPS,
|
| - ssl_options,
|
| - base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest")));
|
| + SpawnedTestServer https_test_server(SpawnedTestServer::TYPE_HTTPS,
|
| + ssl_options,
|
| + base::FilePath(kTestFilePath));
|
| ASSERT_TRUE(https_test_server.Start());
|
|
|
| std::string test_server_hostname = https_test_server.GetURL("").host();
|
| @@ -5517,10 +5511,9 @@ TEST_F(URLRequestTestHTTP, ProcessSTSAndPKP) {
|
| TEST_F(URLRequestTestHTTP, ProcessSTSAndPKP2) {
|
| SpawnedTestServer::SSLOptions ssl_options(
|
| SpawnedTestServer::SSLOptions::CERT_COMMON_NAME_IS_DOMAIN);
|
| - SpawnedTestServer https_test_server(
|
| - SpawnedTestServer::TYPE_HTTPS,
|
| - ssl_options,
|
| - base::FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest")));
|
| + SpawnedTestServer https_test_server(SpawnedTestServer::TYPE_HTTPS,
|
| + ssl_options,
|
| + base::FilePath(kTestFilePath));
|
| ASSERT_TRUE(https_test_server.Start());
|
|
|
| std::string test_server_hostname = https_test_server.GetURL("").host();
|
| @@ -6041,9 +6034,7 @@ TEST_F(URLRequestTestHTTP, DeferredRedirect) {
|
|
|
| base::FilePath path;
|
| PathService::Get(base::DIR_SOURCE_ROOT, &path);
|
| - path = path.Append(FILE_PATH_LITERAL("net"));
|
| - path = path.Append(FILE_PATH_LITERAL("data"));
|
| - path = path.Append(FILE_PATH_LITERAL("url_request_unittest"));
|
| + path = path.Append(kTestFilePath);
|
| path = path.Append(FILE_PATH_LITERAL("with-headers.html"));
|
|
|
| std::string contents;
|
| @@ -6084,9 +6075,7 @@ TEST_F(URLRequestTestHTTP, DeferredRedirect_GetFullRequestHeaders) {
|
|
|
| base::FilePath path;
|
| PathService::Get(base::DIR_SOURCE_ROOT, &path);
|
| - path = path.Append(FILE_PATH_LITERAL("net"));
|
| - path = path.Append(FILE_PATH_LITERAL("data"));
|
| - path = path.Append(FILE_PATH_LITERAL("url_request_unittest"));
|
| + path = path.Append(kTestFilePath);
|
| path = path.Append(FILE_PATH_LITERAL("with-headers.html"));
|
|
|
| std::string contents;
|
| @@ -7057,8 +7046,7 @@ class URLRequestTestReferrerPolicy : public URLRequestTest {
|
| origin_type, SpawnedTestServer::kLocalhost,
|
| origin_type == SpawnedTestServer::TYPE_HTTPS
|
| ? base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))
|
| - : base::FilePath(
|
| - FILE_PATH_LITERAL("net/data/url_request_unittest"))));
|
| + : base::FilePath(kTestFilePath)));
|
| ASSERT_TRUE(origin_server_->Start());
|
| }
|
|
|
| @@ -7068,16 +7056,14 @@ class URLRequestTestReferrerPolicy : public URLRequestTest {
|
| origin_type, SpawnedTestServer::kLocalhost,
|
| origin_type == SpawnedTestServer::TYPE_HTTPS
|
| ? base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))
|
| - : base::FilePath(
|
| - FILE_PATH_LITERAL("net/data/url_request_unittest"))));
|
| + : base::FilePath(kTestFilePath)));
|
| ASSERT_TRUE(origin_server_->Start());
|
|
|
| destination_server_.reset(new SpawnedTestServer(
|
| destination_type, SpawnedTestServer::kLocalhost,
|
| destination_type == SpawnedTestServer::TYPE_HTTPS
|
| ? base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))
|
| - : base::FilePath(
|
| - FILE_PATH_LITERAL("net/data/url_request_unittest"))));
|
| + : base::FilePath(kTestFilePath)));
|
| ASSERT_TRUE(destination_server_->Start());
|
| }
|
|
|
| @@ -8848,30 +8834,49 @@ TEST_F(HTTPSCRLSetTest, CRLSetRevoked) {
|
| }
|
| #endif // !defined(OS_IOS)
|
|
|
| -#if !defined(DISABLE_FTP_SUPPORT)
|
| +#if !defined(DISABLE_FTP_SUPPORT) && !defined(OS_ANDROID)
|
| +// These tests aren't passing on Android. Either the RemoteTestServer isn't
|
| +// starting up successfully, or it can't access the test files.
|
| +// TODO(mmenke): Fix this. See http://crbug.com/495220
|
| class URLRequestTestFTP : public URLRequestTest {
|
| public:
|
| URLRequestTestFTP()
|
| - : test_server_(SpawnedTestServer::TYPE_FTP, SpawnedTestServer::kLocalhost,
|
| - base::FilePath()) {
|
| + : ftp_transaction_factory_(&host_resolver_),
|
| + test_server_(SpawnedTestServer::TYPE_FTP,
|
| + SpawnedTestServer::kLocalhost,
|
| + base::FilePath(kTestFilePath)) {
|
| + // Can't use |default_context_|'s HostResolver to set up the
|
| + // FTPTransactionFactory because it hasn't been created yet.
|
| + default_context_.set_host_resolver(&host_resolver_);
|
| + }
|
| +
|
| + // URLRequestTest interface:
|
| + void SetUpFactory() override {
|
| + // Add FTP support to the default URLRequestContext.
|
| + job_factory_impl_->SetProtocolHandler(
|
| + "ftp", new FtpProtocolHandler(&ftp_transaction_factory_));
|
| + }
|
| +
|
| + std::string GetTestFileContents() {
|
| + base::FilePath path;
|
| + EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &path));
|
| + path = path.Append(kTestFilePath);
|
| + path = path.AppendASCII(kFtpTestFile);
|
| + std::string contents;
|
| + EXPECT_TRUE(base::ReadFileToString(path, &contents));
|
| + return contents;
|
| }
|
|
|
| protected:
|
| + MockHostResolver host_resolver_;
|
| + FtpNetworkLayer ftp_transaction_factory_;
|
| +
|
| SpawnedTestServer test_server_;
|
| };
|
|
|
| // Make sure an FTP request using an unsafe ports fails.
|
| TEST_F(URLRequestTestFTP, UnsafePort) {
|
| - ASSERT_TRUE(test_server_.Start());
|
| -
|
| - URLRequestJobFactoryImpl job_factory;
|
| - FtpNetworkLayer ftp_transaction_factory(default_context_.host_resolver());
|
| -
|
| GURL url("ftp://127.0.0.1:7");
|
| - job_factory.SetProtocolHandler(
|
| - "ftp",
|
| - new FtpProtocolHandler(&ftp_transaction_factory));
|
| - default_context_.set_job_factory(&job_factory);
|
|
|
| TestDelegate d;
|
| {
|
| @@ -8888,8 +8893,7 @@ TEST_F(URLRequestTestFTP, UnsafePort) {
|
| }
|
| }
|
|
|
| -// Flaky, see http://crbug.com/25045.
|
| -TEST_F(URLRequestTestFTP, DISABLED_FTPDirectoryListing) {
|
| +TEST_F(URLRequestTestFTP, FTPDirectoryListing) {
|
| ASSERT_TRUE(test_server_.Start());
|
|
|
| TestDelegate d;
|
| @@ -8912,29 +8916,22 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPDirectoryListing) {
|
| }
|
| }
|
|
|
| -// Flaky, see http://crbug.com/25045.
|
| -TEST_F(URLRequestTestFTP, DISABLED_FTPGetTestAnonymous) {
|
| +TEST_F(URLRequestTestFTP, FTPGetTestAnonymous) {
|
| ASSERT_TRUE(test_server_.Start());
|
|
|
| - base::FilePath app_path;
|
| - PathService::Get(base::DIR_SOURCE_ROOT, &app_path);
|
| - app_path = app_path.AppendASCII("LICENSE");
|
| TestDelegate d;
|
| {
|
| scoped_ptr<URLRequest> r(default_context_.CreateRequest(
|
| - test_server_.GetURL("/LICENSE"), DEFAULT_PRIORITY, &d));
|
| + test_server_.GetURL(kFtpTestFile), DEFAULT_PRIORITY, &d));
|
| r->Start();
|
| EXPECT_TRUE(r->is_pending());
|
|
|
| base::RunLoop().Run();
|
|
|
| - int64 file_size = 0;
|
| - base::GetFileSize(app_path, &file_size);
|
| -
|
| EXPECT_FALSE(r->is_pending());
|
| EXPECT_EQ(1, d.response_started_count());
|
| EXPECT_FALSE(d.received_data_before_response());
|
| - EXPECT_EQ(d.bytes_received(), static_cast<int>(file_size));
|
| + EXPECT_EQ(GetTestFileContents(), d.data_received());
|
| EXPECT_EQ(test_server_.host_port_pair().host(),
|
| r->GetSocketAddress().host());
|
| EXPECT_EQ(test_server_.host_port_pair().port(),
|
| @@ -8942,34 +8939,28 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPGetTestAnonymous) {
|
| }
|
| }
|
|
|
| -// Flaky, see http://crbug.com/25045.
|
| -TEST_F(URLRequestTestFTP, DISABLED_FTPGetTest) {
|
| +TEST_F(URLRequestTestFTP, FTPGetTest) {
|
| ASSERT_TRUE(test_server_.Start());
|
|
|
| - base::FilePath app_path;
|
| - PathService::Get(base::DIR_SOURCE_ROOT, &app_path);
|
| - app_path = app_path.AppendASCII("LICENSE");
|
| TestDelegate d;
|
| {
|
| - scoped_ptr<URLRequest> r(default_context_.CreateRequest(
|
| - test_server_.GetURLWithUserAndPassword("/LICENSE", "chrome", "chrome"),
|
| - DEFAULT_PRIORITY, &d));
|
| + scoped_ptr<URLRequest> r(
|
| + default_context_.CreateRequest(test_server_.GetURLWithUserAndPassword(
|
| + kFtpTestFile, "chrome", "chrome"),
|
| + DEFAULT_PRIORITY, &d));
|
| r->Start();
|
| EXPECT_TRUE(r->is_pending());
|
|
|
| base::RunLoop().Run();
|
|
|
| - int64 file_size = 0;
|
| - base::GetFileSize(app_path, &file_size);
|
| -
|
| EXPECT_FALSE(r->is_pending());
|
| + EXPECT_EQ(1, d.response_started_count());
|
| + EXPECT_FALSE(d.received_data_before_response());
|
| + EXPECT_EQ(GetTestFileContents(), d.data_received());
|
| EXPECT_EQ(test_server_.host_port_pair().host(),
|
| r->GetSocketAddress().host());
|
| EXPECT_EQ(test_server_.host_port_pair().port(),
|
| r->GetSocketAddress().port());
|
| - EXPECT_EQ(1, d.response_started_count());
|
| - EXPECT_FALSE(d.received_data_before_response());
|
| - EXPECT_EQ(d.bytes_received(), static_cast<int>(file_size));
|
|
|
| LoadTimingInfo load_timing_info;
|
| r->GetLoadTimingInfo(&load_timing_info);
|
| @@ -8977,17 +8968,13 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPGetTest) {
|
| }
|
| }
|
|
|
| -// Flaky, see http://crbug.com/25045.
|
| -TEST_F(URLRequestTestFTP, DISABLED_FTPCheckWrongPassword) {
|
| +TEST_F(URLRequestTestFTP, FTPCheckWrongPassword) {
|
| ASSERT_TRUE(test_server_.Start());
|
|
|
| - base::FilePath app_path;
|
| - PathService::Get(base::DIR_SOURCE_ROOT, &app_path);
|
| - app_path = app_path.AppendASCII("LICENSE");
|
| TestDelegate d;
|
| {
|
| scoped_ptr<URLRequest> r(default_context_.CreateRequest(
|
| - test_server_.GetURLWithUserAndPassword("/LICENSE", "chrome",
|
| + test_server_.GetURLWithUserAndPassword(kFtpTestFile, "chrome",
|
| "wrong_password"),
|
| DEFAULT_PRIORITY, &d));
|
| r->Start();
|
| @@ -8995,9 +8982,6 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPCheckWrongPassword) {
|
|
|
| base::RunLoop().Run();
|
|
|
| - int64 file_size = 0;
|
| - base::GetFileSize(app_path, &file_size);
|
| -
|
| EXPECT_FALSE(r->is_pending());
|
| EXPECT_EQ(1, d.response_started_count());
|
| EXPECT_FALSE(d.received_data_before_response());
|
| @@ -9005,20 +8989,16 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPCheckWrongPassword) {
|
| }
|
| }
|
|
|
| -// Flaky, see http://crbug.com/25045.
|
| -TEST_F(URLRequestTestFTP, DISABLED_FTPCheckWrongPasswordRestart) {
|
| +TEST_F(URLRequestTestFTP, FTPCheckWrongPasswordRestart) {
|
| ASSERT_TRUE(test_server_.Start());
|
|
|
| - base::FilePath app_path;
|
| - PathService::Get(base::DIR_SOURCE_ROOT, &app_path);
|
| - app_path = app_path.AppendASCII("LICENSE");
|
| TestDelegate d;
|
| // Set correct login credentials. The delegate will be asked for them when
|
| // the initial login with wrong credentials will fail.
|
| d.set_credentials(AuthCredentials(kChrome, kChrome));
|
| {
|
| scoped_ptr<URLRequest> r(default_context_.CreateRequest(
|
| - test_server_.GetURLWithUserAndPassword("/LICENSE", "chrome",
|
| + test_server_.GetURLWithUserAndPassword(kFtpTestFile, "chrome",
|
| "wrong_password"),
|
| DEFAULT_PRIORITY, &d));
|
| r->Start();
|
| @@ -9026,138 +9006,106 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPCheckWrongPasswordRestart) {
|
|
|
| base::RunLoop().Run();
|
|
|
| - int64 file_size = 0;
|
| - base::GetFileSize(app_path, &file_size);
|
| -
|
| EXPECT_FALSE(r->is_pending());
|
| EXPECT_EQ(1, d.response_started_count());
|
| EXPECT_FALSE(d.received_data_before_response());
|
| - EXPECT_EQ(d.bytes_received(), static_cast<int>(file_size));
|
| + EXPECT_EQ(GetTestFileContents(), d.data_received());
|
| }
|
| }
|
|
|
| -// Flaky, see http://crbug.com/25045.
|
| -TEST_F(URLRequestTestFTP, DISABLED_FTPCheckWrongUser) {
|
| +TEST_F(URLRequestTestFTP, FTPCheckWrongUser) {
|
| ASSERT_TRUE(test_server_.Start());
|
|
|
| - base::FilePath app_path;
|
| - PathService::Get(base::DIR_SOURCE_ROOT, &app_path);
|
| - app_path = app_path.AppendASCII("LICENSE");
|
| TestDelegate d;
|
| {
|
| - scoped_ptr<URLRequest> r(
|
| - default_context_.CreateRequest(test_server_.GetURLWithUserAndPassword(
|
| - "/LICENSE", "wrong_user", "chrome"),
|
| - DEFAULT_PRIORITY, &d));
|
| + scoped_ptr<URLRequest> r(default_context_.CreateRequest(
|
| + test_server_.GetURLWithUserAndPassword(kFtpTestFile, "wrong_user",
|
| + "chrome"),
|
| + DEFAULT_PRIORITY, &d));
|
| r->Start();
|
| EXPECT_TRUE(r->is_pending());
|
|
|
| base::RunLoop().Run();
|
|
|
| - int64 file_size = 0;
|
| - base::GetFileSize(app_path, &file_size);
|
| -
|
| EXPECT_FALSE(r->is_pending());
|
| EXPECT_EQ(1, d.response_started_count());
|
| EXPECT_FALSE(d.received_data_before_response());
|
| - EXPECT_EQ(d.bytes_received(), 0);
|
| + EXPECT_EQ(0, d.bytes_received());
|
| }
|
| }
|
|
|
| -// Flaky, see http://crbug.com/25045.
|
| -TEST_F(URLRequestTestFTP, DISABLED_FTPCheckWrongUserRestart) {
|
| +TEST_F(URLRequestTestFTP, FTPCheckWrongUserRestart) {
|
| ASSERT_TRUE(test_server_.Start());
|
|
|
| - base::FilePath app_path;
|
| - PathService::Get(base::DIR_SOURCE_ROOT, &app_path);
|
| - app_path = app_path.AppendASCII("LICENSE");
|
| TestDelegate d;
|
| // Set correct login credentials. The delegate will be asked for them when
|
| // the initial login with wrong credentials will fail.
|
| d.set_credentials(AuthCredentials(kChrome, kChrome));
|
| {
|
| - scoped_ptr<URLRequest> r(
|
| - default_context_.CreateRequest(test_server_.GetURLWithUserAndPassword(
|
| - "/LICENSE", "wrong_user", "chrome"),
|
| - DEFAULT_PRIORITY, &d));
|
| + scoped_ptr<URLRequest> r(default_context_.CreateRequest(
|
| + test_server_.GetURLWithUserAndPassword(kFtpTestFile, "wrong_user",
|
| + "chrome"),
|
| + DEFAULT_PRIORITY, &d));
|
| r->Start();
|
| EXPECT_TRUE(r->is_pending());
|
|
|
| base::RunLoop().Run();
|
|
|
| - int64 file_size = 0;
|
| - base::GetFileSize(app_path, &file_size);
|
| -
|
| EXPECT_FALSE(r->is_pending());
|
| EXPECT_EQ(1, d.response_started_count());
|
| EXPECT_FALSE(d.received_data_before_response());
|
| - EXPECT_EQ(d.bytes_received(), static_cast<int>(file_size));
|
| + EXPECT_EQ(GetTestFileContents(), d.data_received());
|
| }
|
| }
|
|
|
| -// Flaky, see http://crbug.com/25045.
|
| -TEST_F(URLRequestTestFTP, DISABLED_FTPCacheURLCredentials) {
|
| +TEST_F(URLRequestTestFTP, FTPCacheURLCredentials) {
|
| ASSERT_TRUE(test_server_.Start());
|
|
|
| - base::FilePath app_path;
|
| - PathService::Get(base::DIR_SOURCE_ROOT, &app_path);
|
| - app_path = app_path.AppendASCII("LICENSE");
|
| -
|
| scoped_ptr<TestDelegate> d(new TestDelegate);
|
| {
|
| // Pass correct login identity in the URL.
|
| - scoped_ptr<URLRequest> r(default_context_.CreateRequest(
|
| - test_server_.GetURLWithUserAndPassword("/LICENSE", "chrome", "chrome"),
|
| - DEFAULT_PRIORITY, d.get()));
|
| + scoped_ptr<URLRequest> r(
|
| + default_context_.CreateRequest(test_server_.GetURLWithUserAndPassword(
|
| + kFtpTestFile, "chrome", "chrome"),
|
| + DEFAULT_PRIORITY, d.get()));
|
| r->Start();
|
| EXPECT_TRUE(r->is_pending());
|
|
|
| base::RunLoop().Run();
|
|
|
| - int64 file_size = 0;
|
| - base::GetFileSize(app_path, &file_size);
|
| -
|
| EXPECT_FALSE(r->is_pending());
|
| EXPECT_EQ(1, d->response_started_count());
|
| EXPECT_FALSE(d->received_data_before_response());
|
| - EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size));
|
| + EXPECT_EQ(GetTestFileContents(), d->data_received());
|
| }
|
|
|
| d.reset(new TestDelegate);
|
| {
|
| // This request should use cached identity from previous request.
|
| scoped_ptr<URLRequest> r(default_context_.CreateRequest(
|
| - test_server_.GetURL("/LICENSE"), DEFAULT_PRIORITY, d.get()));
|
| + test_server_.GetURL(kFtpTestFile), DEFAULT_PRIORITY, d.get()));
|
| r->Start();
|
| EXPECT_TRUE(r->is_pending());
|
|
|
| base::RunLoop().Run();
|
|
|
| - int64 file_size = 0;
|
| - base::GetFileSize(app_path, &file_size);
|
| -
|
| EXPECT_FALSE(r->is_pending());
|
| EXPECT_EQ(1, d->response_started_count());
|
| EXPECT_FALSE(d->received_data_before_response());
|
| - EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size));
|
| + EXPECT_EQ(GetTestFileContents(), d->data_received());
|
| }
|
| }
|
|
|
| -// Flaky, see http://crbug.com/25045.
|
| -TEST_F(URLRequestTestFTP, DISABLED_FTPCacheLoginBoxCredentials) {
|
| +TEST_F(URLRequestTestFTP, FTPCacheLoginBoxCredentials) {
|
| ASSERT_TRUE(test_server_.Start());
|
|
|
| - base::FilePath app_path;
|
| - PathService::Get(base::DIR_SOURCE_ROOT, &app_path);
|
| - app_path = app_path.AppendASCII("LICENSE");
|
| -
|
| scoped_ptr<TestDelegate> d(new TestDelegate);
|
| // Set correct login credentials. The delegate will be asked for them when
|
| // the initial login with wrong credentials will fail.
|
| d->set_credentials(AuthCredentials(kChrome, kChrome));
|
| {
|
| scoped_ptr<URLRequest> r(default_context_.CreateRequest(
|
| - test_server_.GetURLWithUserAndPassword("/LICENSE", "chrome",
|
| + test_server_.GetURLWithUserAndPassword(kFtpTestFile, "chrome",
|
| "wrong_password"),
|
| DEFAULT_PRIORITY, d.get()));
|
| r->Start();
|
| @@ -9165,13 +9113,10 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPCacheLoginBoxCredentials) {
|
|
|
| base::RunLoop().Run();
|
|
|
| - int64 file_size = 0;
|
| - base::GetFileSize(app_path, &file_size);
|
| -
|
| EXPECT_FALSE(r->is_pending());
|
| EXPECT_EQ(1, d->response_started_count());
|
| EXPECT_FALSE(d->received_data_before_response());
|
| - EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size));
|
| + EXPECT_EQ(GetTestFileContents(), d->data_received());
|
| }
|
|
|
| // Use a new delegate without explicit credentials. The cached ones should be
|
| @@ -9181,19 +9126,16 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPCacheLoginBoxCredentials) {
|
| // Don't pass wrong credentials in the URL, they would override valid cached
|
| // ones.
|
| scoped_ptr<URLRequest> r(default_context_.CreateRequest(
|
| - test_server_.GetURL("/LICENSE"), DEFAULT_PRIORITY, d.get()));
|
| + test_server_.GetURL(kFtpTestFile), DEFAULT_PRIORITY, d.get()));
|
| r->Start();
|
| EXPECT_TRUE(r->is_pending());
|
|
|
| base::RunLoop().Run();
|
|
|
| - int64 file_size = 0;
|
| - base::GetFileSize(app_path, &file_size);
|
| -
|
| EXPECT_FALSE(r->is_pending());
|
| EXPECT_EQ(1, d->response_started_count());
|
| EXPECT_FALSE(d->received_data_before_response());
|
| - EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size));
|
| + EXPECT_EQ(GetTestFileContents(), d->data_received());
|
| }
|
| }
|
| #endif // !defined(DISABLE_FTP_SUPPORT)
|
|
|