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

Unified Diff: net/url_request/url_request_unittest.cc

Issue 20279: Add a unit test for ERR_UNEXPECTED_SERVER_AUTH.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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 | « net/url_request/url_request_http_job.cc ('k') | 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
===================================================================
--- net/url_request/url_request_unittest.cc (revision 9641)
+++ net/url_request/url_request_unittest.cc (working copy)
@@ -84,8 +84,8 @@
TEST_F(URLRequestTest, ProxyTunnelRedirectTest) {
// In this unit test, we're using the HTTPTestServer as a proxy server and
- // issue a CONNECT request with the magic host name "www.redirect.com" to
- // it. The HTTPTestServer will return a 302 response, which we should not
+ // issuing a CONNECT request with the magic host name "www.redirect.com".
+ // The HTTPTestServer will return a 302 response, which we should not
// follow.
scoped_refptr<HTTPTestServer> server =
HTTPTestServer::CreateServer(L"", NULL);
@@ -102,14 +102,39 @@
MessageLoop::current()->Run();
- EXPECT_EQ(1, d.response_started_count());
+ EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
// We should have rewritten the 302 response code as 500.
EXPECT_EQ(500, r.GetResponseCode());
+ EXPECT_EQ(1, d.response_started_count());
// We should not have followed the redirect.
EXPECT_EQ(0, d.received_redirect_count());
}
}
+TEST_F(URLRequestTest, UnexpectedServerAuthTest) {
+ // In this unit test, we're using the HTTPTestServer as a proxy server and
+ // issuing a CONNECT request with the magic host name "www.server-auth.com".
+ // The HTTPTestServer will return a 401 response, which we should balk at.
+ scoped_refptr<HTTPTestServer> server =
+ HTTPTestServer::CreateServer(L"", NULL);
+ ASSERT_TRUE(NULL != server.get());
+ TestDelegate d;
+ {
+ URLRequest r(GURL("https://www.server-auth.com/"), &d);
+ std::string proxy("localhost:");
+ proxy.append(IntToString(kHTTPDefaultPort));
+ r.set_context(new TestURLRequestContext(proxy));
+
+ r.Start();
+ EXPECT_TRUE(r.is_pending());
+
+ MessageLoop::current()->Run();
+
+ EXPECT_EQ(URLRequestStatus::FAILED, r.status().status());
+ EXPECT_EQ(net::ERR_UNEXPECTED_SERVER_AUTH, r.status().os_error());
+ }
+}
+
TEST_F(URLRequestTest, GetTest_NoCache) {
scoped_refptr<HTTPTestServer> server =
HTTPTestServer::CreateServer(L"", NULL);
« no previous file with comments | « net/url_request/url_request_http_job.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698