| OLD | NEW |
| 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/quic_crypto_server_stream.h" | 5 #include "net/quic/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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 } else { | 420 } else { |
| 421 CryptoTestUtils::CommunicateHandshakeMessages( | 421 CryptoTestUtils::CommunicateHandshakeMessages( |
| 422 client_connection_, client_stream(), server_connection_, | 422 client_connection_, client_stream(), server_connection_, |
| 423 server_stream()); | 423 server_stream()); |
| 424 } | 424 } |
| 425 | 425 |
| 426 EXPECT_EQ(1, client_stream()->num_sent_client_hellos()); | 426 EXPECT_EQ(1, client_stream()->num_sent_client_hellos()); |
| 427 } | 427 } |
| 428 | 428 |
| 429 TEST_P(QuicCryptoServerStreamTest, FailByPolicy) { | 429 TEST_P(QuicCryptoServerStreamTest, FailByPolicy) { |
| 430 FLAGS_quic_disable_pre_30 = true; | |
| 431 FLAGS_quic_deprecate_kfixd = true; | 430 FLAGS_quic_deprecate_kfixd = true; |
| 432 Initialize(); | 431 Initialize(); |
| 433 InitializeFakeClient(/* supports_stateless_rejects= */ false); | 432 InitializeFakeClient(/* supports_stateless_rejects= */ false); |
| 434 | 433 |
| 435 EXPECT_CALL(*server_session_->helper(), CanAcceptClientHello(_, _, _)) | 434 EXPECT_CALL(*server_session_->helper(), CanAcceptClientHello(_, _, _)) |
| 436 .WillOnce(testing::Return(false)); | 435 .WillOnce(testing::Return(false)); |
| 437 EXPECT_CALL(*server_connection_, | 436 EXPECT_CALL(*server_connection_, |
| 438 CloseConnection(QUIC_HANDSHAKE_FAILED, _, _)); | 437 CloseConnection(QUIC_HANDSHAKE_FAILED, _, _)); |
| 439 | 438 |
| 440 AdvanceHandshakeWithFakeClient(); | 439 AdvanceHandshakeWithFakeClient(); |
| 441 } | 440 } |
| 442 | 441 |
| 443 TEST_P(QuicCryptoServerStreamTest, MessageAfterHandshake) { | 442 TEST_P(QuicCryptoServerStreamTest, MessageAfterHandshake) { |
| 444 FLAGS_quic_disable_pre_30 = true; | |
| 445 FLAGS_quic_deprecate_kfixd = true; | 443 FLAGS_quic_deprecate_kfixd = true; |
| 446 Initialize(); | 444 Initialize(); |
| 447 CompleteCryptoHandshake(); | 445 CompleteCryptoHandshake(); |
| 448 EXPECT_CALL( | 446 EXPECT_CALL( |
| 449 *server_connection_, | 447 *server_connection_, |
| 450 CloseConnection(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE, _, _)); | 448 CloseConnection(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE, _, _)); |
| 451 message_.set_tag(kCHLO); | 449 message_.set_tag(kCHLO); |
| 452 ConstructHandshakeMessage(); | 450 ConstructHandshakeMessage(); |
| 453 server_stream()->OnStreamFrame( | 451 server_stream()->OnStreamFrame( |
| 454 QuicStreamFrame(kCryptoStreamId, /*fin=*/false, /*offset=*/0, | 452 QuicStreamFrame(kCryptoStreamId, /*fin=*/false, /*offset=*/0, |
| 455 message_data_->AsStringPiece())); | 453 message_data_->AsStringPiece())); |
| 456 } | 454 } |
| 457 | 455 |
| 458 TEST_P(QuicCryptoServerStreamTest, BadMessageType) { | 456 TEST_P(QuicCryptoServerStreamTest, BadMessageType) { |
| 459 FLAGS_quic_disable_pre_30 = true; | |
| 460 FLAGS_quic_deprecate_kfixd = true; | 457 FLAGS_quic_deprecate_kfixd = true; |
| 461 Initialize(); | 458 Initialize(); |
| 462 | 459 |
| 463 message_.set_tag(kSHLO); | 460 message_.set_tag(kSHLO); |
| 464 ConstructHandshakeMessage(); | 461 ConstructHandshakeMessage(); |
| 465 EXPECT_CALL(*server_connection_, | 462 EXPECT_CALL(*server_connection_, |
| 466 CloseConnection(QUIC_INVALID_CRYPTO_MESSAGE_TYPE, _, _)); | 463 CloseConnection(QUIC_INVALID_CRYPTO_MESSAGE_TYPE, _, _)); |
| 467 server_stream()->OnStreamFrame( | 464 server_stream()->OnStreamFrame( |
| 468 QuicStreamFrame(kCryptoStreamId, /*fin=*/false, /*offset=*/0, | 465 QuicStreamFrame(kCryptoStreamId, /*fin=*/false, /*offset=*/0, |
| 469 message_data_->AsStringPiece())); | 466 message_data_->AsStringPiece())); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 EXPECT_EQ( | 557 EXPECT_EQ( |
| 561 0u, server_stream()->crypto_negotiated_params().token_binding_key_param); | 558 0u, server_stream()->crypto_negotiated_params().token_binding_key_param); |
| 562 EXPECT_TRUE(server_stream()->encryption_established()); | 559 EXPECT_TRUE(server_stream()->encryption_established()); |
| 563 EXPECT_TRUE(server_stream()->handshake_confirmed()); | 560 EXPECT_TRUE(server_stream()->handshake_confirmed()); |
| 564 } | 561 } |
| 565 | 562 |
| 566 TEST_P(QuicCryptoServerStreamTest, CancelRPCBeforeVerificationCompletes) { | 563 TEST_P(QuicCryptoServerStreamTest, CancelRPCBeforeVerificationCompletes) { |
| 567 // Tests that the client can close the connection while the remote strike | 564 // Tests that the client can close the connection while the remote strike |
| 568 // register verification RPC is still pending. | 565 // register verification RPC is still pending. |
| 569 | 566 |
| 570 // Set version to QUIC_VERSION_25 as QUIC_VERSION_26 and later don't support | 567 // Set version to QUIC_VERSION_32 as QUIC_VERSION_33 and later don't support |
| 571 // asynchronous strike register RPCs. | 568 // asynchronous strike register RPCs. |
| 572 supported_versions_ = {QUIC_VERSION_25}; | 569 supported_versions_ = {QUIC_VERSION_32}; |
| 573 Initialize(); | 570 Initialize(); |
| 574 if (!AsyncStrikeRegisterVerification()) { | 571 if (!AsyncStrikeRegisterVerification()) { |
| 575 return; | 572 return; |
| 576 } | 573 } |
| 577 InitializeFakeClient(/* supports_stateless_rejects= */ false); | 574 InitializeFakeClient(/* supports_stateless_rejects= */ false); |
| 578 | 575 |
| 579 // Do a first handshake in order to prime the client config with the server's | 576 // Do a first handshake in order to prime the client config with the server's |
| 580 // information. | 577 // information. |
| 581 AdvanceHandshakeWithFakeClient(); | 578 AdvanceHandshakeWithFakeClient(); |
| 582 | 579 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 602 QUIC_NO_ERROR, "", ConnectionCloseBehavior::SILENT_CLOSE); | 599 QUIC_NO_ERROR, "", ConnectionCloseBehavior::SILENT_CLOSE); |
| 603 | 600 |
| 604 // The outstanding nonce verification RPC now completes. | 601 // The outstanding nonce verification RPC now completes. |
| 605 strike_register_client_->RunPendingVerifications(); | 602 strike_register_client_->RunPendingVerifications(); |
| 606 } | 603 } |
| 607 | 604 |
| 608 } // namespace | 605 } // namespace |
| 609 | 606 |
| 610 } // namespace test | 607 } // namespace test |
| 611 } // namespace net | 608 } // namespace net |
| OLD | NEW |