summaryrefslogtreecommitdiffstats
path: root/net/url_request/url_request_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'net/url_request/url_request_unittest.cc')
-rw-r--r--net/url_request/url_request_unittest.cc60
1 files changed, 60 insertions, 0 deletions
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index b224c2e..49f01a2 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -1972,6 +1972,36 @@ TEST_F(URLRequestTest, FTPCheckWrongPassword) {
}
}
+TEST_F(URLRequestTest, FTPCheckWrongPasswordRestart) {
+ // Pass wrong login credentials in the request URL.
+ scoped_refptr<FTPTestServer> server =
+ FTPTestServer::CreateServer(L"", "chrome", "wrong_password");
+ ASSERT_TRUE(NULL != server.get());
+ 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_username(L"chrome");
+ d.set_password(L"chrome");
+ {
+ TestURLRequest r(server->TestServerPage("/LICENSE"), &d);
+ r.Start();
+ EXPECT_TRUE(r.is_pending());
+
+ MessageLoop::current()->Run();
+
+ int64 file_size = 0;
+ file_util::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));
+ }
+}
+
TEST_F(URLRequestTest, FTPCheckWrongUser) {
scoped_refptr<FTPTestServer> server =
FTPTestServer::CreateServer(L"", "wrong_user", "chrome");
@@ -1996,3 +2026,33 @@ TEST_F(URLRequestTest, FTPCheckWrongUser) {
EXPECT_EQ(d.bytes_received(), 0);
}
}
+
+TEST_F(URLRequestTest, FTPCheckWrongUserRestart) {
+ // Pass wrong login credentials in the request URL.
+ scoped_refptr<FTPTestServer> server =
+ FTPTestServer::CreateServer(L"", "wrong_user", "chrome");
+ ASSERT_TRUE(NULL != server.get());
+ 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_username(L"chrome");
+ d.set_password(L"chrome");
+ {
+ TestURLRequest r(server->TestServerPage("/LICENSE"), &d);
+ r.Start();
+ EXPECT_TRUE(r.is_pending());
+
+ MessageLoop::current()->Run();
+
+ int64 file_size = 0;
+ file_util::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));
+ }
+}