Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Side by Side Diff: net/http/http_auth_handler_unittest.cc

Issue 1084533002: Rename NetLogLogger and CapturingNetLog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename NetLogLogger and CapturingNetLog(removed compiler error for chromeOS) Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/cert/multi_log_ct_verifier_unittest.cc ('k') | net/http/http_cache_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/capturing_net_log.h"
15 #include "net/log/net_log_unittest.h" 14 #include "net/log/net_log_unittest.h"
15 #include "net/log/test_net_log.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 namespace net { 18 namespace net {
19 19
20 TEST(HttpAuthHandlerTest, NetLog) { 20 TEST(HttpAuthHandlerTest, NetLog) {
21 GURL origin("http://www.example.com"); 21 GURL origin("http://www.example.com");
22 std::string challenge = "Mock asdf"; 22 std::string challenge = "Mock asdf";
23 AuthCredentials credentials(base::ASCIIToUTF16("user"), 23 AuthCredentials credentials(base::ASCIIToUTF16("user"),
24 base::ASCIIToUTF16("pass")); 24 base::ASCIIToUTF16("pass"));
25 std::string auth_token; 25 std::string auth_token;
26 HttpRequestInfo request; 26 HttpRequestInfo request;
27 27
28 for (int i = 0; i < 2; ++i) { 28 for (int i = 0; i < 2; ++i) {
29 bool async = (i == 0); 29 bool async = (i == 0);
30 for (int j = 0; j < 2; ++j) { 30 for (int j = 0; j < 2; ++j) {
31 int rv = (j == 0) ? OK : ERR_UNEXPECTED; 31 int rv = (j == 0) ? OK : ERR_UNEXPECTED;
32 for (int k = 0; k < 2; ++k) { 32 for (int k = 0; k < 2; ++k) {
33 TestCompletionCallback test_callback; 33 TestCompletionCallback test_callback;
34 HttpAuth::Target target = 34 HttpAuth::Target target =
35 (k == 0) ? HttpAuth::AUTH_PROXY : HttpAuth::AUTH_SERVER; 35 (k == 0) ? HttpAuth::AUTH_PROXY : HttpAuth::AUTH_SERVER;
36 NetLog::EventType event_type = 36 NetLog::EventType event_type =
37 (k == 0) ? NetLog::TYPE_AUTH_PROXY : NetLog::TYPE_AUTH_SERVER; 37 (k == 0) ? NetLog::TYPE_AUTH_PROXY : NetLog::TYPE_AUTH_SERVER;
38 HttpAuthChallengeTokenizer tokenizer( 38 HttpAuthChallengeTokenizer tokenizer(
39 challenge.begin(), challenge.end()); 39 challenge.begin(), challenge.end());
40 HttpAuthHandlerMock mock_handler; 40 HttpAuthHandlerMock mock_handler;
41 CapturingNetLog capturing_net_log; 41 TestNetLog capturing_net_log;
42 BoundNetLog bound_net_log(BoundNetLog::Make(&capturing_net_log, 42 BoundNetLog bound_net_log(BoundNetLog::Make(&capturing_net_log,
43 net::NetLog::SOURCE_NONE)); 43 net::NetLog::SOURCE_NONE));
44 44
45 mock_handler.InitFromChallenge(&tokenizer, target, 45 mock_handler.InitFromChallenge(&tokenizer, target,
46 origin, bound_net_log); 46 origin, bound_net_log);
47 mock_handler.SetGenerateExpectation(async, rv); 47 mock_handler.SetGenerateExpectation(async, rv);
48 mock_handler.GenerateAuthToken(&credentials, &request, 48 mock_handler.GenerateAuthToken(&credentials, &request,
49 test_callback.callback(), &auth_token); 49 test_callback.callback(), &auth_token);
50 if (async) 50 if (async)
51 test_callback.WaitForResult(); 51 test_callback.WaitForResult();
52 52
53 CapturingNetLog::CapturedEntryList entries; 53 TestNetLog::CapturedEntryList entries;
54 capturing_net_log.GetEntries(&entries); 54 capturing_net_log.GetEntries(&entries);
55 55
56 EXPECT_EQ(2u, entries.size()); 56 EXPECT_EQ(2u, entries.size());
57 EXPECT_TRUE(LogContainsBeginEvent(entries, 0, event_type)); 57 EXPECT_TRUE(LogContainsBeginEvent(entries, 0, event_type));
58 EXPECT_TRUE(LogContainsEndEvent(entries, 1, event_type)); 58 EXPECT_TRUE(LogContainsEndEvent(entries, 1, event_type));
59 } 59 }
60 } 60 }
61 } 61 }
62 } 62 }
63 63
64 } // namespace net 64 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/multi_log_ct_verifier_unittest.cc ('k') | net/http/http_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698