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

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 comments 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
« no previous file with comments | « 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 NetLog::LOG_STRIP_PRIVATE_DATA, "Cookie", "name=value"));
14 EXPECT_EQ("name=value", ElideHeaderValueForNetLog( 14 EXPECT_EQ("name=value", ElideHeaderValueForNetLog(
15 net::NetLog::LOG_ALL_BUT_BYTES, "Cookie", "name=value")); 15 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 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 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 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 NetLog::LOG_STRIP_PRIVATE_DATA, "Authorization", "Basic 1234"));
28 #if !defined(SPDY_PROXY_AUTH_ORIGIN)
29 EXPECT_EQ("[10 bytes were stripped]", ElideHeaderValueForNetLog( 28 EXPECT_EQ("[10 bytes were stripped]", ElideHeaderValueForNetLog(
30 net::NetLog::LOG_STRIP_PRIVATE_DATA, 29 NetLog::LOG_STRIP_PRIVATE_DATA, "Proxy-Authorization", "Basic 1234"));
31 "Proxy-Authorization", "Basic 1234"));
32 #endif
33 30
34 // Unknown headers should pass through. 31 // Unknown headers should pass through.
35 EXPECT_EQ("value", ElideHeaderValueForNetLog( 32 EXPECT_EQ("value", ElideHeaderValueForNetLog(
36 net::NetLog::LOG_STRIP_PRIVATE_DATA, "Boring", "value")); 33 NetLog::LOG_STRIP_PRIVATE_DATA, "Boring", "value"));
37 34
38 // Basic and Digest auth challenges are public. 35 // Basic and Digest auth challenges are public.
39 EXPECT_EQ("Basic realm=test", ElideHeaderValueForNetLog( 36 EXPECT_EQ("Basic realm=test", ElideHeaderValueForNetLog(
40 net::NetLog::LOG_STRIP_PRIVATE_DATA, 37 NetLog::LOG_STRIP_PRIVATE_DATA, "WWW-Authenticate", "Basic realm=test"));
41 "WWW-Authenticate", "Basic realm=test"));
42 EXPECT_EQ("Digest realm=test", ElideHeaderValueForNetLog( 38 EXPECT_EQ("Digest realm=test", ElideHeaderValueForNetLog(
43 net::NetLog::LOG_STRIP_PRIVATE_DATA, 39 NetLog::LOG_STRIP_PRIVATE_DATA, "WWW-Authenticate", "Digest realm=test"));
44 "WWW-Authenticate", "Digest realm=test"));
45 #if !defined(SPDY_PROXY_AUTH_ORIGIN)
46 EXPECT_EQ("Basic realm=test", ElideHeaderValueForNetLog( 40 EXPECT_EQ("Basic realm=test", ElideHeaderValueForNetLog(
47 net::NetLog::LOG_STRIP_PRIVATE_DATA, 41 NetLog::LOG_STRIP_PRIVATE_DATA,
48 "Proxy-Authenticate", "Basic realm=test")); 42 "Proxy-Authenticate", "Basic realm=test"));
49 EXPECT_EQ("Digest realm=test", ElideHeaderValueForNetLog( 43 EXPECT_EQ("Digest realm=test", ElideHeaderValueForNetLog(
50 net::NetLog::LOG_STRIP_PRIVATE_DATA, 44 NetLog::LOG_STRIP_PRIVATE_DATA,
51 "Proxy-Authenticate", "Digest realm=test")); 45 "Proxy-Authenticate", "Digest realm=test"));
52 #endif
53 46
54 // Multi-round mechanisms partially elided. 47 // Multi-round mechanisms partially elided.
55 EXPECT_EQ("NTLM [4 bytes were stripped]", ElideHeaderValueForNetLog( 48 EXPECT_EQ("NTLM [4 bytes were stripped]", ElideHeaderValueForNetLog(
56 net::NetLog::LOG_STRIP_PRIVATE_DATA, "WWW-Authenticate", "NTLM 1234")); 49 NetLog::LOG_STRIP_PRIVATE_DATA, "WWW-Authenticate", "NTLM 1234"));
57 #if !defined(SPDY_PROXY_AUTH_ORIGIN)
58 EXPECT_EQ("NTLM [4 bytes were stripped]", ElideHeaderValueForNetLog( 50 EXPECT_EQ("NTLM [4 bytes were stripped]", ElideHeaderValueForNetLog(
59 net::NetLog::LOG_STRIP_PRIVATE_DATA, "Proxy-Authenticate", "NTLM 1234")); 51 NetLog::LOG_STRIP_PRIVATE_DATA, "Proxy-Authenticate", "NTLM 1234"));
60 #endif
61 52
62 // Leave whitespace intact. 53 // Leave whitespace intact.
63 EXPECT_EQ("NTLM [4 bytes were stripped] ", ElideHeaderValueForNetLog( 54 EXPECT_EQ("NTLM [4 bytes were stripped] ", ElideHeaderValueForNetLog(
64 net::NetLog::LOG_STRIP_PRIVATE_DATA, "WWW-Authenticate", "NTLM 1234 ")); 55 NetLog::LOG_STRIP_PRIVATE_DATA, "WWW-Authenticate", "NTLM 1234 "));
65 56
66 // Extra elisions for SPDY_PROXY_AUTH_ORIGIN. 57 // Extra elisions for SPDY_PROXY_AUTH_ORIGIN.
67 #if defined(SPDY_PROXY_AUTH_ORIGIN) 58 #if defined(SPDY_PROXY_AUTH_ORIGIN)
68 EXPECT_EQ("[elided]", ElideHeaderValueForNetLog( 59 EXPECT_EQ("ps=123, [7 bytes were stripped], c=foo, v=bar",
69 net::NetLog::LOG_ALL_BUT_BYTES, 60 ElideHeaderValueForNetLog(
70 "Proxy-Authenticate", "Basic realm=test")); 61 NetLog::LOG_STRIP_PRIVATE_DATA,
71 EXPECT_EQ("[elided]", ElideHeaderValueForNetLog( 62 "Chrome-Proxy", "ps=123, sid=456, c=foo, v=bar"));
72 net::NetLog::LOG_ALL_BUT_BYTES, "Proxy-Authorization", "Basic 1234")); 63 EXPECT_EQ("[7 bytes were stripped], ps=123, c=foo, v=bar",
64 ElideHeaderValueForNetLog(
65 NetLog::LOG_STRIP_PRIVATE_DATA,
66 "Chrome-Proxy", "sid=456, ps=123, c=foo, v=bar"));
67 EXPECT_EQ("ps=123, c=foo, v=bar, [7 bytes were stripped]",
68 ElideHeaderValueForNetLog(
69 NetLog::LOG_STRIP_PRIVATE_DATA,
70 "Chrome-Proxy", "ps=123, c=foo, v=bar, sid=456"));
73 #endif 71 #endif
74 } 72 }
75 73
76 } // namspace net 74 } // namspace net
OLDNEW
« no previous file with comments | « net/http/http_log_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698