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

Side by Side Diff: net/quic/crypto/properties_based_quic_server_info_test.cc

Issue 1818393003: QUIC - Persist "Hash of the CHLO message" and "Signed timestamp of the (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Default chlo_hash to empty string for old disk cache data Created 4 years, 9 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/quic/crypto/properties_based_quic_server_info.h" 5 #include "net/quic/crypto/properties_based_quic_server_info.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/http/http_server_properties_impl.h" 10 #include "net/http/http_server_properties_impl.h"
11 #include "net/quic/crypto/quic_server_info.h" 11 #include "net/quic/crypto/quic_server_info.h"
12 #include "net/quic/quic_server_id.h" 12 #include "net/quic/quic_server_id.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace net { 15 namespace net {
16 namespace test { 16 namespace test {
17 17
18 namespace { 18 namespace {
19 const std::string kServerConfigA("server_config_a"); 19 const std::string kServerConfigA("server_config_a");
20 const std::string kSourceAddressTokenA("source_address_token_a"); 20 const std::string kSourceAddressTokenA("source_address_token_a");
21 const std::string kCertSCTA("cert_sct_a");
22 const std::string kChloHashA("chlo_hash_a");
21 const std::string kServerConfigSigA("server_config_sig_a"); 23 const std::string kServerConfigSigA("server_config_sig_a");
22 const std::string kCertA("cert_a"); 24 const std::string kCertA("cert_a");
23 const std::string kCertB("cert_b"); 25 const std::string kCertB("cert_b");
24 } // namespace 26 } // namespace
25 27
26 class PropertiesBasedQuicServerInfoTest : public ::testing::Test { 28 class PropertiesBasedQuicServerInfoTest : public ::testing::Test {
27 protected: 29 protected:
28 PropertiesBasedQuicServerInfoTest() 30 PropertiesBasedQuicServerInfoTest()
29 : server_id_("www.google.com", 443, PRIVACY_MODE_DISABLED), 31 : server_id_("www.google.com", 443, PRIVACY_MODE_DISABLED),
30 server_info_(server_id_, http_server_properties_.GetWeakPtr()) {} 32 server_info_(server_id_, http_server_properties_.GetWeakPtr()) {}
31 33
32 // Initialize |server_info_| object and persist it. 34 // Initialize |server_info_| object and persist it.
33 void InitializeAndPersist() { 35 void InitializeAndPersist() {
34 server_info_.Start(); 36 server_info_.Start();
35 EXPECT_TRUE(server_info_.IsDataReady()); 37 EXPECT_TRUE(server_info_.IsDataReady());
36 QuicServerInfo::State* state = server_info_.mutable_state(); 38 QuicServerInfo::State* state = server_info_.mutable_state();
37 EXPECT_TRUE(state->certs.empty()); 39 EXPECT_TRUE(state->certs.empty());
38 40
39 state->server_config = kServerConfigA; 41 state->server_config = kServerConfigA;
40 state->source_address_token = kSourceAddressTokenA; 42 state->source_address_token = kSourceAddressTokenA;
41 state->server_config_sig = kServerConfigSigA; 43 state->server_config_sig = kServerConfigSigA;
44 state->cert_sct = kCertSCTA;
45 state->chlo_hash = kChloHashA;
42 state->certs.push_back(kCertA); 46 state->certs.push_back(kCertA);
43 EXPECT_TRUE(server_info_.IsReadyToPersist()); 47 EXPECT_TRUE(server_info_.IsReadyToPersist());
44 server_info_.Persist(); 48 server_info_.Persist();
45 EXPECT_TRUE(server_info_.IsReadyToPersist()); 49 EXPECT_TRUE(server_info_.IsReadyToPersist());
46 EXPECT_TRUE(server_info_.IsDataReady()); 50 EXPECT_TRUE(server_info_.IsDataReady());
47 server_info_.OnExternalCacheHit(); 51 server_info_.OnExternalCacheHit();
48 } 52 }
49 53
50 // Verify the data that is persisted in InitializeAndPersist(). 54 // Verify the data that is persisted in InitializeAndPersist().
51 void VerifyInitialData(const QuicServerInfo::State& state) { 55 void VerifyInitialData(const QuicServerInfo::State& state) {
52 EXPECT_EQ(kServerConfigA, state.server_config); 56 EXPECT_EQ(kServerConfigA, state.server_config);
53 EXPECT_EQ(kSourceAddressTokenA, state.source_address_token); 57 EXPECT_EQ(kSourceAddressTokenA, state.source_address_token);
58 EXPECT_EQ(kCertSCTA, state.cert_sct);
59 EXPECT_EQ(kChloHashA, state.chlo_hash);
54 EXPECT_EQ(kServerConfigSigA, state.server_config_sig); 60 EXPECT_EQ(kServerConfigSigA, state.server_config_sig);
55 EXPECT_EQ(kCertA, state.certs[0]); 61 EXPECT_EQ(kCertA, state.certs[0]);
56 } 62 }
57 63
58 HttpServerPropertiesImpl http_server_properties_; 64 HttpServerPropertiesImpl http_server_properties_;
59 QuicServerId server_id_; 65 QuicServerId server_id_;
60 PropertiesBasedQuicServerInfo server_info_; 66 PropertiesBasedQuicServerInfo server_info_;
61 CompletionCallback callback_; 67 CompletionCallback callback_;
62 }; 68 };
63 69
(...skipping 28 matching lines...) Expand all
92 98
93 // Verify updated data. 99 // Verify updated data.
94 const QuicServerInfo::State& state3 = server_info2.state(); 100 const QuicServerInfo::State& state3 = server_info2.state();
95 VerifyInitialData(state3); 101 VerifyInitialData(state3);
96 EXPECT_EQ(2U, state3.certs.size()); 102 EXPECT_EQ(2U, state3.certs.size());
97 EXPECT_EQ(kCertB, state3.certs[1]); 103 EXPECT_EQ(kCertB, state3.certs[1]);
98 } 104 }
99 105
100 } // namespace test 106 } // namespace test
101 } // namespace net 107 } // namespace net
OLDNEW
« no previous file with comments | « net/http/disk_cache_based_quic_server_info_unittest.cc ('k') | net/quic/crypto/quic_crypto_client_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698