| 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 <set> | 5 #include <set> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
| 9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "net/base/mock_host_resolver.h" |
| 11 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
| 12 #include "net/http/http_auth.h" | 13 #include "net/http/http_auth.h" |
| 13 #include "net/http/http_auth_filter.h" | 14 #include "net/http/http_auth_filter.h" |
| 14 #include "net/http/http_auth_handler.h" | 15 #include "net/http/http_auth_handler.h" |
| 15 #include "net/http/http_auth_handler_factory.h" | 16 #include "net/http/http_auth_handler_factory.h" |
| 16 #include "net/http/http_auth_handler_mock.h" | 17 #include "net/http/http_auth_handler_mock.h" |
| 17 #include "net/http/http_response_headers.h" | 18 #include "net/http/http_response_headers.h" |
| 18 #include "net/http/http_util.h" | 19 #include "net/http/http_util.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 21 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 // TODO(ahendrickson): This may be flaky on Linux and OSX as it | 91 // TODO(ahendrickson): This may be flaky on Linux and OSX as it |
| 91 // relies on being able to load one of the known .so files | 92 // relies on being able to load one of the known .so files |
| 92 // for gssapi. | 93 // for gssapi. |
| 93 "negotiate", | 94 "negotiate", |
| 94 "", | 95 "", |
| 95 } | 96 } |
| 96 }; | 97 }; |
| 97 GURL origin("http://www.example.com"); | 98 GURL origin("http://www.example.com"); |
| 98 std::set<std::string> disabled_schemes; | 99 std::set<std::string> disabled_schemes; |
| 99 URLSecurityManagerAllow url_security_manager; | 100 URLSecurityManagerAllow url_security_manager; |
| 101 scoped_refptr<HostResolver> host_resolver(new MockHostResolver()); |
| 100 scoped_ptr<HttpAuthHandlerRegistryFactory> http_auth_handler_factory( | 102 scoped_ptr<HttpAuthHandlerRegistryFactory> http_auth_handler_factory( |
| 101 HttpAuthHandlerFactory::CreateDefault()); | 103 HttpAuthHandlerFactory::CreateDefault(host_resolver)); |
| 102 http_auth_handler_factory->SetURLSecurityManager( | 104 http_auth_handler_factory->SetURLSecurityManager( |
| 103 "negotiate", &url_security_manager); | 105 "negotiate", &url_security_manager); |
| 104 | 106 |
| 105 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 107 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
| 106 // Make a HttpResponseHeaders object. | 108 // Make a HttpResponseHeaders object. |
| 107 std::string headers_with_status_line("HTTP/1.1 401 Unauthorized\n"); | 109 std::string headers_with_status_line("HTTP/1.1 401 Unauthorized\n"); |
| 108 headers_with_status_line += tests[i].headers; | 110 headers_with_status_line += tests[i].headers; |
| 109 scoped_refptr<HttpResponseHeaders> headers( | 111 scoped_refptr<HttpResponseHeaders> headers( |
| 110 HeadersFromResponseText(headers_with_status_line)); | 112 HeadersFromResponseText(headers_with_status_line)); |
| 111 | 113 |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 std::string name; | 370 std::string name; |
| 369 | 371 |
| 370 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_SERVER); | 372 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_SERVER); |
| 371 EXPECT_STREQ("Authorization", name.c_str()); | 373 EXPECT_STREQ("Authorization", name.c_str()); |
| 372 | 374 |
| 373 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_PROXY); | 375 name = HttpAuth::GetAuthorizationHeaderName(HttpAuth::AUTH_PROXY); |
| 374 EXPECT_STREQ("Proxy-Authorization", name.c_str()); | 376 EXPECT_STREQ("Proxy-Authorization", name.c_str()); |
| 375 } | 377 } |
| 376 | 378 |
| 377 } // namespace net | 379 } // namespace net |
| OLD | NEW |