summaryrefslogtreecommitdiffstats
path: root/net/http/http_network_transaction_unittest.cc
diff options
context:
space:
mode:
authorlevin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-26 02:33:46 +0000
committerlevin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-26 02:33:46 +0000
commit861fcd5d715f0590e75eddfb1bacb0ac356c8026 (patch)
treed16ca24619a70210141952fe0c50859418b5ef45 /net/http/http_network_transaction_unittest.cc
parent9fa24879b1b211336e6da511a8931f62ad6845d7 (diff)
downloadchromium_src-861fcd5d715f0590e75eddfb1bacb0ac356c8026.zip
chromium_src-861fcd5d715f0590e75eddfb1bacb0ac356c8026.tar.gz
chromium_src-861fcd5d715f0590e75eddfb1bacb0ac356c8026.tar.bz2
Add the ability to not send cookies or send user name/password.
Added unit tests for the above functionality plus the do not save cookies functionality. BUG=http://crbug.com/10961 TEST=Added unit tests for this. Also, this isn't yet called from the rest of the code. Review URL: http://codereview.chromium.org/173206 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24412 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_network_transaction_unittest.cc')
-rw-r--r--net/http/http_network_transaction_unittest.cc46
1 files changed, 45 insertions, 1 deletions
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index 9993b1d..d63546d 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -729,6 +729,48 @@ TEST_F(HttpNetworkTransactionTest, BasicAuth) {
EXPECT_EQ(100, response->headers->GetContentLength());
}
+TEST_F(HttpNetworkTransactionTest, DoNotSendAuth) {
+ SessionDependencies session_deps;
+ scoped_ptr<HttpTransaction> trans(
+ new HttpNetworkTransaction(
+ CreateSession(&session_deps),
+ &session_deps.socket_factory));
+
+ HttpRequestInfo request;
+ request.method = "GET";
+ request.url = GURL("http://www.google.com/");
+ request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA;
+
+ MockWrite data_writes[] = {
+ MockWrite("GET / HTTP/1.1\r\n"
+ "Host: www.google.com\r\n"
+ "Connection: keep-alive\r\n\r\n"),
+ };
+
+ MockRead data_reads[] = {
+ MockRead("HTTP/1.0 401 Unauthorized\r\n"),
+ MockRead("WWW-Authenticate: Basic realm=\"MyRealm1\"\r\n"),
+ MockRead("Content-Type: text/html; charset=iso-8859-1\r\n"),
+ // Large content-length -- won't matter, as connection will be reset.
+ MockRead("Content-Length: 10000\r\n\r\n"),
+ MockRead(false, ERR_FAILED),
+ };
+
+ StaticMockSocket data(data_reads, data_writes);
+ session_deps.socket_factory.AddMockSocket(&data);
+ TestCompletionCallback callback;
+
+ int rv = trans->Start(&request, &callback, NULL);
+ EXPECT_EQ(ERR_IO_PENDING, rv);
+
+ rv = callback.WaitForResult();
+ EXPECT_EQ(0, rv);
+
+ const HttpResponseInfo* response = trans->GetResponseInfo();
+ ASSERT_FALSE(response == NULL);
+ EXPECT_TRUE(response->auth_challenge.get() == NULL);
+}
+
// Test the request-challenge-retry sequence for basic auth, over a keep-alive
// connection.
TEST_F(HttpNetworkTransactionTest, BasicAuthKeepAlive) {
@@ -979,7 +1021,9 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthProxyKeepAlive) {
HttpRequestInfo request;
request.method = "GET";
request.url = GURL("https://www.google.com/");
- request.load_flags = 0;
+ // Ensure that proxy authentication is attempted even
+ // when the no authentication data flag is set.
+ request.load_flags = net::LOAD_DO_NOT_SEND_AUTH_DATA;
// Since we have proxy, should try to establish tunnel.
MockWrite data_writes1[] = {