| 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.h" | 5 #include "net/http/http_auth_handler.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/capturing_net_log.h" | 9 #include "net/base/capturing_net_log.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 int rv = (j == 0) ? OK : ERR_UNEXPECTED; | 29 int rv = (j == 0) ? OK : ERR_UNEXPECTED; |
| 30 for (int k = 0; k < 2; ++k) { | 30 for (int k = 0; k < 2; ++k) { |
| 31 TestCompletionCallback test_callback; | 31 TestCompletionCallback test_callback; |
| 32 HttpAuth::Target target = | 32 HttpAuth::Target target = |
| 33 (k == 0) ? HttpAuth::AUTH_PROXY : HttpAuth::AUTH_SERVER; | 33 (k == 0) ? HttpAuth::AUTH_PROXY : HttpAuth::AUTH_SERVER; |
| 34 NetLog::EventType event_type = | 34 NetLog::EventType event_type = |
| 35 (k == 0) ? NetLog::TYPE_AUTH_PROXY : NetLog::TYPE_AUTH_SERVER; | 35 (k == 0) ? NetLog::TYPE_AUTH_PROXY : NetLog::TYPE_AUTH_SERVER; |
| 36 HttpAuth::ChallengeTokenizer tokenizer( | 36 HttpAuth::ChallengeTokenizer tokenizer( |
| 37 challenge.begin(), challenge.end()); | 37 challenge.begin(), challenge.end()); |
| 38 HttpAuthHandlerMock mock_handler; | 38 HttpAuthHandlerMock mock_handler; |
| 39 CapturingNetLog capturing_net_log(CapturingNetLog::kUnbounded); | 39 CapturingNetLog capturing_net_log; |
| 40 BoundNetLog bound_net_log(BoundNetLog::Make(&capturing_net_log, | 40 BoundNetLog bound_net_log(BoundNetLog::Make(&capturing_net_log, |
| 41 net::NetLog::SOURCE_NONE)); | 41 net::NetLog::SOURCE_NONE)); |
| 42 | 42 |
| 43 mock_handler.InitFromChallenge(&tokenizer, target, | 43 mock_handler.InitFromChallenge(&tokenizer, target, |
| 44 origin, bound_net_log); | 44 origin, bound_net_log); |
| 45 mock_handler.SetGenerateExpectation(async, rv); | 45 mock_handler.SetGenerateExpectation(async, rv); |
| 46 mock_handler.GenerateAuthToken(&credentials, &request, | 46 mock_handler.GenerateAuthToken(&credentials, &request, |
| 47 test_callback.callback(), &auth_token); | 47 test_callback.callback(), &auth_token); |
| 48 if (async) | 48 if (async) |
| 49 test_callback.WaitForResult(); | 49 test_callback.WaitForResult(); |
| 50 | 50 |
| 51 net::CapturingNetLog::CapturedEntryList entries; | 51 CapturingNetLog::CapturedEntryList entries; |
| 52 capturing_net_log.GetEntries(&entries); | 52 capturing_net_log.GetEntries(&entries); |
| 53 | 53 |
| 54 EXPECT_EQ(2u, entries.size()); | 54 EXPECT_EQ(2u, entries.size()); |
| 55 EXPECT_TRUE(LogContainsBeginEvent(entries, 0, event_type)); | 55 EXPECT_TRUE(LogContainsBeginEvent(entries, 0, event_type)); |
| 56 EXPECT_TRUE(LogContainsEndEvent(entries, 1, event_type)); | 56 EXPECT_TRUE(LogContainsEndEvent(entries, 1, event_type)); |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 } // namespace net | 62 } // namespace net |
| OLD | NEW |