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 // Make sure an FTP request using an unsafe ports fails. |
| 4117 TEST_F(URLRequestTestFTP, UnsafePort) { |
| 4118 ASSERT_TRUE(test_server_.Start()); |
| 4119 |
| 4120 URLRequestJobFactory job_factory; |
| 4121 |
| 4122 GURL url("ftp://127.0.0.1:7"); |
| 4123 FtpProtocolHandler ftp_protocol_handler( |
| 4124 default_context_.network_delegate(), |
| 4125 default_context_.ftp_transaction_factory(), |
| 4126 default_context_.ftp_auth_cache()); |
| 4127 job_factory.SetProtocolHandler( |
| 4128 "ftp", |
| 4129 new FtpProtocolHandler(default_context_.network_delegate(), |
| 4130 default_context_.ftp_transaction_factory(), |
| 4131 default_context_.ftp_auth_cache())); |
| 4132 default_context_.set_job_factory(&job_factory); |
| 4133 |
| 4134 TestDelegate d; |
| 4135 { |
| 4136 URLRequest r(url, &d, &default_context_); |
| 4137 r.Start(); |
| 4138 EXPECT_TRUE(r.is_pending()); |
| 4139 |
| 4140 MessageLoop::current()->Run(); |
| 4141 |
| 4142 EXPECT_FALSE(r.is_pending()); |
| 4143 EXPECT_EQ(URLRequestStatus::FAILED, r.status().status()); |
| 4144 EXPECT_EQ(ERR_UNSAFE_PORT, r.status().error()); |
| 4145 } |
| 4146 } |
| 4147 |
4115 // Flaky, see http://crbug.com/25045. | 4148 // Flaky, see http://crbug.com/25045. |
4116 TEST_F(URLRequestTestFTP, DISABLED_FTPDirectoryListing) { | 4149 TEST_F(URLRequestTestFTP, DISABLED_FTPDirectoryListing) { |
4117 ASSERT_TRUE(test_server_.Start()); | 4150 ASSERT_TRUE(test_server_.Start()); |
4118 | 4151 |
4119 TestDelegate d; | 4152 TestDelegate d; |
4120 { | 4153 { |
4121 URLRequest r(test_server_.GetURL("/"), &d, &default_context_); | 4154 URLRequest r(test_server_.GetURL("/"), &d, &default_context_); |
4122 r.Start(); | 4155 r.Start(); |
4123 EXPECT_TRUE(r.is_pending()); | 4156 EXPECT_TRUE(r.is_pending()); |
4124 | 4157 |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4599 req.SetExtraRequestHeaders(headers); | 4632 req.SetExtraRequestHeaders(headers); |
4600 req.Start(); | 4633 req.Start(); |
4601 MessageLoop::current()->Run(); | 4634 MessageLoop::current()->Run(); |
4602 // If the net tests are being run with ChromeFrame then we need to allow for | 4635 // 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 | 4636 // the 'chromeframe' suffix which is added to the user agent before the |
4604 // closing parentheses. | 4637 // closing parentheses. |
4605 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); | 4638 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); |
4606 } | 4639 } |
4607 | 4640 |
4608 } // namespace net | 4641 } // namespace net |
OLD | NEW |