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

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

Issue 1128043007: Support Kerberos on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix cbentzel@'s nits Created 5 years, 5 months 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
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"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 62 }
63 63
64 } // namespace 64 } // namespace
65 65
66 TEST(HttpAuthTest, ChooseBestChallenge) { 66 TEST(HttpAuthTest, ChooseBestChallenge) {
67 static const struct { 67 static const struct {
68 const char* headers; 68 const char* headers;
69 HttpAuth::Scheme challenge_scheme; 69 HttpAuth::Scheme challenge_scheme;
70 const char* challenge_realm; 70 const char* challenge_realm;
71 } tests[] = { 71 } tests[] = {
72 { 72 {
73 // Basic is the only challenge type, pick it. 73 // Basic is the only challenge type, pick it.
74 "Y: Digest realm=\"X\", nonce=\"aaaaaaaaaa\"\n" 74 "Y: Digest realm=\"X\", nonce=\"aaaaaaaaaa\"\n"
75 "www-authenticate: Basic realm=\"BasicRealm\"\n", 75 "www-authenticate: Basic realm=\"BasicRealm\"\n",
76 76
77 HttpAuth::AUTH_SCHEME_BASIC, 77 HttpAuth::AUTH_SCHEME_BASIC,
78 "BasicRealm", 78 "BasicRealm",
79 }, 79 },
80 { 80 {
81 // Fake is the only challenge type, but it is unsupported. 81 // Fake is the only challenge type, but it is unsupported.
82 "Y: Digest realm=\"FooBar\", nonce=\"aaaaaaaaaa\"\n" 82 "Y: Digest realm=\"FooBar\", nonce=\"aaaaaaaaaa\"\n"
83 "www-authenticate: Fake realm=\"FooBar\"\n", 83 "www-authenticate: Fake realm=\"FooBar\"\n",
84 84
85 HttpAuth::AUTH_SCHEME_MAX, 85 HttpAuth::AUTH_SCHEME_MAX,
86 "", 86 "",
87 }, 87 },
88 { 88 {
89 // Pick Digest over Basic. 89 // Pick Digest over Basic.
90 "www-authenticate: Basic realm=\"FooBar\"\n" 90 "www-authenticate: Basic realm=\"FooBar\"\n"
91 "www-authenticate: Fake realm=\"FooBar\"\n" 91 "www-authenticate: Fake realm=\"FooBar\"\n"
92 "www-authenticate: nonce=\"aaaaaaaaaa\"\n" 92 "www-authenticate: nonce=\"aaaaaaaaaa\"\n"
93 "www-authenticate: Digest realm=\"DigestRealm\", nonce=\"aaaaaaaaaa\"\n", 93 "www-authenticate: Digest realm=\"DigestRealm\", nonce=\"aaaaaaaaaa\"\n",
94 94
95 HttpAuth::AUTH_SCHEME_DIGEST, 95 HttpAuth::AUTH_SCHEME_DIGEST,
96 "DigestRealm", 96 "DigestRealm",
97 }, 97 },
98 { 98 {
99 // Handle an empty header correctly. 99 // Handle an empty header correctly.
100 "Y: Digest realm=\"X\", nonce=\"aaaaaaaaaa\"\n" 100 "Y: Digest realm=\"X\", nonce=\"aaaaaaaaaa\"\n"
101 "www-authenticate:\n", 101 "www-authenticate:\n",
102 102
103 HttpAuth::AUTH_SCHEME_MAX, 103 HttpAuth::AUTH_SCHEME_MAX,
104 "", 104 "",
105 }, 105 },
106 { 106 {
107 "WWW-Authenticate: Negotiate\n" 107 "WWW-Authenticate: Negotiate\n"
108 "WWW-Authenticate: NTLM\n", 108 "WWW-Authenticate: NTLM\n",
109 109
110 #if defined(USE_KERBEROS) 110 #if defined(USE_KERBEROS) && !defined(OS_ANDROID)
111 // Choose Negotiate over NTLM on all platforms. 111 // Choose Negotiate over NTLM on all platforms.
112 // TODO(ahendrickson): This may be flaky on Linux and OSX as it 112 // TODO(ahendrickson): This may be flaky on Linux and OSX as it
113 // relies on being able to load one of the known .so files 113 // relies on being able to load one of the known .so files
114 // for gssapi. 114 // for gssapi.
115 HttpAuth::AUTH_SCHEME_NEGOTIATE, 115 HttpAuth::AUTH_SCHEME_NEGOTIATE,
116 #else 116 #else
117 // On systems that don't use Kerberos fall back to NTLM. 117 // On systems that don't use Kerberos fall back to NTLM.
118 HttpAuth::AUTH_SCHEME_NTLM, 118 HttpAuth::AUTH_SCHEME_NTLM,
119 #endif // defined(USE_KERBEROS) 119 #endif // defined(USE_KERBEROS)
120 "", 120 "",
121 } 121 }};
122 };
123 GURL origin("http://www.example.com"); 122 GURL origin("http://www.example.com");
124 std::set<HttpAuth::Scheme> disabled_schemes; 123 std::set<HttpAuth::Scheme> disabled_schemes;
125 MockAllowURLSecurityManager url_security_manager; 124 MockAllowURLSecurityManager url_security_manager;
126 scoped_ptr<HostResolver> host_resolver(new MockHostResolver()); 125 scoped_ptr<HostResolver> host_resolver(new MockHostResolver());
127 scoped_ptr<HttpAuthHandlerRegistryFactory> http_auth_handler_factory( 126 scoped_ptr<HttpAuthHandlerRegistryFactory> http_auth_handler_factory(
128 HttpAuthHandlerFactory::CreateDefault(host_resolver.get())); 127 HttpAuthHandlerFactory::CreateDefault(host_resolver.get()));
129 http_auth_handler_factory->SetURLSecurityManager( 128 http_auth_handler_factory->SetURLSecurityManager(
130 "negotiate", &url_security_manager); 129 "negotiate", &url_security_manager);
131 130
132 for (size_t i = 0; i < arraysize(tests); ++i) { 131 for (size_t i = 0; i < arraysize(tests); ++i) {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 std::string name; 259 std::string name;
261 260
262 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_SERVER); 261 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_SERVER);
263 EXPECT_STREQ("Authorization", name.c_str()); 262 EXPECT_STREQ("Authorization", name.c_str());
264 263
265 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_PROXY); 264 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_PROXY);
266 EXPECT_STREQ("Proxy-Authorization", name.c_str()); 265 EXPECT_STREQ("Proxy-Authorization", name.c_str());
267 } 266 }
268 267
269 } // namespace net 268 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698