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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "net/base/mock_host_resolver.h" | 11 #include "net/base/mock_host_resolver.h" |
12 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
13 #include "net/http/http_auth.h" | 13 #include "net/http/http_auth.h" |
14 #include "net/http/http_auth_filter.h" | 14 #include "net/http/http_auth_filter.h" |
15 #include "net/http/http_auth_handler.h" | 15 #include "net/http/http_auth_handler.h" |
16 #include "net/http/http_auth_handler_factory.h" | 16 #include "net/http/http_auth_handler_factory.h" |
17 #include "net/http/http_auth_handler_mock.h" | 17 #include "net/http/http_auth_handler_mock.h" |
18 #include "net/http/http_response_headers.h" | 18 #include "net/http/http_response_headers.h" |
19 #include "net/http/http_util.h" | 19 #include "net/http/http_util.h" |
| 20 #include "net/http/mock_allow_url_security_manager.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 | 22 |
22 namespace net { | 23 namespace net { |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
26 HttpAuthHandlerMock* CreateMockHandler(bool connection_based) { | 27 HttpAuthHandlerMock* CreateMockHandler(bool connection_based) { |
27 HttpAuthHandlerMock* auth_handler = new HttpAuthHandlerMock(); | 28 HttpAuthHandlerMock* auth_handler = new HttpAuthHandlerMock(); |
28 auth_handler->set_connection_based(connection_based); | 29 auth_handler->set_connection_based(connection_based); |
29 std::string challenge_text = "Basic"; | 30 std::string challenge_text = "Basic"; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 // for gssapi. | 109 // for gssapi. |
109 "WWW-Authenticate: Negotiate\n" | 110 "WWW-Authenticate: Negotiate\n" |
110 "WWW-Authenticate: NTLM\n", | 111 "WWW-Authenticate: NTLM\n", |
111 | 112 |
112 HttpAuth::AUTH_SCHEME_NEGOTIATE, | 113 HttpAuth::AUTH_SCHEME_NEGOTIATE, |
113 "", | 114 "", |
114 } | 115 } |
115 }; | 116 }; |
116 GURL origin("http://www.example.com"); | 117 GURL origin("http://www.example.com"); |
117 std::set<HttpAuth::Scheme> disabled_schemes; | 118 std::set<HttpAuth::Scheme> disabled_schemes; |
118 URLSecurityManagerAllow url_security_manager; | 119 MockAllowURLSecurityManager url_security_manager; |
119 scoped_ptr<HostResolver> host_resolver(new MockHostResolver()); | 120 scoped_ptr<HostResolver> host_resolver(new MockHostResolver()); |
120 scoped_ptr<HttpAuthHandlerRegistryFactory> http_auth_handler_factory( | 121 scoped_ptr<HttpAuthHandlerRegistryFactory> http_auth_handler_factory( |
121 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())); | 122 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())); |
122 http_auth_handler_factory->SetURLSecurityManager( | 123 http_auth_handler_factory->SetURLSecurityManager( |
123 "negotiate", &url_security_manager); | 124 "negotiate", &url_security_manager); |
124 | 125 |
125 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 126 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
126 // Make a HttpResponseHeaders object. | 127 // Make a HttpResponseHeaders object. |
127 std::string headers_with_status_line("HTTP/1.1 401 Unauthorized\n"); | 128 std::string headers_with_status_line("HTTP/1.1 401 Unauthorized\n"); |
128 headers_with_status_line += tests[i].headers; | 129 headers_with_status_line += tests[i].headers; |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 std::string name; | 421 std::string name; |
421 | 422 |
422 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_SERVER); | 423 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_SERVER); |
423 EXPECT_STREQ("Authorization", name.c_str()); | 424 EXPECT_STREQ("Authorization", name.c_str()); |
424 | 425 |
425 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_PROXY); | 426 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_PROXY); |
426 EXPECT_STREQ("Proxy-Authorization", name.c_str()); | 427 EXPECT_STREQ("Proxy-Authorization", name.c_str()); |
427 } | 428 } |
428 | 429 |
429 } // namespace net | 430 } // namespace net |
OLD | NEW |