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/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 #include "net/base/test_completion_callback.h" | 10 #include "net/base/test_completion_callback.h" |
11 #include "net/http/http_auth_challenge_tokenizer.h" | 11 #include "net/http/http_auth_challenge_tokenizer.h" |
12 #include "net/http/http_auth_handler_mock.h" | 12 #include "net/http/http_auth_handler_mock.h" |
13 #include "net/http/http_request_info.h" | 13 #include "net/http/http_request_info.h" |
| 14 #include "net/log/captured_net_log_entry.h" |
14 #include "net/log/net_log_unittest.h" | 15 #include "net/log/net_log_unittest.h" |
15 #include "net/log/test_net_log.h" | 16 #include "net/log/test_net_log.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 | 18 |
18 namespace net { | 19 namespace net { |
19 | 20 |
20 TEST(HttpAuthHandlerTest, NetLog) { | 21 TEST(HttpAuthHandlerTest, NetLog) { |
21 GURL origin("http://www.example.com"); | 22 GURL origin("http://www.example.com"); |
22 std::string challenge = "Mock asdf"; | 23 std::string challenge = "Mock asdf"; |
23 AuthCredentials credentials(base::ASCIIToUTF16("user"), | 24 AuthCredentials credentials(base::ASCIIToUTF16("user"), |
(...skipping 19 matching lines...) Expand all Loading... |
43 BoundNetLog::Make(&capturing_net_log, NetLog::SOURCE_NONE)); | 44 BoundNetLog::Make(&capturing_net_log, NetLog::SOURCE_NONE)); |
44 | 45 |
45 mock_handler.InitFromChallenge(&tokenizer, target, | 46 mock_handler.InitFromChallenge(&tokenizer, target, |
46 origin, bound_net_log); | 47 origin, bound_net_log); |
47 mock_handler.SetGenerateExpectation(async, rv); | 48 mock_handler.SetGenerateExpectation(async, rv); |
48 mock_handler.GenerateAuthToken(&credentials, &request, | 49 mock_handler.GenerateAuthToken(&credentials, &request, |
49 test_callback.callback(), &auth_token); | 50 test_callback.callback(), &auth_token); |
50 if (async) | 51 if (async) |
51 test_callback.WaitForResult(); | 52 test_callback.WaitForResult(); |
52 | 53 |
53 TestNetLog::CapturedEntryList entries; | 54 CapturedNetLogEntry::List entries; |
54 capturing_net_log.GetEntries(&entries); | 55 capturing_net_log.GetEntries(&entries); |
55 | 56 |
56 EXPECT_EQ(2u, entries.size()); | 57 EXPECT_EQ(2u, entries.size()); |
57 EXPECT_TRUE(LogContainsBeginEvent(entries, 0, event_type)); | 58 EXPECT_TRUE(LogContainsBeginEvent(entries, 0, event_type)); |
58 EXPECT_TRUE(LogContainsEndEvent(entries, 1, event_type)); | 59 EXPECT_TRUE(LogContainsEndEvent(entries, 1, event_type)); |
59 } | 60 } |
60 } | 61 } |
61 } | 62 } |
62 } | 63 } |
63 | 64 |
64 } // namespace net | 65 } // namespace net |
OLD | NEW |