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

Side by Side Diff: net/quic/core/quic_crypto_server_stream_test.cc

Issue 2306173003: Add a new QuicFlagSaver class for saving/restoring the values of QUIC flags in tests. (Closed)
Patch Set: Better Created 4 years, 3 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
« no previous file with comments | « net/quic/core/quic_crypto_client_stream_test.cc ('k') | net/quic/core/quic_flags.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "net/quic/core/quic_crypto_server_stream.h" 5 #include "net/quic/core/quic_crypto_server_stream.h"
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 CHECK(server_connection_); 164 CHECK(server_connection_);
165 CHECK(client_session_ != nullptr); 165 CHECK(client_session_ != nullptr);
166 166
167 EXPECT_CALL(*client_session_, OnProofValid(_)).Times(testing::AnyNumber()); 167 EXPECT_CALL(*client_session_, OnProofValid(_)).Times(testing::AnyNumber());
168 client_stream()->CryptoConnect(); 168 client_stream()->CryptoConnect();
169 CryptoTestUtils::AdvanceHandshake(client_connection_, client_stream(), 0, 169 CryptoTestUtils::AdvanceHandshake(client_connection_, client_stream(), 0,
170 server_connection_, server_stream(), 0); 170 server_connection_, server_stream(), 0);
171 } 171 }
172 172
173 protected: 173 protected:
174 QuicFlagSaver flags_; // Save/restore all QUIC flag values.
175
174 // Every connection gets its own MockQuicConnectionHelper and 176 // Every connection gets its own MockQuicConnectionHelper and
175 // MockAlarmFactory, 177 // MockAlarmFactory,
176 // tracked separately from 178 // tracked separately from
177 // the server and client state so their lifetimes persist through the whole 179 // the server and client state so their lifetimes persist through the whole
178 // test. 180 // test.
179 std::vector<MockQuicConnectionHelper*> helpers_; 181 std::vector<MockQuicConnectionHelper*> helpers_;
180 std::vector<MockAlarmFactory*> alarm_factories_; 182 std::vector<MockAlarmFactory*> alarm_factories_;
181 183
182 // Server state 184 // Server state
183 PacketSavingConnection* server_connection_; 185 PacketSavingConnection* server_connection_;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 InitializeFakeClient(/* supports_stateless_rejects= */ false); 242 InitializeFakeClient(/* supports_stateless_rejects= */ false);
241 243
242 AdvanceHandshakeWithFakeClient(); 244 AdvanceHandshakeWithFakeClient();
243 EXPECT_TRUE(server_stream()->encryption_established()); 245 EXPECT_TRUE(server_stream()->encryption_established());
244 EXPECT_TRUE(server_stream()->handshake_confirmed()); 246 EXPECT_TRUE(server_stream()->handshake_confirmed());
245 EXPECT_EQ(ENCRYPTION_FORWARD_SECURE, 247 EXPECT_EQ(ENCRYPTION_FORWARD_SECURE,
246 server_session_->connection()->encryption_level()); 248 server_session_->connection()->encryption_level());
247 } 249 }
248 250
249 TEST_P(QuicCryptoServerStreamTest, StatelessRejectAfterCHLO) { 251 TEST_P(QuicCryptoServerStreamTest, StatelessRejectAfterCHLO) {
250 ValueRestore<bool> old_flag(&FLAGS_enable_quic_stateless_reject_support, 252 FLAGS_enable_quic_stateless_reject_support = true;
251 true); 253
252 Initialize(); 254 Initialize();
253 255
254 EXPECT_CALL(*server_connection_, 256 EXPECT_CALL(*server_connection_,
255 CloseConnection(QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT, _, _)); 257 CloseConnection(QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT, _, _));
256 258
257 InitializeFakeClient(/* supports_stateless_rejects= */ true); 259 InitializeFakeClient(/* supports_stateless_rejects= */ true);
258 AdvanceHandshakeWithFakeClient(); 260 AdvanceHandshakeWithFakeClient();
259 261
260 // Check the server to make the sure the handshake did not succeed. 262 // Check the server to make the sure the handshake did not succeed.
261 EXPECT_FALSE(server_stream()->encryption_established()); 263 EXPECT_FALSE(server_stream()->encryption_established());
(...skipping 12 matching lines...) Expand all
274 const QuicConnectionId server_designated_connection_id = 276 const QuicConnectionId server_designated_connection_id =
275 client_state->GetNextServerDesignatedConnectionId(); 277 client_state->GetNextServerDesignatedConnectionId();
276 const QuicConnectionId expected_id = 278 const QuicConnectionId expected_id =
277 server_connection_->random_generator()->RandUint64(); 279 server_connection_->random_generator()->RandUint64();
278 EXPECT_EQ(expected_id, server_designated_connection_id); 280 EXPECT_EQ(expected_id, server_designated_connection_id);
279 EXPECT_FALSE(client_state->has_server_designated_connection_id()); 281 EXPECT_FALSE(client_state->has_server_designated_connection_id());
280 ASSERT_TRUE(client_state->IsComplete(QuicWallTime::FromUNIXSeconds(0))); 282 ASSERT_TRUE(client_state->IsComplete(QuicWallTime::FromUNIXSeconds(0)));
281 } 283 }
282 284
283 TEST_P(QuicCryptoServerStreamTest, ConnectedAfterStatelessHandshake) { 285 TEST_P(QuicCryptoServerStreamTest, ConnectedAfterStatelessHandshake) {
284 ValueRestore<bool> old_flag(&FLAGS_enable_quic_stateless_reject_support, 286 FLAGS_enable_quic_stateless_reject_support = true;
285 true); 287
286 Initialize(); 288 Initialize();
287 289
288 InitializeFakeClient(/* supports_stateless_rejects= */ true); 290 InitializeFakeClient(/* supports_stateless_rejects= */ true);
289 AdvanceHandshakeWithFakeClient(); 291 AdvanceHandshakeWithFakeClient();
290 292
291 // On the first round, encryption will not be established. 293 // On the first round, encryption will not be established.
292 EXPECT_FALSE(server_stream()->encryption_established()); 294 EXPECT_FALSE(server_stream()->encryption_established());
293 EXPECT_FALSE(server_stream()->handshake_confirmed()); 295 EXPECT_FALSE(server_stream()->handshake_confirmed());
294 EXPECT_EQ(1, server_stream()->NumHandshakeMessages()); 296 EXPECT_EQ(1, server_stream()->NumHandshakeMessages());
295 EXPECT_EQ(0, server_stream()->NumHandshakeMessagesWithServerNonces()); 297 EXPECT_EQ(0, server_stream()->NumHandshakeMessagesWithServerNonces());
(...skipping 23 matching lines...) Expand all
319 AdvanceHandshakeWithFakeClient(); 321 AdvanceHandshakeWithFakeClient();
320 322
321 // On the second round, encryption will be established. 323 // On the second round, encryption will be established.
322 EXPECT_TRUE(server_stream()->encryption_established()); 324 EXPECT_TRUE(server_stream()->encryption_established());
323 EXPECT_TRUE(server_stream()->handshake_confirmed()); 325 EXPECT_TRUE(server_stream()->handshake_confirmed());
324 EXPECT_EQ(1, server_stream()->NumHandshakeMessages()); 326 EXPECT_EQ(1, server_stream()->NumHandshakeMessages());
325 EXPECT_EQ(1, server_stream()->NumHandshakeMessagesWithServerNonces()); 327 EXPECT_EQ(1, server_stream()->NumHandshakeMessagesWithServerNonces());
326 } 328 }
327 329
328 TEST_P(QuicCryptoServerStreamTest, NoStatelessRejectIfNoClientSupport) { 330 TEST_P(QuicCryptoServerStreamTest, NoStatelessRejectIfNoClientSupport) {
329 ValueRestore<bool> old_flag(&FLAGS_enable_quic_stateless_reject_support, 331 FLAGS_enable_quic_stateless_reject_support = true;
330 true); 332
331 Initialize(); 333 Initialize();
332 334
333 // The server is configured to use stateless rejects, but the client does not 335 // The server is configured to use stateless rejects, but the client does not
334 // support it. 336 // support it.
335 InitializeFakeClient(/* supports_stateless_rejects= */ false); 337 InitializeFakeClient(/* supports_stateless_rejects= */ false);
336 AdvanceHandshakeWithFakeClient(); 338 AdvanceHandshakeWithFakeClient();
337 339
338 // Check the server to make the sure the handshake did not succeed. 340 // Check the server to make the sure the handshake did not succeed.
339 EXPECT_FALSE(server_stream()->encryption_established()); 341 EXPECT_FALSE(server_stream()->encryption_established());
340 EXPECT_FALSE(server_stream()->handshake_confirmed()); 342 EXPECT_FALSE(server_stream()->handshake_confirmed());
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 QUIC_NO_ERROR, "", ConnectionCloseBehavior::SILENT_CLOSE); 572 QUIC_NO_ERROR, "", ConnectionCloseBehavior::SILENT_CLOSE);
571 573
572 // The outstanding nonce verification RPC now completes. 574 // The outstanding nonce verification RPC now completes.
573 strike_register_client_->RunPendingVerifications(); 575 strike_register_client_->RunPendingVerifications();
574 } 576 }
575 577
576 } // namespace 578 } // namespace
577 579
578 } // namespace test 580 } // namespace test
579 } // namespace net 581 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_crypto_client_stream_test.cc ('k') | net/quic/core/quic_flags.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698