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

Side by Side Diff: net/quic/quic_config_test.cc

Issue 862133002: Update from https://crrev.com/312398 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/quic_config.h" 5 #include "net/quic/quic_config.h"
6 6
7 #include "net/quic/crypto/crypto_handshake_message.h" 7 #include "net/quic/crypto/crypto_handshake_message.h"
8 #include "net/quic/crypto/crypto_protocol.h" 8 #include "net/quic/crypto/crypto_protocol.h"
9 #include "net/quic/quic_flags.h" 9 #include "net/quic/quic_flags.h"
10 #include "net/quic/quic_protocol.h" 10 #include "net/quic/quic_protocol.h"
11 #include "net/quic/quic_time.h" 11 #include "net/quic/quic_time.h"
12 #include "net/quic/quic_utils.h" 12 #include "net/quic/quic_utils.h"
13 #include "net/quic/test_tools/quic_config_peer.h"
13 #include "net/quic/test_tools/quic_test_utils.h" 14 #include "net/quic/test_tools/quic_test_utils.h"
14 #include "net/test/gtest_util.h" 15 #include "net/test/gtest_util.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 using std::string; 18 using std::string;
18 19
19 namespace net { 20 namespace net {
20 namespace test { 21 namespace test {
21 namespace { 22 namespace {
22 23
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 size_t out_len; 63 size_t out_len;
63 error = msg.GetTaglist(kCGST, &out, &out_len); 64 error = msg.GetTaglist(kCGST, &out, &out_len);
64 EXPECT_EQ(1u, out_len); 65 EXPECT_EQ(1u, out_len);
65 EXPECT_EQ(kQBIC, *out); 66 EXPECT_EQ(kQBIC, *out);
66 } 67 }
67 68
68 TEST_F(QuicConfigTest, ProcessClientHello) { 69 TEST_F(QuicConfigTest, ProcessClientHello) {
69 QuicConfig client_config; 70 QuicConfig client_config;
70 QuicTagVector cgst; 71 QuicTagVector cgst;
71 cgst.push_back(kQBIC); 72 cgst.push_back(kQBIC);
72 client_config.SetCongestionFeedback(cgst, kQBIC);
73 client_config.SetIdleConnectionStateLifetime( 73 client_config.SetIdleConnectionStateLifetime(
74 QuicTime::Delta::FromSeconds(2 * kMaximumIdleTimeoutSecs), 74 QuicTime::Delta::FromSeconds(2 * kMaximumIdleTimeoutSecs),
75 QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs)); 75 QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs));
76 client_config.SetMaxStreamsPerConnection( 76 client_config.SetMaxStreamsPerConnection(
77 2 * kDefaultMaxStreamsPerConnection, kDefaultMaxStreamsPerConnection); 77 2 * kDefaultMaxStreamsPerConnection, kDefaultMaxStreamsPerConnection);
78 client_config.SetInitialRoundTripTimeUsToSend(10 * kNumMicrosPerMilli); 78 client_config.SetInitialRoundTripTimeUsToSend(10 * kNumMicrosPerMilli);
79 client_config.SetInitialStreamFlowControlWindowToSend( 79 client_config.SetInitialStreamFlowControlWindowToSend(
80 2 * kInitialStreamFlowControlWindowForTest); 80 2 * kInitialStreamFlowControlWindowForTest);
81 client_config.SetInitialSessionFlowControlWindowToSend( 81 client_config.SetInitialSessionFlowControlWindowToSend(
82 2 * kInitialSessionFlowControlWindowForTest); 82 2 * kInitialSessionFlowControlWindowForTest);
83 client_config.SetSocketReceiveBufferToSend(kDefaultSocketReceiveBuffer); 83 client_config.SetSocketReceiveBufferToSend(kDefaultSocketReceiveBuffer);
84 QuicTagVector copt; 84 QuicTagVector copt;
85 copt.push_back(kTBBR); 85 copt.push_back(kTBBR);
86 copt.push_back(kFHDR); 86 copt.push_back(kFHDR);
87 client_config.SetConnectionOptionsToSend(copt); 87 client_config.SetConnectionOptionsToSend(copt);
88 CryptoHandshakeMessage msg; 88 CryptoHandshakeMessage msg;
89 client_config.ToHandshakeMessage(&msg); 89 client_config.ToHandshakeMessage(&msg);
90 90
91 string error_details; 91 string error_details;
92 const QuicErrorCode error = 92 const QuicErrorCode error =
93 config_.ProcessPeerHello(msg, CLIENT, &error_details); 93 config_.ProcessPeerHello(msg, CLIENT, &error_details);
94 EXPECT_EQ(QUIC_NO_ERROR, error); 94 EXPECT_EQ(QUIC_NO_ERROR, error);
95 EXPECT_TRUE(config_.negotiated()); 95 EXPECT_TRUE(config_.negotiated());
96 EXPECT_EQ(kQBIC, config_.CongestionFeedback());
97 EXPECT_EQ(QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs), 96 EXPECT_EQ(QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs),
98 config_.IdleConnectionStateLifetime()); 97 config_.IdleConnectionStateLifetime());
99 EXPECT_EQ(kDefaultMaxStreamsPerConnection, 98 EXPECT_EQ(kDefaultMaxStreamsPerConnection,
100 config_.MaxStreamsPerConnection()); 99 config_.MaxStreamsPerConnection());
101 EXPECT_EQ(10 * kNumMicrosPerMilli, config_.ReceivedInitialRoundTripTimeUs()); 100 EXPECT_EQ(10 * kNumMicrosPerMilli, config_.ReceivedInitialRoundTripTimeUs());
102 EXPECT_TRUE(config_.HasReceivedConnectionOptions()); 101 EXPECT_TRUE(config_.HasReceivedConnectionOptions());
103 EXPECT_EQ(2u, config_.ReceivedConnectionOptions().size()); 102 EXPECT_EQ(2u, config_.ReceivedConnectionOptions().size());
104 EXPECT_EQ(config_.ReceivedConnectionOptions()[0], kTBBR); 103 EXPECT_EQ(config_.ReceivedConnectionOptions()[0], kTBBR);
105 EXPECT_EQ(config_.ReceivedConnectionOptions()[1], kFHDR); 104 EXPECT_EQ(config_.ReceivedConnectionOptions()[1], kFHDR);
106 EXPECT_EQ(config_.ReceivedInitialStreamFlowControlWindowBytes(), 105 EXPECT_EQ(config_.ReceivedInitialStreamFlowControlWindowBytes(),
107 2 * kInitialStreamFlowControlWindowForTest); 106 2 * kInitialStreamFlowControlWindowForTest);
108 EXPECT_EQ(config_.ReceivedInitialSessionFlowControlWindowBytes(), 107 EXPECT_EQ(config_.ReceivedInitialSessionFlowControlWindowBytes(),
109 2 * kInitialSessionFlowControlWindowForTest); 108 2 * kInitialSessionFlowControlWindowForTest);
110 EXPECT_EQ(config_.ReceivedSocketReceiveBuffer(), 109 EXPECT_EQ(config_.ReceivedSocketReceiveBuffer(),
111 kDefaultSocketReceiveBuffer); 110 kDefaultSocketReceiveBuffer);
112 } 111 }
113 112
114 TEST_F(QuicConfigTest, ProcessServerHello) { 113 TEST_F(QuicConfigTest, ProcessServerHello) {
115 QuicConfig server_config; 114 QuicConfig server_config;
116 QuicTagVector cgst; 115 QuicTagVector cgst;
117 cgst.push_back(kQBIC); 116 cgst.push_back(kQBIC);
118 server_config.SetCongestionFeedback(cgst, kQBIC);
119 server_config.SetIdleConnectionStateLifetime( 117 server_config.SetIdleConnectionStateLifetime(
120 QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs / 2), 118 QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs / 2),
121 QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs / 2)); 119 QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs / 2));
122 server_config.SetMaxStreamsPerConnection( 120 server_config.SetMaxStreamsPerConnection(
123 kDefaultMaxStreamsPerConnection / 2, 121 kDefaultMaxStreamsPerConnection / 2,
124 kDefaultMaxStreamsPerConnection / 2); 122 kDefaultMaxStreamsPerConnection / 2);
125 server_config.SetInitialRoundTripTimeUsToSend(10 * kNumMicrosPerMilli); 123 server_config.SetInitialRoundTripTimeUsToSend(10 * kNumMicrosPerMilli);
126 server_config.SetInitialStreamFlowControlWindowToSend( 124 server_config.SetInitialStreamFlowControlWindowToSend(
127 2 * kInitialStreamFlowControlWindowForTest); 125 2 * kInitialStreamFlowControlWindowForTest);
128 server_config.SetInitialSessionFlowControlWindowToSend( 126 server_config.SetInitialSessionFlowControlWindowToSend(
129 2 * kInitialSessionFlowControlWindowForTest); 127 2 * kInitialSessionFlowControlWindowForTest);
130 server_config.SetSocketReceiveBufferToSend(kDefaultSocketReceiveBuffer); 128 server_config.SetSocketReceiveBufferToSend(kDefaultSocketReceiveBuffer);
131 CryptoHandshakeMessage msg; 129 CryptoHandshakeMessage msg;
132 server_config.ToHandshakeMessage(&msg); 130 server_config.ToHandshakeMessage(&msg);
133 string error_details; 131 string error_details;
134 const QuicErrorCode error = 132 const QuicErrorCode error =
135 config_.ProcessPeerHello(msg, SERVER, &error_details); 133 config_.ProcessPeerHello(msg, SERVER, &error_details);
136 EXPECT_EQ(QUIC_NO_ERROR, error); 134 EXPECT_EQ(QUIC_NO_ERROR, error);
137 EXPECT_TRUE(config_.negotiated()); 135 EXPECT_TRUE(config_.negotiated());
138 EXPECT_EQ(kQBIC, config_.CongestionFeedback());
139 EXPECT_EQ(QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs / 2), 136 EXPECT_EQ(QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs / 2),
140 config_.IdleConnectionStateLifetime()); 137 config_.IdleConnectionStateLifetime());
141 EXPECT_EQ(kDefaultMaxStreamsPerConnection / 2, 138 EXPECT_EQ(kDefaultMaxStreamsPerConnection / 2,
142 config_.MaxStreamsPerConnection()); 139 config_.MaxStreamsPerConnection());
143 EXPECT_EQ(10 * kNumMicrosPerMilli, config_.ReceivedInitialRoundTripTimeUs()); 140 EXPECT_EQ(10 * kNumMicrosPerMilli, config_.ReceivedInitialRoundTripTimeUs());
144 EXPECT_EQ(config_.ReceivedInitialStreamFlowControlWindowBytes(), 141 EXPECT_EQ(config_.ReceivedInitialStreamFlowControlWindowBytes(),
145 2 * kInitialStreamFlowControlWindowForTest); 142 2 * kInitialStreamFlowControlWindowForTest);
146 EXPECT_EQ(config_.ReceivedInitialSessionFlowControlWindowBytes(), 143 EXPECT_EQ(config_.ReceivedInitialSessionFlowControlWindowBytes(),
147 2 * kInitialSessionFlowControlWindowForTest); 144 2 * kInitialSessionFlowControlWindowForTest);
148 EXPECT_EQ(config_.ReceivedSocketReceiveBuffer(), 145 EXPECT_EQ(config_.ReceivedSocketReceiveBuffer(),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 msg.SetVector(kCGST, QuicTagVector(1, kQBIC)); 186 msg.SetVector(kCGST, QuicTagVector(1, kQBIC));
190 // Missing kMSPC. KATO is optional. 187 // Missing kMSPC. KATO is optional.
191 string error_details; 188 string error_details;
192 const QuicErrorCode error = 189 const QuicErrorCode error =
193 config_.ProcessPeerHello(msg, CLIENT, &error_details); 190 config_.ProcessPeerHello(msg, CLIENT, &error_details);
194 EXPECT_EQ(QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND, error); 191 EXPECT_EQ(QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND, error);
195 } 192 }
196 193
197 TEST_F(QuicConfigTest, MissingValueInSHLO) { 194 TEST_F(QuicConfigTest, MissingValueInSHLO) {
198 CryptoHandshakeMessage msg; 195 CryptoHandshakeMessage msg;
199 msg.SetValue(kICSL, 1);
200 msg.SetValue(kMSPC, 3); 196 msg.SetValue(kMSPC, 3);
201 // Missing CGST. KATO is optional. 197 // Missing ICSL. KATO is optional.
202 string error_details; 198 string error_details;
203 const QuicErrorCode error = 199 const QuicErrorCode error =
204 config_.ProcessPeerHello(msg, SERVER, &error_details); 200 config_.ProcessPeerHello(msg, SERVER, &error_details);
205 EXPECT_EQ(QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND, error); 201 EXPECT_EQ(QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND, error);
206 } 202 }
207 203
208 TEST_F(QuicConfigTest, OutOfBoundSHLO) { 204 TEST_F(QuicConfigTest, OutOfBoundSHLO) {
209 QuicConfig server_config; 205 QuicConfig server_config;
210 server_config.SetIdleConnectionStateLifetime( 206 server_config.SetIdleConnectionStateLifetime(
211 QuicTime::Delta::FromSeconds(2 * kMaximumIdleTimeoutSecs), 207 QuicTime::Delta::FromSeconds(2 * kMaximumIdleTimeoutSecs),
212 QuicTime::Delta::FromSeconds(2 * kMaximumIdleTimeoutSecs)); 208 QuicTime::Delta::FromSeconds(2 * kMaximumIdleTimeoutSecs));
213 209
214 CryptoHandshakeMessage msg; 210 CryptoHandshakeMessage msg;
215 server_config.ToHandshakeMessage(&msg); 211 server_config.ToHandshakeMessage(&msg);
216 string error_details; 212 string error_details;
217 const QuicErrorCode error = 213 const QuicErrorCode error =
218 config_.ProcessPeerHello(msg, SERVER, &error_details); 214 config_.ProcessPeerHello(msg, SERVER, &error_details);
219 EXPECT_EQ(QUIC_INVALID_NEGOTIATED_VALUE, error); 215 EXPECT_EQ(QUIC_INVALID_NEGOTIATED_VALUE, error);
220 } 216 }
221 217
222 TEST_F(QuicConfigTest, MultipleNegotiatedValuesInVectorTag) {
223 QuicConfig server_config;
224 QuicTagVector cgst;
225 cgst.push_back(kQBIC);
226 cgst.push_back(kTBBR);
227 server_config.SetCongestionFeedback(cgst, kQBIC);
228
229 CryptoHandshakeMessage msg;
230 server_config.ToHandshakeMessage(&msg);
231 string error_details;
232 const QuicErrorCode error =
233 config_.ProcessPeerHello(msg, SERVER, &error_details);
234 EXPECT_EQ(QUIC_INVALID_NEGOTIATED_VALUE, error);
235 }
236
237 TEST_F(QuicConfigTest, NoOverLapInCGST) {
238 QuicConfig server_config;
239 QuicTagVector cgst;
240 cgst.push_back(kTBBR);
241 server_config.SetCongestionFeedback(cgst, kTBBR);
242
243 CryptoHandshakeMessage msg;
244 string error_details;
245 server_config.ToHandshakeMessage(&msg);
246 const QuicErrorCode error =
247 config_.ProcessPeerHello(msg, CLIENT, &error_details);
248 DVLOG(1) << QuicUtils::ErrorToString(error);
249 EXPECT_EQ(QUIC_CRYPTO_MESSAGE_PARAMETER_NO_OVERLAP, error);
250 }
251
252 TEST_F(QuicConfigTest, InvalidFlowControlWindow) { 218 TEST_F(QuicConfigTest, InvalidFlowControlWindow) {
253 // QuicConfig should not accept an invalid flow control window to send to the 219 // QuicConfig should not accept an invalid flow control window to send to the
254 // peer: the receive window must be at least the default of 16 Kb. 220 // peer: the receive window must be at least the default of 16 Kb.
255 QuicConfig config; 221 QuicConfig config;
256 const uint64 kInvalidWindow = kMinimumFlowControlSendWindow - 1; 222 const uint64 kInvalidWindow = kMinimumFlowControlSendWindow - 1;
257 EXPECT_DFATAL(config.SetInitialStreamFlowControlWindowToSend(kInvalidWindow), 223 EXPECT_DFATAL(config.SetInitialStreamFlowControlWindowToSend(kInvalidWindow),
258 "Initial stream flow control receive window"); 224 "Initial stream flow control receive window");
259 225
260 EXPECT_EQ(kMinimumFlowControlSendWindow, 226 EXPECT_EQ(kMinimumFlowControlSendWindow,
261 config.GetInitialStreamFlowControlWindowToSend()); 227 config.GetInitialStreamFlowControlWindowToSend());
262 } 228 }
263 229
264 } // namespace 230 } // namespace
265 } // namespace test 231 } // namespace test
266 } // namespace net 232 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_config.cc ('k') | net/quic/quic_connection.h » ('j') | shell/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698