OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/http/http_auth_handler_negotiate.h" | 5 #include "net/http/http_auth_handler_negotiate.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
12 #include "net/base/test_completion_callback.h" | 12 #include "net/base/test_completion_callback.h" |
13 #include "net/dns/mock_host_resolver.h" | 13 #include "net/dns/mock_host_resolver.h" |
| 14 #include "net/http/http_auth_challenge_tokenizer.h" |
14 #include "net/http/http_request_info.h" | 15 #include "net/http/http_request_info.h" |
15 #include "net/http/mock_allow_url_security_manager.h" | 16 #include "net/http/mock_allow_url_security_manager.h" |
16 #if defined(OS_ANDROID) | 17 #if defined(OS_ANDROID) |
17 #include "net/android/dummy_spnego_authenticator.h" | 18 #include "net/android/dummy_spnego_authenticator.h" |
18 #elif defined(OS_WIN) | 19 #elif defined(OS_WIN) |
19 #include "net/http/mock_sspi_library_win.h" | 20 #include "net/http/mock_sspi_library_win.h" |
20 #elif defined(OS_POSIX) | 21 #elif defined(OS_POSIX) |
21 #include "net/http/mock_gssapi_library_posix.h" | 22 #include "net/http/mock_gssapi_library_posix.h" |
22 #endif | 23 #endif |
23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 factory_->set_disable_cname_lookup(disable_cname_lookup); | 198 factory_->set_disable_cname_lookup(disable_cname_lookup); |
198 factory_->set_use_port(use_port); | 199 factory_->set_use_port(use_port); |
199 resolver_->set_synchronous_mode(synchronous_resolve_mode); | 200 resolver_->set_synchronous_mode(synchronous_resolve_mode); |
200 GURL gurl(url_string); | 201 GURL gurl(url_string); |
201 | 202 |
202 // Note: This is a little tricky because CreateAuthHandlerFromString | 203 // Note: This is a little tricky because CreateAuthHandlerFromString |
203 // expects a scoped_ptr<HttpAuthHandler>* rather than a | 204 // expects a scoped_ptr<HttpAuthHandler>* rather than a |
204 // scoped_ptr<HttpAuthHandlerNegotiate>*. This needs to do the cast | 205 // scoped_ptr<HttpAuthHandlerNegotiate>*. This needs to do the cast |
205 // after creating the handler, and make sure that generic_handler | 206 // after creating the handler, and make sure that generic_handler |
206 // no longer holds on to the HttpAuthHandlerNegotiate object. | 207 // no longer holds on to the HttpAuthHandlerNegotiate object. |
207 scoped_ptr<HttpAuthHandler> generic_handler; | 208 std::string challenge = "Negotiate"; |
208 int rv = factory_->CreateAuthHandlerFromString("Negotiate", | 209 HttpAuthChallengeTokenizer tokenizer(challenge.begin(), challenge.end()); |
209 HttpAuth::AUTH_SERVER, | 210 |
210 gurl, | 211 scoped_ptr<HttpAuthHandler> generic_handler = |
211 BoundNetLog(), | 212 factory_->CreateAuthHandlerForScheme(tokenizer.NormalizedScheme()); |
212 &generic_handler); | 213 if (!generic_handler) |
| 214 return ERR_UNSUPPORTED_AUTH_SCHEME; |
| 215 int rv = generic_handler->HandleInitialChallenge( |
| 216 tokenizer, HttpAuth::AUTH_SERVER, gurl, BoundNetLog()); |
213 if (rv != OK) | 217 if (rv != OK) |
214 return rv; | 218 return rv; |
215 HttpAuthHandlerNegotiate* negotiate_handler = | 219 HttpAuthHandlerNegotiate* negotiate_handler = |
216 static_cast<HttpAuthHandlerNegotiate*>(generic_handler.release()); | 220 static_cast<HttpAuthHandlerNegotiate*>(generic_handler.release()); |
217 handler->reset(negotiate_handler); | 221 handler->reset(negotiate_handler); |
218 return rv; | 222 return rv; |
219 } | 223 } |
220 | 224 |
221 MockAuthLibrary* AuthLibrary() { return auth_library_; } | 225 MockAuthLibrary* AuthLibrary() { return auth_library_; } |
222 | 226 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 BoundNetLog(), | 384 BoundNetLog(), |
381 &generic_handler); | 385 &generic_handler); |
382 EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME, rv); | 386 EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME, rv); |
383 EXPECT_TRUE(generic_handler.get() == NULL); | 387 EXPECT_TRUE(generic_handler.get() == NULL); |
384 } | 388 } |
385 #endif // defined(DLOPEN_KERBEROS) | 389 #endif // defined(DLOPEN_KERBEROS) |
386 | 390 |
387 #endif // defined(OS_POSIX) | 391 #endif // defined(OS_POSIX) |
388 | 392 |
389 } // namespace net | 393 } // namespace net |
OLD | NEW |