Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2197)

Unified Diff: net/url_request/url_request_unittest.cc

Issue 10844004: Regression test for lack of errors on requests with invalid ports (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added documentation to test Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1fdfc1dcf0ef74e53a2b67f64af66873e242e818..0178d37a154ee91cac42241529ece703ef0c3fa9 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -52,6 +52,7 @@
#include "net/proxy/proxy_service.h"
#include "net/socket/ssl_client_socket.h"
#include "net/test/test_server.h"
+#include "net/url_request/ftp_protocol_handler.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_file_dir_job.h"
#include "net/url_request/url_request_http_job.h"
@@ -4112,6 +4113,38 @@ class URLRequestTestFTP : public URLRequestTest {
TestServer test_server_;
};
+// Make sure an FTP request using an unsafe ports fails.
+TEST_F(URLRequestTestFTP, UnsafePort) {
+ ASSERT_TRUE(test_server_.Start());
+
+ URLRequestJobFactory job_factory;
+
+ GURL url("ftp://127.0.0.1:7");
+ FtpProtocolHandler ftp_protocol_handler(
+ default_context_.network_delegate(),
+ default_context_.ftp_transaction_factory(),
+ default_context_.ftp_auth_cache());
+ job_factory.SetProtocolHandler(
+ "ftp",
+ new FtpProtocolHandler(default_context_.network_delegate(),
+ default_context_.ftp_transaction_factory(),
+ default_context_.ftp_auth_cache()));
+ default_context_.set_job_factory(&job_factory);
+
+ TestDelegate d;
+ {
+ URLRequest r(url, &d, &default_context_);
+ r.Start();
+ EXPECT_TRUE(r.is_pending());
+
+ MessageLoop::current()->Run();
+
+ EXPECT_FALSE(r.is_pending());
+ EXPECT_EQ(URLRequestStatus::FAILED, r.status().status());
+ EXPECT_EQ(ERR_UNSAFE_PORT, r.status().error());
+ }
+}
+
// Flaky, see http://crbug.com/25045.
TEST_F(URLRequestTestFTP, DISABLED_FTPDirectoryListing) {
ASSERT_TRUE(test_server_.Start());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698