| 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_request_info.h" | 14 #include "net/http/http_request_info.h" |
| 15 #include "net/http/http_response_info.h" |
| 15 #include "net/http/mock_allow_http_auth_preferences.h" | 16 #include "net/http/mock_allow_http_auth_preferences.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" |
| 24 #include "testing/platform_test.h" | 25 #include "testing/platform_test.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 mock_library->ExpectSecurityContext(query.expected_package, | 183 mock_library->ExpectSecurityContext(query.expected_package, |
| 183 query.response_code, | 184 query.response_code, |
| 184 query.minor_response_code, | 185 query.minor_response_code, |
| 185 query.context_info, | 186 query.context_info, |
| 186 query.expected_input_token, | 187 query.expected_input_token, |
| 187 query.output_token); | 188 query.output_token); |
| 188 } | 189 } |
| 189 | 190 |
| 190 #endif // defined(OS_POSIX) | 191 #endif // defined(OS_POSIX) |
| 191 | 192 |
| 192 int CreateHandler(bool disable_cname_lookup, bool use_port, | 193 int CreateHandler(bool disable_cname_lookup, |
| 193 bool synchronous_resolve_mode, | 194 bool use_port, |
| 194 const std::string& url_string, | 195 bool synchronous_resolve_mode, |
| 195 scoped_ptr<HttpAuthHandlerNegotiate>* handler) { | 196 const std::string& url_string, |
| 197 scoped_ptr<HttpAuthHandlerNegotiate>* handler) { |
| 196 http_auth_preferences_->set_negotiate_disable_cname_lookup( | 198 http_auth_preferences_->set_negotiate_disable_cname_lookup( |
| 197 disable_cname_lookup); | 199 disable_cname_lookup); |
| 198 http_auth_preferences_->set_negotiate_enable_port(use_port); | 200 http_auth_preferences_->set_negotiate_enable_port(use_port); |
| 199 resolver_->set_synchronous_mode(synchronous_resolve_mode); | 201 resolver_->set_synchronous_mode(synchronous_resolve_mode); |
| 200 GURL gurl(url_string); | 202 GURL gurl(url_string); |
| 201 | 203 |
| 202 // Note: This is a little tricky because CreateAuthHandlerFromString | 204 // Note: This is a little tricky because CreateAuthHandlerFromString |
| 203 // expects a scoped_ptr<HttpAuthHandler>* rather than a | 205 // expects a scoped_ptr<HttpAuthHandler>* rather than a |
| 204 // scoped_ptr<HttpAuthHandlerNegotiate>*. This needs to do the cast | 206 // scoped_ptr<HttpAuthHandlerNegotiate>*. This needs to do the cast |
| 205 // after creating the handler, and make sure that generic_handler | 207 // after creating the handler, and make sure that generic_handler |
| 206 // no longer holds on to the HttpAuthHandlerNegotiate object. | 208 // no longer holds on to the HttpAuthHandlerNegotiate object. |
| 207 scoped_ptr<HttpAuthHandler> generic_handler; | 209 scoped_ptr<HttpAuthHandler> generic_handler; |
| 208 int rv = factory_->CreateAuthHandlerFromString("Negotiate", | 210 HttpResponseInfo null_response_info; |
| 209 HttpAuth::AUTH_SERVER, | 211 int rv = factory_->CreateAuthHandlerFromString( |
| 210 gurl, | 212 "Negotiate", HttpAuth::AUTH_SERVER, null_response_info, gurl, |
| 211 BoundNetLog(), | 213 BoundNetLog(), &generic_handler); |
| 212 &generic_handler); | |
| 213 if (rv != OK) | 214 if (rv != OK) |
| 214 return rv; | 215 return rv; |
| 215 HttpAuthHandlerNegotiate* negotiate_handler = | 216 HttpAuthHandlerNegotiate* negotiate_handler = |
| 216 static_cast<HttpAuthHandlerNegotiate*>(generic_handler.release()); | 217 static_cast<HttpAuthHandlerNegotiate*>(generic_handler.release()); |
| 217 handler->reset(negotiate_handler); | 218 handler->reset(negotiate_handler); |
| 218 return rv; | 219 return rv; |
| 219 } | 220 } |
| 220 | 221 |
| 221 MockAuthLibrary* AuthLibrary() { return auth_library_; } | 222 MockAuthLibrary* AuthLibrary() { return auth_library_; } |
| 222 | 223 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 BoundNetLog(), | 380 BoundNetLog(), |
| 380 &generic_handler); | 381 &generic_handler); |
| 381 EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME, rv); | 382 EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME, rv); |
| 382 EXPECT_TRUE(generic_handler.get() == NULL); | 383 EXPECT_TRUE(generic_handler.get() == NULL); |
| 383 } | 384 } |
| 384 #endif // defined(DLOPEN_KERBEROS) | 385 #endif // defined(DLOPEN_KERBEROS) |
| 385 | 386 |
| 386 #endif // defined(OS_POSIX) | 387 #endif // defined(OS_POSIX) |
| 387 | 388 |
| 388 } // namespace net | 389 } // namespace net |
| OLD | NEW |