Index: net/http/http_auth_handler_factory_unittest.cc |
diff --git a/net/http/http_auth_handler_factory_unittest.cc b/net/http/http_auth_handler_factory_unittest.cc |
index 76eb3a3c026014137b0f576bfcccbefe5aba8380..7efd29be02aca380451df8fe96a41c23f539ee9f 100644 |
--- a/net/http/http_auth_handler_factory_unittest.cc |
+++ b/net/http/http_auth_handler_factory_unittest.cc |
@@ -5,11 +5,13 @@ |
#include "base/memory/scoped_ptr.h" |
#include "base/strings/string_util.h" |
#include "net/base/net_errors.h" |
+#include "net/base/test_completion_callback.h" |
#include "net/dns/mock_host_resolver.h" |
#include "net/http/http_auth_challenge_tokenizer.h" |
#include "net/http/http_auth_handler.h" |
#include "net/http/http_auth_handler_factory.h" |
#include "net/http/http_auth_handler_mock.h" |
+#include "net/http/http_response_info.h" |
#include "net/http/mock_allow_url_security_manager.h" |
#include "net/http/url_security_manager.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -26,12 +28,13 @@ class MockHttpAuthHandlerFactory : public HttpAuthHandlerFactory { |
scoped_ptr<HttpAuthHandler> CreateAuthHandlerForScheme( |
const std::string& scheme) override { |
+ if (scheme_.empty()) |
+ return scoped_ptr<HttpAuthHandler>(); |
EXPECT_EQ(scheme, scheme_) << scheme << " vs. " << scheme_; |
return make_scoped_ptr(new HttpAuthHandlerMock()); |
} |
scoped_ptr<HttpAuthHandler> CreateAndInitPreemptiveAuthHandler( |
HttpAuthCache::Entry* cache_entry, |
- const HttpAuthChallengeTokenizer& tokenizer, |
HttpAuth::Target target, |
const BoundNetLog& net_log) override { |
EXPECT_EQ(cache_entry->scheme(), scheme_) << cache_entry->scheme() |
@@ -75,7 +78,7 @@ TEST(HttpAuthHandlerFactoryTest, RegistryFactory) { |
// Test replacement of existing schemes. |
registry_factory.RegisterSchemeFactory("digest", |
- new HttpAuthHandlerMock::Factory()); |
+ new MockHttpAuthHandlerFactory("")); |
handler = registry_factory.CreateAuthHandlerForScheme("digest"); |
EXPECT_FALSE(handler); |
registry_factory.RegisterSchemeFactory( |
@@ -93,6 +96,8 @@ TEST(HttpAuthHandlerFactoryTest, DefaultFactory) { |
"negotiate", &url_security_manager); |
GURL server_origin("http://www.example.com"); |
GURL proxy_origin("http://cache.example.com:3128"); |
+ TestCompletionCallback callback; |
+ HttpResponseInfo response_info; |
{ |
std::string challenge = "Basic realm=\"FooBar\""; |
HttpAuthChallengeTokenizer tokenizer(challenge.begin(), challenge.end()); |
@@ -100,10 +105,10 @@ TEST(HttpAuthHandlerFactoryTest, DefaultFactory) { |
http_auth_handler_factory->CreateAuthHandlerForScheme( |
tokenizer.NormalizedScheme()); |
ASSERT_TRUE(handler); |
- int rv = handler->HandleInitialChallenge(tokenizer, HttpAuth::AUTH_SERVER, |
- server_origin, BoundNetLog()); |
- EXPECT_EQ(OK, rv); |
- ASSERT_FALSE(handler.get() == NULL); |
+ int rv = handler->HandleInitialChallenge( |
+ tokenizer, response_info, HttpAuth::AUTH_SERVER, server_origin, |
+ BoundNetLog(), callback.callback()); |
+ EXPECT_EQ(OK, callback.GetResult(rv)); |
EXPECT_EQ("basic", handler->auth_scheme()); |
EXPECT_STREQ("FooBar", handler->realm().c_str()); |
EXPECT_EQ(HttpAuth::AUTH_SERVER, handler->target()); |
@@ -120,10 +125,10 @@ TEST(HttpAuthHandlerFactoryTest, DefaultFactory) { |
http_auth_handler_factory->CreateAuthHandlerForScheme( |
tokenizer.NormalizedScheme()); |
ASSERT_TRUE(handler); |
- int rv = handler->HandleInitialChallenge(tokenizer, HttpAuth::AUTH_PROXY, |
- proxy_origin, BoundNetLog()); |
- EXPECT_EQ(OK, rv); |
- ASSERT_FALSE(handler.get() == NULL); |
+ int rv = handler->HandleInitialChallenge( |
+ tokenizer, response_info, HttpAuth::AUTH_PROXY, proxy_origin, |
+ BoundNetLog(), callback.callback()); |
+ EXPECT_EQ(OK, callback.GetResult(rv)); |
EXPECT_EQ("digest", handler->auth_scheme()); |
EXPECT_STREQ("FooBar", handler->realm().c_str()); |
EXPECT_EQ(HttpAuth::AUTH_PROXY, handler->target()); |
@@ -135,9 +140,10 @@ TEST(HttpAuthHandlerFactoryTest, DefaultFactory) { |
http_auth_handler_factory->CreateAuthHandlerForScheme( |
tokenizer.NormalizedScheme()); |
ASSERT_TRUE(handler); |
- int rv = handler->HandleInitialChallenge(tokenizer, HttpAuth::AUTH_SERVER, |
- server_origin, BoundNetLog()); |
- EXPECT_EQ(OK, rv); |
+ int rv = handler->HandleInitialChallenge( |
+ tokenizer, response_info, HttpAuth::AUTH_SERVER, server_origin, |
+ BoundNetLog(), callback.callback()); |
+ EXPECT_EQ(OK, callback.GetResult(rv)); |
ASSERT_FALSE(handler.get() == NULL); |
EXPECT_EQ("ntlm", handler->auth_scheme()); |
EXPECT_STREQ("", handler->realm().c_str()); |
@@ -150,8 +156,10 @@ TEST(HttpAuthHandlerFactoryTest, DefaultFactory) { |
http_auth_handler_factory->CreateAuthHandlerForScheme( |
tokenizer.NormalizedScheme()); |
ASSERT_TRUE(handler); |
- int rv = handler->HandleInitialChallenge(tokenizer, HttpAuth::AUTH_SERVER, |
- server_origin, BoundNetLog()); |
+ int rv = handler->HandleInitialChallenge( |
+ tokenizer, response_info, HttpAuth::AUTH_SERVER, server_origin, |
+ BoundNetLog(), callback.callback()); |
+ rv = callback.GetResult(rv); |
// Note the default factory doesn't support Kerberos on Android |
#if defined(USE_KERBEROS) && !defined(OS_ANDROID) |
EXPECT_EQ(OK, rv); |