diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-27 04:00:22 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-27 04:00:22 +0000 |
commit | 0757e770ac9ce685ee0db0179271f1a3dba47cb0 (patch) | |
tree | 54e1a153fd38a9f950187929076a1d5d6966357e /net/http/http_network_transaction_unittest.cc | |
parent | 3a2d366b664bb0c13f4427f3ed6a3b6af6e77451 (diff) | |
download | chromium_src-0757e770ac9ce685ee0db0179271f1a3dba47cb0.zip chromium_src-0757e770ac9ce685ee0db0179271f1a3dba47cb0.tar.gz chromium_src-0757e770ac9ce685ee0db0179271f1a3dba47cb0.tar.bz2 |
Respect cookies set in a 401 responses when restarting the http transaction.
There are two parts to this change:
(1) rebuild the request cookies before each transaction restart for
authentication
(2) notify the URLRequestHttpJob of header completion before *each*
transaction restart for authentication
By "each transaction" I mean the automatic restarts that don't require
user input, such as:
- replying to the first step of NTLM
- selecting identity embedded in URL
- selecting identity in auth-cache
Needing to notify URLRequestHttpJob for these intermediate restarts is
a consequence of cookie store management being done outside of
HttpNetworkTransaction.
After updating the cookie store, URLRequestHttpJob now tests
|HttpTransaction::IsReadyToRestartForAuth()| to check whether the
notification was informational or an identity is actually needed.
R=wtc
BUG=6450
Review URL: http://codereview.chromium.org/51004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12635 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/http_network_transaction_unittest.cc')
-rw-r--r-- | net/http/http_network_transaction_unittest.cc | 78 |
1 files changed, 63 insertions, 15 deletions
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc index a9fa974..4e8209c 100644 --- a/net/http/http_network_transaction_unittest.cc +++ b/net/http/http_network_transaction_unittest.cc @@ -1651,7 +1651,7 @@ TEST_F(HttpNetworkTransactionTest, NTLMAuth1) { }; MockWrite data_writes2[] = { - // After automatically restarting with a null identity, this is the + // After restarting with a null identity, this is the // request we should be issuing -- the final header line contains a Type // 1 message. MockWrite("GET /kids/login.aspx HTTP/1.1\r\n" @@ -1715,6 +1715,14 @@ TEST_F(HttpNetworkTransactionTest, NTLMAuth1) { rv = callback1.WaitForResult(); EXPECT_EQ(net::OK, rv); + EXPECT_TRUE(trans->IsReadyToRestartForAuth()); + TestCompletionCallback callback2; + rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); + EXPECT_EQ(net::ERR_IO_PENDING, rv); + rv = callback2.WaitForResult(); + EXPECT_EQ(net::OK, rv); + EXPECT_FALSE(trans->IsReadyToRestartForAuth()); + const net::HttpResponseInfo* response = trans->GetResponseInfo(); EXPECT_FALSE(response == NULL); @@ -1726,12 +1734,12 @@ TEST_F(HttpNetworkTransactionTest, NTLMAuth1) { EXPECT_EQ(L"", response->auth_challenge->realm); EXPECT_EQ(L"ntlm", response->auth_challenge->scheme); - TestCompletionCallback callback2; + TestCompletionCallback callback3; - rv = trans->RestartWithAuth(L"testing-ntlm", L"testing-ntlm", &callback2); + rv = trans->RestartWithAuth(L"testing-ntlm", L"testing-ntlm", &callback3); EXPECT_EQ(net::ERR_IO_PENDING, rv); - rv = callback2.WaitForResult(); + rv = callback3.WaitForResult(); EXPECT_EQ(net::OK, rv); response = trans->GetResponseInfo(); @@ -1773,7 +1781,7 @@ TEST_F(HttpNetworkTransactionTest, NTLMAuth2) { }; MockWrite data_writes2[] = { - // After automatically restarting with a null identity, this is the + // After restarting with a null identity, this is the // request we should be issuing -- the final header line contains a Type // 1 message. MockWrite("GET /kids/login.aspx HTTP/1.1\r\n" @@ -1824,7 +1832,7 @@ TEST_F(HttpNetworkTransactionTest, NTLMAuth2) { }; MockWrite data_writes3[] = { - // After automatically restarting with a null identity, this is the + // After restarting with a null identity, this is the // request we should be issuing -- the final header line contains a Type // 1 message. MockWrite("GET /kids/login.aspx HTTP/1.1\r\n" @@ -1892,6 +1900,14 @@ TEST_F(HttpNetworkTransactionTest, NTLMAuth2) { rv = callback1.WaitForResult(); EXPECT_EQ(net::OK, rv); + EXPECT_TRUE(trans->IsReadyToRestartForAuth()); + TestCompletionCallback callback2; + rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); + EXPECT_EQ(net::ERR_IO_PENDING, rv); + rv = callback2.WaitForResult(); + EXPECT_EQ(net::OK, rv); + EXPECT_FALSE(trans->IsReadyToRestartForAuth()); + const net::HttpResponseInfo* response = trans->GetResponseInfo(); EXPECT_FALSE(response == NULL); @@ -1903,14 +1919,22 @@ TEST_F(HttpNetworkTransactionTest, NTLMAuth2) { EXPECT_EQ(L"", response->auth_challenge->realm); EXPECT_EQ(L"ntlm", response->auth_challenge->scheme); - TestCompletionCallback callback2; + TestCompletionCallback callback3; // Enter the wrong password. - rv = trans->RestartWithAuth(L"testing-ntlm", L"wrongpassword", &callback2); + rv = trans->RestartWithAuth(L"testing-ntlm", L"wrongpassword", &callback3); EXPECT_EQ(net::ERR_IO_PENDING, rv); - rv = callback2.WaitForResult(); + rv = callback3.WaitForResult(); + EXPECT_EQ(net::OK, rv); + + EXPECT_TRUE(trans->IsReadyToRestartForAuth()); + TestCompletionCallback callback4; + rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback4); + EXPECT_EQ(net::ERR_IO_PENDING, rv); + rv = callback4.WaitForResult(); EXPECT_EQ(net::OK, rv); + EXPECT_FALSE(trans->IsReadyToRestartForAuth()); response = trans->GetResponseInfo(); EXPECT_FALSE(response == NULL); @@ -1923,13 +1947,13 @@ TEST_F(HttpNetworkTransactionTest, NTLMAuth2) { EXPECT_EQ(L"", response->auth_challenge->realm); EXPECT_EQ(L"ntlm", response->auth_challenge->scheme); - TestCompletionCallback callback3; + TestCompletionCallback callback5; // Now enter the right password. - rv = trans->RestartWithAuth(L"testing-ntlm", L"testing-ntlm", &callback3); + rv = trans->RestartWithAuth(L"testing-ntlm", L"testing-ntlm", &callback5); EXPECT_EQ(net::ERR_IO_PENDING, rv); - rv = callback3.WaitForResult(); + rv = callback5.WaitForResult(); EXPECT_EQ(net::OK, rv); response = trans->GetResponseInfo(); @@ -2187,6 +2211,14 @@ TEST_F(HttpNetworkTransactionTest, AuthIdentityInUrl) { rv = callback1.WaitForResult(); EXPECT_EQ(net::OK, rv); + EXPECT_TRUE(trans->IsReadyToRestartForAuth()); + TestCompletionCallback callback2; + rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); + EXPECT_EQ(net::ERR_IO_PENDING, rv); + rv = callback2.WaitForResult(); + EXPECT_EQ(net::OK, rv); + EXPECT_FALSE(trans->IsReadyToRestartForAuth()); + const net::HttpResponseInfo* response = trans->GetResponseInfo(); EXPECT_FALSE(response == NULL); @@ -2490,6 +2522,14 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) { rv = callback1.WaitForResult(); EXPECT_EQ(net::OK, rv); + EXPECT_TRUE(trans->IsReadyToRestartForAuth()); + TestCompletionCallback callback2; + rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); + EXPECT_EQ(net::ERR_IO_PENDING, rv); + rv = callback2.WaitForResult(); + EXPECT_EQ(net::OK, rv); + EXPECT_FALSE(trans->IsReadyToRestartForAuth()); + const net::HttpResponseInfo* response = trans->GetResponseInfo(); EXPECT_FALSE(response == NULL); EXPECT_TRUE(response->auth_challenge.get() == NULL); @@ -2577,6 +2617,14 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) { rv = callback1.WaitForResult(); EXPECT_EQ(net::OK, rv); + EXPECT_TRUE(trans->IsReadyToRestartForAuth()); + TestCompletionCallback callback2; + rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); + EXPECT_EQ(net::ERR_IO_PENDING, rv); + rv = callback2.WaitForResult(); + EXPECT_EQ(net::OK, rv); + EXPECT_FALSE(trans->IsReadyToRestartForAuth()); + const net::HttpResponseInfo* response = trans->GetResponseInfo(); EXPECT_FALSE(response == NULL); @@ -2589,12 +2637,12 @@ TEST_F(HttpNetworkTransactionTest, BasicAuthCacheAndPreauth) { EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); EXPECT_EQ(L"basic", response->auth_challenge->scheme); - TestCompletionCallback callback2; + TestCompletionCallback callback3; - rv = trans->RestartWithAuth(L"foo3", L"bar3", &callback2); + rv = trans->RestartWithAuth(L"foo3", L"bar3", &callback3); EXPECT_EQ(net::ERR_IO_PENDING, rv); - rv = callback2.WaitForResult(); + rv = callback3.WaitForResult(); EXPECT_EQ(net::OK, rv); response = trans->GetResponseInfo(); |