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

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

Issue 2391103003: Landing Recent QUIC changes until 3:24 PM, Oct 01, 2016 UTC-4 (Closed)
Patch Set: Add new error code to quic_error_mapping.cc Created 4 years, 2 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_server_stream.cc ('k') | net/quic/core/quic_flags_list.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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 }; 51 };
52 52
53 namespace { 53 namespace {
54 54
55 const char kServerHostname[] = "test.example.com"; 55 const char kServerHostname[] = "test.example.com";
56 const uint16_t kServerPort = 443; 56 const uint16_t kServerPort = 443;
57 57
58 class QuicCryptoServerStreamTest : public ::testing::TestWithParam<bool> { 58 class QuicCryptoServerStreamTest : public ::testing::TestWithParam<bool> {
59 public: 59 public:
60 QuicCryptoServerStreamTest() 60 QuicCryptoServerStreamTest()
61 : QuicCryptoServerStreamTest(CryptoTestUtils::ProofSourceForTesting()) {}
62
63 explicit QuicCryptoServerStreamTest(std::unique_ptr<ProofSource> proof_source)
61 : server_crypto_config_(QuicCryptoServerConfig::TESTING, 64 : server_crypto_config_(QuicCryptoServerConfig::TESTING,
62 QuicRandom::GetInstance(), 65 QuicRandom::GetInstance(),
63 CryptoTestUtils::ProofSourceForTesting()), 66 std::move(proof_source)),
64 server_compressed_certs_cache_( 67 server_compressed_certs_cache_(
65 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize), 68 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize),
66 server_id_(kServerHostname, kServerPort, PRIVACY_MODE_DISABLED), 69 server_id_(kServerHostname, kServerPort, PRIVACY_MODE_DISABLED),
67 client_crypto_config_(CryptoTestUtils::ProofVerifierForTesting()) { 70 client_crypto_config_(CryptoTestUtils::ProofVerifierForTesting()) {
68 FLAGS_enable_quic_stateless_reject_support = false; 71 FLAGS_enable_quic_stateless_reject_support = false;
69 server_crypto_config_.set_strike_register_no_startup_period(); 72 server_crypto_config_.set_strike_register_no_startup_period();
70 } 73 }
71 74
72 void Initialize() { 75 void Initialize() {
73 InitializeServer(); 76 InitializeServer();
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 571
569 // While waiting for the asynchronous verification to complete, the client 572 // While waiting for the asynchronous verification to complete, the client
570 // decides to close the connection. 573 // decides to close the connection.
571 server_session_->connection()->CloseConnection( 574 server_session_->connection()->CloseConnection(
572 QUIC_NO_ERROR, "", ConnectionCloseBehavior::SILENT_CLOSE); 575 QUIC_NO_ERROR, "", ConnectionCloseBehavior::SILENT_CLOSE);
573 576
574 // The outstanding nonce verification RPC now completes. 577 // The outstanding nonce verification RPC now completes.
575 strike_register_client_->RunPendingVerifications(); 578 strike_register_client_->RunPendingVerifications();
576 } 579 }
577 580
581 class FailingProofSource : public ProofSource {
582 public:
583 bool GetProof(const IPAddress& server_ip,
584 const string& hostname,
585 const string& server_config,
586 QuicVersion quic_version,
587 StringPiece chlo_hash,
588 scoped_refptr<ProofSource::Chain>* out_chain,
589 string* out_signature,
590 string* out_leaf_cert_sct) override {
591 return false;
592 }
593
594 void GetProof(const IPAddress& server_ip,
595 const string& hostname,
596 const string& server_config,
597 QuicVersion quic_version,
598 StringPiece chlo_hash,
599 std::unique_ptr<Callback> callback) override {
600 callback->Run(false, nullptr, "", "", nullptr);
601 }
602 };
603
604 class QuicCryptoServerStreamTestWithFailingProofSource
605 : public QuicCryptoServerStreamTest {
606 public:
607 QuicCryptoServerStreamTestWithFailingProofSource()
608 : QuicCryptoServerStreamTest(
609 std::unique_ptr<FailingProofSource>(new FailingProofSource)) {}
610 };
611
612 INSTANTIATE_TEST_CASE_P(MoreTests,
613 QuicCryptoServerStreamTestWithFailingProofSource,
614 testing::Bool());
615
616 TEST_P(QuicCryptoServerStreamTestWithFailingProofSource, Test) {
617 Initialize();
618 InitializeFakeClient(/* supports_stateless_rejects= */ false);
619
620 // Regression test for b/31521252, in which a crash would happen here.
621 AdvanceHandshakeWithFakeClient();
622 EXPECT_FALSE(server_stream()->encryption_established());
623 EXPECT_FALSE(server_stream()->handshake_confirmed());
624 }
625
578 } // namespace 626 } // namespace
579 627
580 } // namespace test 628 } // namespace test
581 } // namespace net 629 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_crypto_server_stream.cc ('k') | net/quic/core/quic_flags_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698