Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / net / http / http_log_util_unittest.cc
blobbd9c79f0680d92bea60e602a6d087ae4a6a38b15
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/http/http_log_util.h"
6 #include "testing/gtest/include/gtest/gtest.h"
8 namespace net {
10 TEST(HttpLogUtilTest, ElideHeaderValueForNetLog) {
11 // Only elide for appropriate log level.
12 EXPECT_EQ("[10 bytes were stripped]",
13 ElideHeaderValueForNetLog(NetLogCaptureMode::Default(), "Cookie",
14 "name=value"));
15 EXPECT_EQ("name=value", ElideHeaderValueForNetLog(
16 NetLogCaptureMode::IncludeCookiesAndCredentials(),
17 "Cookie", "name=value"));
19 // Headers are compared case insensitively.
20 EXPECT_EQ("[10 bytes were stripped]",
21 ElideHeaderValueForNetLog(NetLogCaptureMode::Default(), "cOoKiE",
22 "name=value"));
24 // These headers should be completely elided.
25 EXPECT_EQ("[10 bytes were stripped]",
26 ElideHeaderValueForNetLog(NetLogCaptureMode::Default(),
27 "Set-Cookie", "name=value"));
28 EXPECT_EQ("[10 bytes were stripped]",
29 ElideHeaderValueForNetLog(NetLogCaptureMode::Default(),
30 "Set-Cookie2", "name=value"));
31 EXPECT_EQ("[10 bytes were stripped]",
32 ElideHeaderValueForNetLog(NetLogCaptureMode::Default(),
33 "Authorization", "Basic 1234"));
34 EXPECT_EQ("[10 bytes were stripped]",
35 ElideHeaderValueForNetLog(NetLogCaptureMode::Default(),
36 "Proxy-Authorization", "Basic 1234"));
38 // Unknown headers should pass through.
39 EXPECT_EQ("value", ElideHeaderValueForNetLog(NetLogCaptureMode::Default(),
40 "Boring", "value"));
42 // Basic and Digest auth challenges are public.
43 EXPECT_EQ("Basic realm=test",
44 ElideHeaderValueForNetLog(NetLogCaptureMode::Default(),
45 "WWW-Authenticate", "Basic realm=test"));
46 EXPECT_EQ("Digest realm=test",
47 ElideHeaderValueForNetLog(NetLogCaptureMode::Default(),
48 "WWW-Authenticate", "Digest realm=test"));
49 EXPECT_EQ("Basic realm=test", ElideHeaderValueForNetLog(
50 NetLogCaptureMode::Default(),
51 "Proxy-Authenticate", "Basic realm=test"));
52 EXPECT_EQ(
53 "Digest realm=test",
54 ElideHeaderValueForNetLog(NetLogCaptureMode::Default(),
55 "Proxy-Authenticate", "Digest realm=test"));
57 // Multi-round mechanisms partially elided.
58 EXPECT_EQ("NTLM [4 bytes were stripped]",
59 ElideHeaderValueForNetLog(NetLogCaptureMode::Default(),
60 "WWW-Authenticate", "NTLM 1234"));
61 EXPECT_EQ("NTLM [4 bytes were stripped]",
62 ElideHeaderValueForNetLog(NetLogCaptureMode::Default(),
63 "Proxy-Authenticate", "NTLM 1234"));
65 // Leave whitespace intact.
66 EXPECT_EQ("NTLM [4 bytes were stripped] ",
67 ElideHeaderValueForNetLog(NetLogCaptureMode::Default(),
68 "WWW-Authenticate", "NTLM 1234 "));
71 } // namspace net