| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/scoped_ptr.h" | 5 #include "base/scoped_ptr.h" |
| 6 #include "net/base/mock_host_resolver.h" |
| 6 #include "net/base/net_errors.h" | 7 #include "net/base/net_errors.h" |
| 7 #include "net/http/http_auth_handler.h" | 8 #include "net/http/http_auth_handler.h" |
| 8 #include "net/http/http_auth_handler_factory.h" | 9 #include "net/http/http_auth_handler_factory.h" |
| 9 #include "net/http/url_security_manager.h" | 10 #include "net/http/url_security_manager.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 12 |
| 12 namespace net { | 13 namespace net { |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 EXPECT_EQ(kBasicReturnCode, | 89 EXPECT_EQ(kBasicReturnCode, |
| 89 registry_factory.CreateAuthHandlerFromString( | 90 registry_factory.CreateAuthHandlerFromString( |
| 90 "Basic", HttpAuth::AUTH_SERVER, gurl, BoundNetLog(), &handler)); | 91 "Basic", HttpAuth::AUTH_SERVER, gurl, BoundNetLog(), &handler)); |
| 91 EXPECT_EQ(kDigestReturnCodeReplace, | 92 EXPECT_EQ(kDigestReturnCodeReplace, |
| 92 registry_factory.CreateAuthHandlerFromString( | 93 registry_factory.CreateAuthHandlerFromString( |
| 93 "Digest", HttpAuth::AUTH_SERVER, gurl, BoundNetLog(), | 94 "Digest", HttpAuth::AUTH_SERVER, gurl, BoundNetLog(), |
| 94 &handler)); | 95 &handler)); |
| 95 } | 96 } |
| 96 | 97 |
| 97 TEST(HttpAuthHandlerFactoryTest, DefaultFactory) { | 98 TEST(HttpAuthHandlerFactoryTest, DefaultFactory) { |
| 99 scoped_refptr<HostResolver> host_resolver(new MockHostResolver()); |
| 98 URLSecurityManagerAllow url_security_manager; | 100 URLSecurityManagerAllow url_security_manager; |
| 99 scoped_ptr<HttpAuthHandlerRegistryFactory> http_auth_handler_factory( | 101 scoped_ptr<HttpAuthHandlerRegistryFactory> http_auth_handler_factory( |
| 100 HttpAuthHandlerFactory::CreateDefault()); | 102 HttpAuthHandlerFactory::CreateDefault(host_resolver)); |
| 101 http_auth_handler_factory->SetURLSecurityManager( | 103 http_auth_handler_factory->SetURLSecurityManager( |
| 102 "negotiate", &url_security_manager); | 104 "negotiate", &url_security_manager); |
| 103 GURL server_origin("http://www.example.com"); | 105 GURL server_origin("http://www.example.com"); |
| 104 GURL proxy_origin("http://cache.example.com:3128"); | 106 GURL proxy_origin("http://cache.example.com:3128"); |
| 105 { | 107 { |
| 106 scoped_ptr<HttpAuthHandler> handler; | 108 scoped_ptr<HttpAuthHandler> handler; |
| 107 int rv = http_auth_handler_factory->CreateAuthHandlerFromString( | 109 int rv = http_auth_handler_factory->CreateAuthHandlerFromString( |
| 108 "Basic realm=\"FooBar\"", | 110 "Basic realm=\"FooBar\"", |
| 109 HttpAuth::AUTH_SERVER, | 111 HttpAuth::AUTH_SERVER, |
| 110 server_origin, | 112 server_origin, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 ASSERT_FALSE(handler.get() == NULL); | 175 ASSERT_FALSE(handler.get() == NULL); |
| 174 EXPECT_STREQ("negotiate", handler->scheme().c_str()); | 176 EXPECT_STREQ("negotiate", handler->scheme().c_str()); |
| 175 EXPECT_STREQ("", handler->realm().c_str()); | 177 EXPECT_STREQ("", handler->realm().c_str()); |
| 176 EXPECT_EQ(HttpAuth::AUTH_SERVER, handler->target()); | 178 EXPECT_EQ(HttpAuth::AUTH_SERVER, handler->target()); |
| 177 EXPECT_TRUE(handler->encrypts_identity()); | 179 EXPECT_TRUE(handler->encrypts_identity()); |
| 178 EXPECT_TRUE(handler->is_connection_based()); | 180 EXPECT_TRUE(handler->is_connection_based()); |
| 179 } | 181 } |
| 180 } | 182 } |
| 181 | 183 |
| 182 } // namespace net | 184 } // namespace net |
| OLD | NEW |