[Presentation API] Plumbing of |onstatechange| from the Mojo service to the public...
[chromium-blink-merge.git] / net / http / http_log_util_unittest.cc
blobdd6af698787c9b1d77728c7d29b26eb37f6c94b9
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]", ElideHeaderValueForNetLog(
13 NetLog::LOG_STRIP_PRIVATE_DATA, "Cookie", "name=value"));
14 EXPECT_EQ("name=value", ElideHeaderValueForNetLog(
15 NetLog::LOG_ALL_BUT_BYTES, "Cookie", "name=value"));
17 // Headers are compared case insensitively.
18 EXPECT_EQ("[10 bytes were stripped]", ElideHeaderValueForNetLog(
19 NetLog::LOG_STRIP_PRIVATE_DATA, "cOoKiE", "name=value"));
21 // These headers should be completely elided.
22 EXPECT_EQ("[10 bytes were stripped]", ElideHeaderValueForNetLog(
23 NetLog::LOG_STRIP_PRIVATE_DATA, "Set-Cookie", "name=value"));
24 EXPECT_EQ("[10 bytes were stripped]", ElideHeaderValueForNetLog(
25 NetLog::LOG_STRIP_PRIVATE_DATA, "Set-Cookie2", "name=value"));
26 EXPECT_EQ("[10 bytes were stripped]", ElideHeaderValueForNetLog(
27 NetLog::LOG_STRIP_PRIVATE_DATA, "Authorization", "Basic 1234"));
28 EXPECT_EQ("[10 bytes were stripped]", ElideHeaderValueForNetLog(
29 NetLog::LOG_STRIP_PRIVATE_DATA, "Proxy-Authorization", "Basic 1234"));
31 // Unknown headers should pass through.
32 EXPECT_EQ("value", ElideHeaderValueForNetLog(
33 NetLog::LOG_STRIP_PRIVATE_DATA, "Boring", "value"));
35 // Basic and Digest auth challenges are public.
36 EXPECT_EQ("Basic realm=test", ElideHeaderValueForNetLog(
37 NetLog::LOG_STRIP_PRIVATE_DATA, "WWW-Authenticate", "Basic realm=test"));
38 EXPECT_EQ("Digest realm=test", ElideHeaderValueForNetLog(
39 NetLog::LOG_STRIP_PRIVATE_DATA, "WWW-Authenticate", "Digest realm=test"));
40 EXPECT_EQ("Basic realm=test", ElideHeaderValueForNetLog(
41 NetLog::LOG_STRIP_PRIVATE_DATA,
42 "Proxy-Authenticate", "Basic realm=test"));
43 EXPECT_EQ("Digest realm=test", ElideHeaderValueForNetLog(
44 NetLog::LOG_STRIP_PRIVATE_DATA,
45 "Proxy-Authenticate", "Digest realm=test"));
47 // Multi-round mechanisms partially elided.
48 EXPECT_EQ("NTLM [4 bytes were stripped]", ElideHeaderValueForNetLog(
49 NetLog::LOG_STRIP_PRIVATE_DATA, "WWW-Authenticate", "NTLM 1234"));
50 EXPECT_EQ("NTLM [4 bytes were stripped]", ElideHeaderValueForNetLog(
51 NetLog::LOG_STRIP_PRIVATE_DATA, "Proxy-Authenticate", "NTLM 1234"));
53 // Leave whitespace intact.
54 EXPECT_EQ("NTLM [4 bytes were stripped] ", ElideHeaderValueForNetLog(
55 NetLog::LOG_STRIP_PRIVATE_DATA, "WWW-Authenticate", "NTLM 1234 "));
58 } // namspace net