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

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

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 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 | Annotate | Revision Log
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 "base/base64.h" 5 #include "base/base64.h"
6 #include "base/sha1.h" 6 #include "base/sha1.h"
7 #include "base/string_piece.h" 7 #include "base/string_piece.h"
8 #include "crypto/sha2.h" 8 #include "crypto/sha2.h"
9 #include "net/base/net_log.h" 9 #include "net/base/net_log.h"
10 #include "net/base/test_completion_callback.h" 10 #include "net/base/test_completion_callback.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 class HttpSecurityHeadersTest : public testing::Test { 45 class HttpSecurityHeadersTest : public testing::Test {
46 }; 46 };
47 47
48 48
49 TEST_F(HttpSecurityHeadersTest, BogusHeaders) { 49 TEST_F(HttpSecurityHeadersTest, BogusHeaders) {
50 base::Time now = base::Time::Now(); 50 base::Time now = base::Time::Now();
51 base::Time expiry = now; 51 base::Time expiry = now;
52 bool include_subdomains = false; 52 bool include_subdomains = false;
53 53
54 EXPECT_FALSE(ParseHSTSHeader(now, "", &expiry, &include_subdomains)); 54 EXPECT_FALSE(
55 ParseHSTSHeader(now, std::string(), &expiry, &include_subdomains));
55 EXPECT_FALSE(ParseHSTSHeader(now, " ", &expiry, &include_subdomains)); 56 EXPECT_FALSE(ParseHSTSHeader(now, " ", &expiry, &include_subdomains));
56 EXPECT_FALSE(ParseHSTSHeader(now, "abc", &expiry, &include_subdomains)); 57 EXPECT_FALSE(ParseHSTSHeader(now, "abc", &expiry, &include_subdomains));
57 EXPECT_FALSE(ParseHSTSHeader(now, " abc", &expiry, &include_subdomains)); 58 EXPECT_FALSE(ParseHSTSHeader(now, " abc", &expiry, &include_subdomains));
58 EXPECT_FALSE(ParseHSTSHeader(now, " abc ", &expiry, &include_subdomains)); 59 EXPECT_FALSE(ParseHSTSHeader(now, " abc ", &expiry, &include_subdomains));
59 EXPECT_FALSE(ParseHSTSHeader(now, "max-age", &expiry, &include_subdomains)); 60 EXPECT_FALSE(ParseHSTSHeader(now, "max-age", &expiry, &include_subdomains));
60 EXPECT_FALSE(ParseHSTSHeader(now, " max-age", &expiry, 61 EXPECT_FALSE(ParseHSTSHeader(now, " max-age", &expiry,
61 &include_subdomains)); 62 &include_subdomains));
62 EXPECT_FALSE(ParseHSTSHeader(now, " max-age ", &expiry, 63 EXPECT_FALSE(ParseHSTSHeader(now, " max-age ", &expiry,
63 &include_subdomains)); 64 &include_subdomains));
64 EXPECT_FALSE(ParseHSTSHeader(now, "max-age=", &expiry, &include_subdomains)); 65 EXPECT_FALSE(ParseHSTSHeader(now, "max-age=", &expiry, &include_subdomains));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 129
129 // Set some fake "chain" hashes 130 // Set some fake "chain" hashes
130 chain_hashes.push_back(GetTestHashValue(1, tag)); 131 chain_hashes.push_back(GetTestHashValue(1, tag));
131 chain_hashes.push_back(GetTestHashValue(2, tag)); 132 chain_hashes.push_back(GetTestHashValue(2, tag));
132 chain_hashes.push_back(GetTestHashValue(3, tag)); 133 chain_hashes.push_back(GetTestHashValue(3, tag));
133 134
134 // The good pin must be in the chain, the backup pin must not be 135 // The good pin must be in the chain, the backup pin must not be
135 std::string good_pin = GetTestPin(2, tag); 136 std::string good_pin = GetTestPin(2, tag);
136 std::string backup_pin = GetTestPin(4, tag); 137 std::string backup_pin = GetTestPin(4, tag);
137 138
138 EXPECT_FALSE(ParseHPKPHeader(now, "", chain_hashes, &expiry, &hashes)); 139 EXPECT_FALSE(
140 ParseHPKPHeader(now, std::string(), chain_hashes, &expiry, &hashes));
139 EXPECT_FALSE(ParseHPKPHeader(now, " ", chain_hashes, &expiry, &hashes)); 141 EXPECT_FALSE(ParseHPKPHeader(now, " ", chain_hashes, &expiry, &hashes));
140 EXPECT_FALSE(ParseHPKPHeader(now, "abc", chain_hashes, &expiry, &hashes)); 142 EXPECT_FALSE(ParseHPKPHeader(now, "abc", chain_hashes, &expiry, &hashes));
141 EXPECT_FALSE(ParseHPKPHeader(now, " abc", chain_hashes, &expiry, &hashes)); 143 EXPECT_FALSE(ParseHPKPHeader(now, " abc", chain_hashes, &expiry, &hashes));
142 EXPECT_FALSE(ParseHPKPHeader(now, " abc ", chain_hashes, &expiry, 144 EXPECT_FALSE(ParseHPKPHeader(now, " abc ", chain_hashes, &expiry,
143 &hashes)); 145 &hashes));
144 EXPECT_FALSE(ParseHPKPHeader(now, "max-age", chain_hashes, &expiry, 146 EXPECT_FALSE(ParseHPKPHeader(now, "max-age", chain_hashes, &expiry,
145 &hashes)); 147 &hashes));
146 EXPECT_FALSE(ParseHPKPHeader(now, " max-age", chain_hashes, &expiry, 148 EXPECT_FALSE(ParseHPKPHeader(now, " max-age", chain_hashes, &expiry,
147 &hashes)); 149 &hashes));
148 EXPECT_FALSE(ParseHPKPHeader(now, " max-age ", chain_hashes, &expiry, 150 EXPECT_FALSE(ParseHPKPHeader(now, " max-age ", chain_hashes, &expiry,
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 417
416 TEST_F(HttpSecurityHeadersTest, ValidPinsHeadersSHA1) { 418 TEST_F(HttpSecurityHeadersTest, ValidPinsHeadersSHA1) {
417 TestValidPinsHeaders(HASH_VALUE_SHA1); 419 TestValidPinsHeaders(HASH_VALUE_SHA1);
418 } 420 }
419 421
420 TEST_F(HttpSecurityHeadersTest, ValidPinsHeadersSHA256) { 422 TEST_F(HttpSecurityHeadersTest, ValidPinsHeadersSHA256) {
421 TestValidPinsHeaders(HASH_VALUE_SHA256); 423 TestValidPinsHeaders(HASH_VALUE_SHA256);
422 } 424 }
423 }; 425 };
424 426
OLDNEW
« no previous file with comments | « net/http/http_proxy_client_socket_pool_spdy3_unittest.cc ('k') | net/http/http_server_properties_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698