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 "net/http/http_auth_handler_negotiate.h" | 5 #include "net/http/http_auth_handler_negotiate.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "net/base/mock_host_resolver.h" | 9 #include "net/base/mock_host_resolver.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
11 #include "net/base/test_completion_callback.h" | 11 #include "net/base/test_completion_callback.h" |
12 #include "net/http/http_request_info.h" | 12 #include "net/http/http_request_info.h" |
| 13 #include "net/http/mock_allow_url_security_manager.h" |
13 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
14 #include "net/http/mock_sspi_library_win.h" | 15 #include "net/http/mock_sspi_library_win.h" |
15 #elif defined(OS_POSIX) | 16 #elif defined(OS_POSIX) |
16 #include "net/http/mock_gssapi_library_posix.h" | 17 #include "net/http/mock_gssapi_library_posix.h" |
17 #include "net/third_party/gssapi/gssapi.h" | 18 #include "net/third_party/gssapi/gssapi.h" |
18 #endif | 19 #endif |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "testing/platform_test.h" | 21 #include "testing/platform_test.h" |
21 | 22 |
22 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
23 typedef net::MockSSPILibrary MockAuthLibrary; | 24 typedef net::MockSSPILibrary MockAuthLibrary; |
24 #elif defined(OS_POSIX) | 25 #elif defined(OS_POSIX) |
25 typedef net::test::MockGSSAPILibrary MockAuthLibrary; | 26 typedef net::test::MockGSSAPILibrary MockAuthLibrary; |
26 #endif | 27 #endif |
27 | 28 |
28 | 29 |
29 namespace net { | 30 namespace net { |
30 | 31 |
31 class HttpAuthHandlerNegotiateTest : public PlatformTest { | 32 class HttpAuthHandlerNegotiateTest : public PlatformTest { |
32 public: | 33 public: |
33 virtual void SetUp() { | 34 virtual void SetUp() { |
34 auth_library_ = new MockAuthLibrary(); | 35 auth_library_ = new MockAuthLibrary(); |
35 resolver_.reset(new MockHostResolver()); | 36 resolver_.reset(new MockHostResolver()); |
36 resolver_->rules()->AddIPLiteralRule("alias", "10.0.0.2", | 37 resolver_->rules()->AddIPLiteralRule("alias", "10.0.0.2", |
37 "canonical.example.com"); | 38 "canonical.example.com"); |
38 | 39 |
39 url_security_manager_.reset(new URLSecurityManagerAllow()); | 40 url_security_manager_.reset(new MockAllowURLSecurityManager()); |
40 factory_.reset(new HttpAuthHandlerNegotiate::Factory()); | 41 factory_.reset(new HttpAuthHandlerNegotiate::Factory()); |
41 factory_->set_url_security_manager(url_security_manager_.get()); | 42 factory_->set_url_security_manager(url_security_manager_.get()); |
42 factory_->set_library(auth_library_); | 43 factory_->set_library(auth_library_); |
43 factory_->set_host_resolver(resolver_.get()); | 44 factory_->set_host_resolver(resolver_.get()); |
44 } | 45 } |
45 | 46 |
46 void SetupMocks(MockAuthLibrary* mock_library) { | 47 void SetupMocks(MockAuthLibrary* mock_library) { |
47 #if defined(OS_WIN) | 48 #if defined(OS_WIN) |
48 security_package_.reset(new SecPkgInfoW); | 49 security_package_.reset(new SecPkgInfoW); |
49 memset(security_package_.get(), 0x0, sizeof(SecPkgInfoW)); | 50 memset(security_package_.get(), 0x0, sizeof(SecPkgInfoW)); |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 HttpRequestInfo request_info; | 344 HttpRequestInfo request_info; |
344 std::string token; | 345 std::string token; |
345 EXPECT_EQ(ERR_IO_PENDING, auth_handler->GenerateAuthToken( | 346 EXPECT_EQ(ERR_IO_PENDING, auth_handler->GenerateAuthToken( |
346 NULL, NULL, &request_info, &callback, &token)); | 347 NULL, NULL, &request_info, &callback, &token)); |
347 EXPECT_EQ(ERR_MISSING_AUTH_CREDENTIALS, callback.WaitForResult()); | 348 EXPECT_EQ(ERR_MISSING_AUTH_CREDENTIALS, callback.WaitForResult()); |
348 } | 349 } |
349 | 350 |
350 #endif // defined(OS_POSIX) | 351 #endif // defined(OS_POSIX) |
351 | 352 |
352 } // namespace net | 353 } // namespace net |
OLD | NEW |