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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shlobj.h> | 9 #include <shlobj.h> |
| 10 #endif | 10 #endif |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 #include "net/ftp/ftp_network_layer.h" | 45 #include "net/ftp/ftp_network_layer.h" |
| 46 #include "net/http/http_cache.h" | 46 #include "net/http/http_cache.h" |
| 47 #include "net/http/http_network_layer.h" | 47 #include "net/http/http_network_layer.h" |
| 48 #include "net/http/http_network_session.h" | 48 #include "net/http/http_network_session.h" |
| 49 #include "net/http/http_request_headers.h" | 49 #include "net/http/http_request_headers.h" |
| 50 #include "net/http/http_response_headers.h" | 50 #include "net/http/http_response_headers.h" |
| 51 #include "net/ocsp/nss_ocsp.h" | 51 #include "net/ocsp/nss_ocsp.h" |
| 52 #include "net/proxy/proxy_service.h" | 52 #include "net/proxy/proxy_service.h" |
| 53 #include "net/socket/ssl_client_socket.h" | 53 #include "net/socket/ssl_client_socket.h" |
| 54 #include "net/test/test_server.h" | 54 #include "net/test/test_server.h" |
| 55 #include "net/url_request/ftp_protocol_handler.h" | |
| 55 #include "net/url_request/url_request.h" | 56 #include "net/url_request/url_request.h" |
| 56 #include "net/url_request/url_request_file_dir_job.h" | 57 #include "net/url_request/url_request_file_dir_job.h" |
| 57 #include "net/url_request/url_request_http_job.h" | 58 #include "net/url_request/url_request_http_job.h" |
| 58 #include "net/url_request/url_request_job_factory.h" | 59 #include "net/url_request/url_request_job_factory.h" |
| 59 #include "net/url_request/url_request_redirect_job.h" | 60 #include "net/url_request/url_request_redirect_job.h" |
| 60 #include "net/url_request/url_request_test_job.h" | 61 #include "net/url_request/url_request_test_job.h" |
| 61 #include "net/url_request/url_request_test_util.h" | 62 #include "net/url_request/url_request_test_util.h" |
| 62 #include "testing/gtest/include/gtest/gtest.h" | 63 #include "testing/gtest/include/gtest/gtest.h" |
| 63 #include "testing/platform_test.h" | 64 #include "testing/platform_test.h" |
| 64 | 65 |
| (...skipping 4040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4105 class URLRequestTestFTP : public URLRequestTest { | 4106 class URLRequestTestFTP : public URLRequestTest { |
| 4106 public: | 4107 public: |
| 4107 URLRequestTestFTP() | 4108 URLRequestTestFTP() |
| 4108 : test_server_(TestServer::TYPE_FTP, TestServer::kLocalhost, FilePath()) { | 4109 : test_server_(TestServer::TYPE_FTP, TestServer::kLocalhost, FilePath()) { |
| 4109 } | 4110 } |
| 4110 | 4111 |
| 4111 protected: | 4112 protected: |
| 4112 TestServer test_server_; | 4113 TestServer test_server_; |
| 4113 }; | 4114 }; |
| 4114 | 4115 |
| 4116 TEST_F(URLRequestTestFTP, Errors) { | |
|
mmenke
2012/08/03 15:40:54
Think it's best to document even fairly straightfo
mmenke
2012/08/03 15:40:54
Think "UnsafePort" would be a clearer name.
shalev
2012/08/05 07:12:55
Done.
shalev
2012/08/05 07:12:55
Done.
| |
| 4117 ASSERT_TRUE(test_server_.Start()); | |
| 4118 | |
| 4119 URLRequestJobFactory job_factory; | |
| 4120 | |
| 4121 GURL url("ftp://127.0.0.1:7"); | |
| 4122 FtpProtocolHandler ftp_protocol_handler( | |
| 4123 default_context_.network_delegate(), | |
| 4124 default_context_.ftp_transaction_factory(), | |
| 4125 default_context_.ftp_auth_cache()); | |
| 4126 job_factory.SetProtocolHandler( | |
| 4127 "ftp", | |
| 4128 new FtpProtocolHandler(default_context_.network_delegate(), | |
| 4129 default_context_.ftp_transaction_factory(), | |
| 4130 default_context_.ftp_auth_cache())); | |
| 4131 default_context_.set_job_factory(&job_factory); | |
| 4132 | |
| 4133 TestDelegate d; | |
| 4134 { | |
| 4135 URLRequest r(url, &d, &default_context_); | |
| 4136 r.Start(); | |
| 4137 EXPECT_TRUE(r.is_pending()); | |
| 4138 | |
| 4139 MessageLoop::current()->Run(); | |
| 4140 | |
| 4141 EXPECT_FALSE(r.is_pending()); | |
| 4142 EXPECT_EQ(URLRequestStatus::FAILED, r.status().status()); | |
| 4143 EXPECT_EQ(ERR_UNSAFE_PORT, r.status().error()); | |
| 4144 } | |
| 4145 } | |
| 4146 | |
| 4115 // Flaky, see http://crbug.com/25045. | 4147 // Flaky, see http://crbug.com/25045. |
| 4116 TEST_F(URLRequestTestFTP, DISABLED_FTPDirectoryListing) { | 4148 TEST_F(URLRequestTestFTP, DISABLED_FTPDirectoryListing) { |
| 4117 ASSERT_TRUE(test_server_.Start()); | 4149 ASSERT_TRUE(test_server_.Start()); |
| 4118 | 4150 |
| 4119 TestDelegate d; | 4151 TestDelegate d; |
| 4120 { | 4152 { |
| 4121 URLRequest r(test_server_.GetURL("/"), &d, &default_context_); | 4153 URLRequest r(test_server_.GetURL("/"), &d, &default_context_); |
| 4122 r.Start(); | 4154 r.Start(); |
| 4123 EXPECT_TRUE(r.is_pending()); | 4155 EXPECT_TRUE(r.is_pending()); |
| 4124 | 4156 |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4599 req.SetExtraRequestHeaders(headers); | 4631 req.SetExtraRequestHeaders(headers); |
| 4600 req.Start(); | 4632 req.Start(); |
| 4601 MessageLoop::current()->Run(); | 4633 MessageLoop::current()->Run(); |
| 4602 // If the net tests are being run with ChromeFrame then we need to allow for | 4634 // If the net tests are being run with ChromeFrame then we need to allow for |
| 4603 // the 'chromeframe' suffix which is added to the user agent before the | 4635 // the 'chromeframe' suffix which is added to the user agent before the |
| 4604 // closing parentheses. | 4636 // closing parentheses. |
| 4605 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); | 4637 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); |
| 4606 } | 4638 } |
| 4607 | 4639 |
| 4608 } // namespace net | 4640 } // namespace net |
| OLD | NEW |