Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: net/http/http_auth_unittest.cc

Issue 1414313002: Allow dynamic updating of authentication policies (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to cbentzel@'s comments. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_auth_scheme.cc ('k') | net/http/http_log_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
12 #include "net/dns/mock_host_resolver.h" 12 #include "net/dns/mock_host_resolver.h"
13 #include "net/http/http_auth.h" 13 #include "net/http/http_auth.h"
14 #include "net/http/http_auth_challenge_tokenizer.h" 14 #include "net/http/http_auth_challenge_tokenizer.h"
15 #include "net/http/http_auth_filter.h" 15 #include "net/http/http_auth_filter.h"
16 #include "net/http/http_auth_handler.h" 16 #include "net/http/http_auth_handler.h"
17 #include "net/http/http_auth_handler_factory.h" 17 #include "net/http/http_auth_handler_factory.h"
18 #include "net/http/http_auth_handler_mock.h" 18 #include "net/http/http_auth_handler_mock.h"
19 #include "net/http/http_auth_scheme.h"
19 #include "net/http/http_response_headers.h" 20 #include "net/http/http_response_headers.h"
20 #include "net/http/http_util.h" 21 #include "net/http/http_util.h"
21 #include "net/http/mock_allow_url_security_manager.h" 22 #include "net/http/mock_allow_http_auth_preferences.h"
22 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
23 24
24 namespace net { 25 namespace net {
25 26
26 namespace { 27 namespace {
27 28
28 HttpAuthHandlerMock* CreateMockHandler(bool connection_based) { 29 HttpAuthHandlerMock* CreateMockHandler(bool connection_based) {
29 HttpAuthHandlerMock* auth_handler = new HttpAuthHandlerMock(); 30 HttpAuthHandlerMock* auth_handler = new HttpAuthHandlerMock();
30 auth_handler->set_connection_based(connection_based); 31 auth_handler->set_connection_based(connection_based);
31 std::string challenge_text = "Basic"; 32 std::string challenge_text = "Basic";
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 // for gssapi. 115 // for gssapi.
115 HttpAuth::AUTH_SCHEME_NEGOTIATE, 116 HttpAuth::AUTH_SCHEME_NEGOTIATE,
116 #else 117 #else
117 // On systems that don't use Kerberos fall back to NTLM. 118 // On systems that don't use Kerberos fall back to NTLM.
118 HttpAuth::AUTH_SCHEME_NTLM, 119 HttpAuth::AUTH_SCHEME_NTLM,
119 #endif // defined(USE_KERBEROS) 120 #endif // defined(USE_KERBEROS)
120 "", 121 "",
121 }}; 122 }};
122 GURL origin("http://www.example.com"); 123 GURL origin("http://www.example.com");
123 std::set<HttpAuth::Scheme> disabled_schemes; 124 std::set<HttpAuth::Scheme> disabled_schemes;
124 MockAllowURLSecurityManager url_security_manager; 125 MockAllowHttpAuthPreferences http_auth_preferences;
125 scoped_ptr<HostResolver> host_resolver(new MockHostResolver()); 126 scoped_ptr<HostResolver> host_resolver(new MockHostResolver());
126 scoped_ptr<HttpAuthHandlerRegistryFactory> http_auth_handler_factory( 127 scoped_ptr<HttpAuthHandlerRegistryFactory> http_auth_handler_factory(
127 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())); 128 HttpAuthHandlerFactory::CreateDefault(host_resolver.get()));
128 http_auth_handler_factory->SetURLSecurityManager( 129 http_auth_handler_factory->SetHttpAuthPreferences(kNegotiateAuthScheme,
129 "negotiate", &url_security_manager); 130 &http_auth_preferences);
130 131
131 for (size_t i = 0; i < arraysize(tests); ++i) { 132 for (size_t i = 0; i < arraysize(tests); ++i) {
132 // Make a HttpResponseHeaders object. 133 // Make a HttpResponseHeaders object.
133 std::string headers_with_status_line("HTTP/1.1 401 Unauthorized\n"); 134 std::string headers_with_status_line("HTTP/1.1 401 Unauthorized\n");
134 headers_with_status_line += tests[i].headers; 135 headers_with_status_line += tests[i].headers;
135 scoped_refptr<HttpResponseHeaders> headers( 136 scoped_refptr<HttpResponseHeaders> headers(
136 HeadersFromResponseText(headers_with_status_line)); 137 HeadersFromResponseText(headers_with_status_line));
137 138
138 scoped_ptr<HttpAuthHandler> handler; 139 scoped_ptr<HttpAuthHandler> handler;
139 HttpAuth::ChooseBestChallenge(http_auth_handler_factory.get(), 140 HttpAuth::ChooseBestChallenge(http_auth_handler_factory.get(),
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 std::string name; 260 std::string name;
260 261
261 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_SERVER); 262 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_SERVER);
262 EXPECT_STREQ("Authorization", name.c_str()); 263 EXPECT_STREQ("Authorization", name.c_str());
263 264
264 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_PROXY); 265 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_PROXY);
265 EXPECT_STREQ("Proxy-Authorization", name.c_str()); 266 EXPECT_STREQ("Proxy-Authorization", name.c_str());
266 } 267 }
267 268
268 } // namespace net 269 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_scheme.cc ('k') | net/http/http_log_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698