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

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

Issue 361053002: Elide data reduction proxy credentials from NetLog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comment Created 6 years, 5 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
« net/http/http_log_util.cc ('K') | « net/http/http_log_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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_log_util.h" 5 #include "net/http/http_log_util.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 7
8 namespace net { 8 namespace net {
9 9
10 TEST(HttpLogUtilTest, ElideHeaderValueForNetLog) { 10 TEST(HttpLogUtilTest, ElideHeaderValueForNetLog) {
11 // Only elide for appropriate log level. 11 // Only elide for appropriate log level.
12 EXPECT_EQ("[10 bytes were stripped]", ElideHeaderValueForNetLog( 12 EXPECT_EQ("[10 bytes were stripped]", ElideHeaderValueForNetLog(
13 net::NetLog::LOG_STRIP_PRIVATE_DATA, "Cookie", "name=value")); 13 net::NetLog::LOG_STRIP_PRIVATE_DATA, "Cookie", "name=value"));
mmenke 2014/07/02 18:34:25 Hrm...while you're here, mind removing all the net
bengr 2014/07/02 19:31:58 Done.
14 EXPECT_EQ("name=value", ElideHeaderValueForNetLog( 14 EXPECT_EQ("name=value", ElideHeaderValueForNetLog(
15 net::NetLog::LOG_ALL_BUT_BYTES, "Cookie", "name=value")); 15 net::NetLog::LOG_ALL_BUT_BYTES, "Cookie", "name=value"));
16 16
17 // Headers are compared case insensitively. 17 // Headers are compared case insensitively.
18 EXPECT_EQ("[10 bytes were stripped]", ElideHeaderValueForNetLog( 18 EXPECT_EQ("[10 bytes were stripped]", ElideHeaderValueForNetLog(
19 net::NetLog::LOG_STRIP_PRIVATE_DATA, "cOoKiE", "name=value")); 19 net::NetLog::LOG_STRIP_PRIVATE_DATA, "cOoKiE", "name=value"));
20 20
21 // These headers should be completely elided. 21 // These headers should be completely elided.
22 EXPECT_EQ("[10 bytes were stripped]", ElideHeaderValueForNetLog( 22 EXPECT_EQ("[10 bytes were stripped]", ElideHeaderValueForNetLog(
23 net::NetLog::LOG_STRIP_PRIVATE_DATA, "Set-Cookie", "name=value")); 23 net::NetLog::LOG_STRIP_PRIVATE_DATA, "Set-Cookie", "name=value"));
24 EXPECT_EQ("[10 bytes were stripped]", ElideHeaderValueForNetLog( 24 EXPECT_EQ("[10 bytes were stripped]", ElideHeaderValueForNetLog(
25 net::NetLog::LOG_STRIP_PRIVATE_DATA, "Set-Cookie2", "name=value")); 25 net::NetLog::LOG_STRIP_PRIVATE_DATA, "Set-Cookie2", "name=value"));
26 EXPECT_EQ("[10 bytes were stripped]", ElideHeaderValueForNetLog( 26 EXPECT_EQ("[10 bytes were stripped]", ElideHeaderValueForNetLog(
27 net::NetLog::LOG_STRIP_PRIVATE_DATA, "Authorization", "Basic 1234")); 27 net::NetLog::LOG_STRIP_PRIVATE_DATA, "Authorization", "Basic 1234"));
28 #if !defined(SPDY_PROXY_AUTH_ORIGIN)
29 EXPECT_EQ("[10 bytes were stripped]", ElideHeaderValueForNetLog(
30 net::NetLog::LOG_STRIP_PRIVATE_DATA,
31 "Proxy-Authorization", "Basic 1234"));
32 #endif
33 28
34 // Unknown headers should pass through. 29 // Unknown headers should pass through.
35 EXPECT_EQ("value", ElideHeaderValueForNetLog( 30 EXPECT_EQ("value", ElideHeaderValueForNetLog(
36 net::NetLog::LOG_STRIP_PRIVATE_DATA, "Boring", "value")); 31 net::NetLog::LOG_STRIP_PRIVATE_DATA, "Boring", "value"));
37 32
38 // Basic and Digest auth challenges are public. 33 // Basic and Digest auth challenges are public.
39 EXPECT_EQ("Basic realm=test", ElideHeaderValueForNetLog( 34 EXPECT_EQ("Basic realm=test", ElideHeaderValueForNetLog(
40 net::NetLog::LOG_STRIP_PRIVATE_DATA, 35 net::NetLog::LOG_STRIP_PRIVATE_DATA,
41 "WWW-Authenticate", "Basic realm=test")); 36 "WWW-Authenticate", "Basic realm=test"));
42 EXPECT_EQ("Digest realm=test", ElideHeaderValueForNetLog( 37 EXPECT_EQ("Digest realm=test", ElideHeaderValueForNetLog(
43 net::NetLog::LOG_STRIP_PRIVATE_DATA, 38 net::NetLog::LOG_STRIP_PRIVATE_DATA,
44 "WWW-Authenticate", "Digest realm=test")); 39 "WWW-Authenticate", "Digest realm=test"));
45 #if !defined(SPDY_PROXY_AUTH_ORIGIN)
46 EXPECT_EQ("Basic realm=test", ElideHeaderValueForNetLog(
47 net::NetLog::LOG_STRIP_PRIVATE_DATA,
48 "Proxy-Authenticate", "Basic realm=test"));
49 EXPECT_EQ("Digest realm=test", ElideHeaderValueForNetLog(
50 net::NetLog::LOG_STRIP_PRIVATE_DATA,
51 "Proxy-Authenticate", "Digest realm=test"));
52 #endif
53 40
54 // Multi-round mechanisms partially elided. 41 // Multi-round mechanisms partially elided.
55 EXPECT_EQ("NTLM [4 bytes were stripped]", ElideHeaderValueForNetLog( 42 EXPECT_EQ("NTLM [4 bytes were stripped]", ElideHeaderValueForNetLog(
56 net::NetLog::LOG_STRIP_PRIVATE_DATA, "WWW-Authenticate", "NTLM 1234")); 43 net::NetLog::LOG_STRIP_PRIVATE_DATA, "WWW-Authenticate", "NTLM 1234"));
57 #if !defined(SPDY_PROXY_AUTH_ORIGIN)
mmenke 2014/07/02 18:34:25 These !defined cases shouldn't be deleted, but jus
bengr 2014/07/02 19:31:58 Done.
58 EXPECT_EQ("NTLM [4 bytes were stripped]", ElideHeaderValueForNetLog(
59 net::NetLog::LOG_STRIP_PRIVATE_DATA, "Proxy-Authenticate", "NTLM 1234"));
60 #endif
61 44
62 // Leave whitespace intact. 45 // Leave whitespace intact.
63 EXPECT_EQ("NTLM [4 bytes were stripped] ", ElideHeaderValueForNetLog( 46 EXPECT_EQ("NTLM [4 bytes were stripped] ", ElideHeaderValueForNetLog(
64 net::NetLog::LOG_STRIP_PRIVATE_DATA, "WWW-Authenticate", "NTLM 1234 ")); 47 net::NetLog::LOG_STRIP_PRIVATE_DATA, "WWW-Authenticate", "NTLM 1234 "));
65 48
66 // Extra elisions for SPDY_PROXY_AUTH_ORIGIN. 49 // Extra elisions for SPDY_PROXY_AUTH_ORIGIN.
67 #if defined(SPDY_PROXY_AUTH_ORIGIN) 50 #if defined(SPDY_PROXY_AUTH_ORIGIN)
68 EXPECT_EQ("[elided]", ElideHeaderValueForNetLog( 51 EXPECT_EQ("ps=123, [7 bytes were stripped], c=foo, v=bar",
69 net::NetLog::LOG_ALL_BUT_BYTES, 52 ElideHeaderValueForNetLog(
70 "Proxy-Authenticate", "Basic realm=test")); 53 net::NetLog::LOG_STRIP_PRIVATE_DATA,
71 EXPECT_EQ("[elided]", ElideHeaderValueForNetLog( 54 "Chrome-Proxy", "ps=123, sid=456, c=foo, v=bar"));
mmenke 2014/07/02 18:34:25 The indentation here is weird. Suggest indenting
mmenke 2014/07/02 18:34:25 Just for the sake of completeness, suggest tests w
bengr 2014/07/02 19:31:58 Done.
bengr 2014/07/02 19:31:58 Done.
72 net::NetLog::LOG_ALL_BUT_BYTES, "Proxy-Authorization", "Basic 1234"));
73 #endif 55 #endif
74 } 56 }
75 57
76 } // namspace net 58 } // namspace net
OLDNEW
« net/http/http_log_util.cc ('K') | « net/http/http_log_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698