Index: net/http/http_auth_handler_basic_unittest.cc |
diff --git a/net/http/http_auth_handler_basic_unittest.cc b/net/http/http_auth_handler_basic_unittest.cc |
index 0c2f1297ea1e937eb14b4920b56fe75a64347e51..d2ca310722fbb28ecfbdb98f704053a5bfb542cf 100644 |
--- a/net/http/http_auth_handler_basic_unittest.cc |
+++ b/net/http/http_auth_handler_basic_unittest.cc |
@@ -13,6 +13,7 @@ |
#include "net/http/http_auth_challenge_tokenizer.h" |
#include "net/http/http_auth_handler_basic.h" |
#include "net/http/http_request_info.h" |
+#include "net/http/http_response_info.h" |
#include "testing/gtest/include/gtest/gtest.h" |
namespace net { |
@@ -39,16 +40,19 @@ TEST(HttpAuthHandlerBasicTest, GenerateAuthToken) { |
factory.CreateAuthHandlerForScheme("basic"); |
ASSERT_TRUE(basic); |
HttpAuthChallengeTokenizer tokenizer(challenge.begin(), challenge.end()); |
- EXPECT_EQ(OK, basic->HandleInitialChallenge( |
- tokenizer, HttpAuth::AUTH_SERVER, origin, BoundNetLog())); |
+ HttpResponseInfo response_info; |
+ TestCompletionCallback callback; |
+ int rv = basic->HandleInitialChallenge(tokenizer, response_info, |
+ HttpAuth::AUTH_SERVER, origin, |
+ BoundNetLog(), callback.callback()); |
+ EXPECT_EQ(OK, callback.GetResult(rv)); |
AuthCredentials credentials(base::ASCIIToUTF16(tests[i].username), |
base::ASCIIToUTF16(tests[i].password)); |
HttpRequestInfo request_info; |
std::string auth_token; |
- TestCompletionCallback callback; |
- int rv = basic->GenerateAuthToken(&credentials, request_info, |
- callback.callback(), &auth_token); |
- EXPECT_EQ(OK, rv); |
+ rv = basic->GenerateAuthToken(&credentials, request_info, |
+ callback.callback(), &auth_token); |
+ EXPECT_EQ(OK, callback.GetResult(rv)); |
EXPECT_STREQ(tests[i].expected_credentials, auth_token.c_str()); |
} |
} |
@@ -95,8 +99,12 @@ TEST(HttpAuthHandlerBasicTest, HandleAnotherChallenge) { |
std::string initial_challenge(tests[0].challenge); |
HttpAuthChallengeTokenizer tokenizer(initial_challenge.begin(), |
initial_challenge.end()); |
- EXPECT_EQ(OK, basic->HandleInitialChallenge(tokenizer, HttpAuth::AUTH_SERVER, |
- origin, BoundNetLog())); |
+ HttpResponseInfo response_info; |
+ TestCompletionCallback callback; |
+ int rv = basic->HandleInitialChallenge(tokenizer, response_info, |
+ HttpAuth::AUTH_SERVER, origin, |
+ BoundNetLog(), callback.callback()); |
+ EXPECT_EQ(OK, callback.GetResult(rv)); |
for (size_t i = 0; i < arraysize(tests); ++i) { |
std::string challenge(tests[i].challenge); |
@@ -189,9 +197,12 @@ TEST(HttpAuthHandlerBasicTest, HandleInitialChallenge) { |
scoped_ptr<HttpAuthHandler> basic = |
factory.CreateAuthHandlerForScheme("basic"); |
HttpAuthChallengeTokenizer tokenizer(challenge.begin(), challenge.end()); |
- int rv = basic->HandleInitialChallenge(tokenizer, HttpAuth::AUTH_SERVER, |
- origin, BoundNetLog()); |
- EXPECT_EQ(tests[i].expected_rv, rv); |
+ HttpResponseInfo response_info; |
+ TestCompletionCallback callback; |
+ int rv = basic->HandleInitialChallenge(tokenizer, response_info, |
+ HttpAuth::AUTH_SERVER, origin, |
+ BoundNetLog(), callback.callback()); |
+ EXPECT_EQ(tests[i].expected_rv, callback.GetResult(rv)); |
if (rv == OK) |
EXPECT_EQ(tests[i].expected_realm, basic->realm()); |
} |
@@ -208,26 +219,24 @@ TEST(HttpAuthHandlerBasicTest, CreateAndInitPreemptiveAuthHandler_Valid) { |
HttpAuthHandlerBasic::Factory digest_factory; |
HttpAuthCache auth_cache; |
std::string challenge("basic realm=\"Foo\""); |
- HttpAuthChallengeTokenizer tokenizer(challenge.begin(), challenge.end()); |
HttpAuthCache::Entry* entry = |
auth_cache.Add(GURL("http://example.com/foo").GetOrigin(), "foo", "basic", |
challenge, AuthCredentials(), "/foo"); |
EXPECT_TRUE(digest_factory.CreateAndInitPreemptiveAuthHandler( |
- entry, tokenizer, HttpAuth::AUTH_SERVER, BoundNetLog())); |
+ entry, HttpAuth::AUTH_SERVER, BoundNetLog())); |
} |
TEST(HttpAuthHandlerBasicTest, CreateAndInitPreemptiveAuthHandler_Invalid) { |
HttpAuthHandlerBasic::Factory digest_factory; |
HttpAuthCache auth_cache; |
std::string challenge("digest realm=\"foo\""); |
- HttpAuthChallengeTokenizer tokenizer(challenge.begin(), challenge.end()); |
HttpAuthCache::Entry* entry = |
auth_cache.Add(GURL("http://example.com").GetOrigin(), "bar", "digest", |
challenge, AuthCredentials(), "/bar"); |
EXPECT_FALSE(digest_factory.CreateAndInitPreemptiveAuthHandler( |
- entry, tokenizer, HttpAuth::AUTH_SERVER, BoundNetLog())); |
+ entry, HttpAuth::AUTH_SERVER, BoundNetLog())); |
} |
} // namespace net |