OLD | NEW |
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 "net/http/http_auth_controller.h" | 5 #include "net/http/http_auth_controller.h" |
6 | 6 |
7 #include "net/base/net_errors.h" | 7 #include "net/base/net_errors.h" |
8 #include "net/base/net_log.h" | 8 #include "net/base/net_log.h" |
9 #include "net/base/test_completion_callback.h" | 9 #include "net/base/test_completion_callback.h" |
10 #include "net/http/http_auth_cache.h" | 10 #include "net/http/http_auth_cache.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 "\r\n"; | 51 "\r\n"; |
52 std::string headers_string = HttpUtil::AssembleRawHeaders( | 52 std::string headers_string = HttpUtil::AssembleRawHeaders( |
53 headers_raw_string.c_str(), headers_raw_string.length()); | 53 headers_raw_string.c_str(), headers_raw_string.length()); |
54 scoped_refptr<HttpResponseHeaders> headers( | 54 scoped_refptr<HttpResponseHeaders> headers( |
55 new HttpResponseHeaders(headers_string)); | 55 new HttpResponseHeaders(headers_string)); |
56 | 56 |
57 HttpAuthHandlerMock::Factory auth_handler_factory; | 57 HttpAuthHandlerMock::Factory auth_handler_factory; |
58 HttpAuthHandlerMock* auth_handler = new HttpAuthHandlerMock(); | 58 HttpAuthHandlerMock* auth_handler = new HttpAuthHandlerMock(); |
59 auth_handler->SetGenerateExpectation((run_mode == RUN_HANDLER_ASYNC), | 59 auth_handler->SetGenerateExpectation((run_mode == RUN_HANDLER_ASYNC), |
60 handler_rv); | 60 handler_rv); |
61 auth_handler_factory.set_mock_handler(auth_handler, HttpAuth::AUTH_PROXY); | 61 auth_handler_factory.AddMockHandler(auth_handler, HttpAuth::AUTH_PROXY); |
62 auth_handler_factory.set_do_init_from_challenge(true); | 62 auth_handler_factory.set_do_init_from_challenge(true); |
63 | 63 |
64 scoped_refptr<HttpAuthController> controller( | 64 scoped_refptr<HttpAuthController> controller( |
65 new HttpAuthController(HttpAuth::AUTH_PROXY, | 65 new HttpAuthController(HttpAuth::AUTH_PROXY, |
66 GURL("http://example.com"), | 66 GURL("http://example.com"), |
67 &dummy_auth_cache, &auth_handler_factory)); | 67 &dummy_auth_cache, &auth_handler_factory)); |
68 ASSERT_EQ(OK, | 68 ASSERT_EQ(OK, |
69 controller->HandleAuthChallenge(headers, false, false, dummy_log)); | 69 controller->HandleAuthChallenge(headers, false, false, dummy_log)); |
70 EXPECT_TRUE(controller->HaveAuthHandler()); | 70 EXPECT_TRUE(controller->HaveAuthHandler()); |
71 controller->ResetAuth(string16(), string16()); | 71 controller->ResetAuth(string16(), string16()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 RunSingleRoundAuthTest(RUN_HANDLER_ASYNC, ERR_MISSING_AUTH_CREDENTIALS, OK, | 103 RunSingleRoundAuthTest(RUN_HANDLER_ASYNC, ERR_MISSING_AUTH_CREDENTIALS, OK, |
104 SCHEME_IS_DISABLED); | 104 SCHEME_IS_DISABLED); |
105 | 105 |
106 // If a non-permanent error is returned by the handler, then the | 106 // If a non-permanent error is returned by the handler, then the |
107 // controller should report it unchanged. | 107 // controller should report it unchanged. |
108 RunSingleRoundAuthTest(RUN_HANDLER_ASYNC, ERR_INVALID_AUTH_CREDENTIALS, | 108 RunSingleRoundAuthTest(RUN_HANDLER_ASYNC, ERR_INVALID_AUTH_CREDENTIALS, |
109 ERR_INVALID_AUTH_CREDENTIALS, SCHEME_IS_ENABLED); | 109 ERR_INVALID_AUTH_CREDENTIALS, SCHEME_IS_ENABLED); |
110 } | 110 } |
111 | 111 |
112 } // namespace net | 112 } // namespace net |
OLD | NEW |