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

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

Issue 2821053004: Revert of Remove the code to store and load QUIC server configs in the disk cache. (Closed)
Patch Set: Created 3 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
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/chromium/properties_based_quic_server_info.h" 5 #include "net/quic/chromium/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"
(...skipping 16 matching lines...) Expand all
27 } // namespace 27 } // namespace
28 28
29 class PropertiesBasedQuicServerInfoTest : public ::testing::Test { 29 class PropertiesBasedQuicServerInfoTest : public ::testing::Test {
30 protected: 30 protected:
31 PropertiesBasedQuicServerInfoTest() 31 PropertiesBasedQuicServerInfoTest()
32 : server_id_("www.google.com", 443, PRIVACY_MODE_DISABLED), 32 : server_id_("www.google.com", 443, PRIVACY_MODE_DISABLED),
33 server_info_(server_id_, &http_server_properties_) {} 33 server_info_(server_id_, &http_server_properties_) {}
34 34
35 // Initialize |server_info_| object and persist it. 35 // Initialize |server_info_| object and persist it.
36 void InitializeAndPersist() { 36 void InitializeAndPersist() {
37 server_info_.Start();
38 EXPECT_TRUE(server_info_.IsDataReady());
37 QuicServerInfo::State* state = server_info_.mutable_state(); 39 QuicServerInfo::State* state = server_info_.mutable_state();
38 EXPECT_TRUE(state->certs.empty()); 40 EXPECT_TRUE(state->certs.empty());
39 41
40 state->server_config = kServerConfigA; 42 state->server_config = kServerConfigA;
41 state->source_address_token = kSourceAddressTokenA; 43 state->source_address_token = kSourceAddressTokenA;
42 state->server_config_sig = kServerConfigSigA; 44 state->server_config_sig = kServerConfigSigA;
43 state->cert_sct = kCertSCTA; 45 state->cert_sct = kCertSCTA;
44 state->chlo_hash = kChloHashA; 46 state->chlo_hash = kChloHashA;
45 state->certs.push_back(kCertA); 47 state->certs.push_back(kCertA);
48 EXPECT_TRUE(server_info_.IsReadyToPersist());
46 server_info_.Persist(); 49 server_info_.Persist();
50 EXPECT_TRUE(server_info_.IsReadyToPersist());
51 EXPECT_TRUE(server_info_.IsDataReady());
52 server_info_.OnExternalCacheHit();
47 } 53 }
48 54
49 // Verify the data that is persisted in InitializeAndPersist(). 55 // Verify the data that is persisted in InitializeAndPersist().
50 void VerifyInitialData(const QuicServerInfo::State& state) { 56 void VerifyInitialData(const QuicServerInfo::State& state) {
51 EXPECT_EQ(kServerConfigA, state.server_config); 57 EXPECT_EQ(kServerConfigA, state.server_config);
52 EXPECT_EQ(kSourceAddressTokenA, state.source_address_token); 58 EXPECT_EQ(kSourceAddressTokenA, state.source_address_token);
53 EXPECT_EQ(kCertSCTA, state.cert_sct); 59 EXPECT_EQ(kCertSCTA, state.cert_sct);
54 EXPECT_EQ(kChloHashA, state.chlo_hash); 60 EXPECT_EQ(kChloHashA, state.chlo_hash);
55 EXPECT_EQ(kServerConfigSigA, state.server_config_sig); 61 EXPECT_EQ(kServerConfigSigA, state.server_config_sig);
56 EXPECT_EQ(kCertA, state.certs[0]); 62 EXPECT_EQ(kCertA, state.certs[0]);
57 } 63 }
58 64
59 HttpServerPropertiesImpl http_server_properties_; 65 HttpServerPropertiesImpl http_server_properties_;
60 QuicServerId server_id_; 66 QuicServerId server_id_;
61 PropertiesBasedQuicServerInfo server_info_; 67 PropertiesBasedQuicServerInfo server_info_;
62 CompletionCallback callback_; 68 CompletionCallback callback_;
63 }; 69 };
64 70
65 // Test persisting, reading and verifying and then updating and verifing. 71 // Test persisting, reading and verifying and then updating and verifing.
66 TEST_F(PropertiesBasedQuicServerInfoTest, Update) { 72 TEST_F(PropertiesBasedQuicServerInfoTest, Update) {
67 InitializeAndPersist(); 73 InitializeAndPersist();
68 74
69 // Read the persisted data and verify we have read the data correctly. 75 // Read the persisted data and verify we have read the data correctly.
70 PropertiesBasedQuicServerInfo server_info1(server_id_, 76 PropertiesBasedQuicServerInfo server_info1(server_id_,
71 &http_server_properties_); 77 &http_server_properties_);
72 EXPECT_TRUE(server_info1.Load()); 78 server_info1.Start();
79 EXPECT_THAT(server_info1.WaitForDataReady(callback_),
80 IsOk()); // Read the data.
81 EXPECT_TRUE(server_info1.IsDataReady());
73 82
74 // Verify the data. 83 // Verify the data.
75 const QuicServerInfo::State& state1 = server_info1.state(); 84 const QuicServerInfo::State& state1 = server_info1.state();
76 EXPECT_EQ(1U, state1.certs.size()); 85 EXPECT_EQ(1U, state1.certs.size());
77 VerifyInitialData(state1); 86 VerifyInitialData(state1);
78 87
79 // Update the data, by adding another cert. 88 // Update the data, by adding another cert.
80 QuicServerInfo::State* state2 = server_info1.mutable_state(); 89 QuicServerInfo::State* state2 = server_info1.mutable_state();
81 state2->certs.push_back(kCertB); 90 state2->certs.push_back(kCertB);
91 EXPECT_TRUE(server_info_.IsReadyToPersist());
82 server_info1.Persist(); 92 server_info1.Persist();
83 93
84 // Read the persisted data and verify we have read the data correctly. 94 // Read the persisted data and verify we have read the data correctly.
85 PropertiesBasedQuicServerInfo server_info2(server_id_, 95 PropertiesBasedQuicServerInfo server_info2(server_id_,
86 &http_server_properties_); 96 &http_server_properties_);
87 EXPECT_TRUE(server_info2.Load()); 97 server_info2.Start();
98 EXPECT_THAT(server_info2.WaitForDataReady(callback_),
99 IsOk()); // Read the data.
100 EXPECT_TRUE(server_info1.IsDataReady());
88 101
89 // Verify updated data. 102 // Verify updated data.
90 const QuicServerInfo::State& state3 = server_info2.state(); 103 const QuicServerInfo::State& state3 = server_info2.state();
91 VerifyInitialData(state3); 104 VerifyInitialData(state3);
92 EXPECT_EQ(2U, state3.certs.size()); 105 EXPECT_EQ(2U, state3.certs.size());
93 EXPECT_EQ(kCertB, state3.certs[1]); 106 EXPECT_EQ(kCertB, state3.certs[1]);
94 } 107 }
95 108
96 } // namespace test 109 } // namespace test
97 } // namespace net 110 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/chromium/properties_based_quic_server_info.cc ('k') | net/quic/chromium/quic_chromium_client_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698