OLD | NEW |
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 <algorithm> | 5 #include <algorithm> |
6 #include <cstdint> | 6 #include <cstdint> |
7 #include <memory> | 7 #include <memory> |
8 #include <ostream> | 8 #include <ostream> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "net/quic/test_tools/mock_clock.h" | 26 #include "net/quic/test_tools/mock_clock.h" |
27 #include "net/quic/test_tools/mock_random.h" | 27 #include "net/quic/test_tools/mock_random.h" |
28 #include "net/quic/test_tools/quic_crypto_server_config_peer.h" | 28 #include "net/quic/test_tools/quic_crypto_server_config_peer.h" |
29 #include "net/quic/test_tools/quic_test_utils.h" | 29 #include "net/quic/test_tools/quic_test_utils.h" |
30 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
31 | 31 |
32 using base::StringPiece; | 32 using base::StringPiece; |
33 using std::endl; | 33 using std::endl; |
34 using std::ostream; | 34 using std::ostream; |
35 using std::string; | 35 using std::string; |
36 using std::vector; | |
37 | 36 |
38 namespace net { | 37 namespace net { |
39 namespace test { | 38 namespace test { |
40 | 39 |
41 namespace { | 40 namespace { |
42 | 41 |
43 class DummyProofVerifierCallback : public ProofVerifierCallback { | 42 class DummyProofVerifierCallback : public ProofVerifierCallback { |
44 public: | 43 public: |
45 DummyProofVerifierCallback() {} | 44 DummyProofVerifierCallback() {} |
46 ~DummyProofVerifierCallback() override {} | 45 ~DummyProofVerifierCallback() override {} |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 bool enable_stateless_rejects; | 77 bool enable_stateless_rejects; |
79 // If true, this forces the server to send a stateless reject when | 78 // If true, this forces the server to send a stateless reject when |
80 // rejecting messages. This should be a no-op if | 79 // rejecting messages. This should be a no-op if |
81 // enable_stateless_rejects is false. | 80 // enable_stateless_rejects is false. |
82 bool use_stateless_rejects; | 81 bool use_stateless_rejects; |
83 // Versions supported by client and server. | 82 // Versions supported by client and server. |
84 QuicVersionVector supported_versions; | 83 QuicVersionVector supported_versions; |
85 }; | 84 }; |
86 | 85 |
87 // Constructs various test permutations. | 86 // Constructs various test permutations. |
88 vector<TestParams> GetTestParams() { | 87 std::vector<TestParams> GetTestParams() { |
89 vector<TestParams> params; | 88 std::vector<TestParams> params; |
90 static const bool kTrueFalse[] = {true, false}; | 89 static const bool kTrueFalse[] = {true, false}; |
91 for (bool enable_stateless_rejects : kTrueFalse) { | 90 for (bool enable_stateless_rejects : kTrueFalse) { |
92 for (bool use_stateless_rejects : kTrueFalse) { | 91 for (bool use_stateless_rejects : kTrueFalse) { |
93 // Start with all versions, remove highest on each iteration. | 92 // Start with all versions, remove highest on each iteration. |
94 QuicVersionVector supported_versions = AllSupportedVersions(); | 93 QuicVersionVector supported_versions = AllSupportedVersions(); |
95 while (!supported_versions.empty()) { | 94 while (!supported_versions.empty()) { |
96 params.push_back(TestParams(enable_stateless_rejects, | 95 params.push_back(TestParams(enable_stateless_rejects, |
97 use_stateless_rejects, supported_versions)); | 96 use_stateless_rejects, supported_versions)); |
98 supported_versions.erase(supported_versions.begin()); | 97 supported_versions.erase(supported_versions.begin()); |
99 } | 98 } |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 EXPECT_TRUE(out_.GetStringPiece(kPROF, &proof)); | 902 EXPECT_TRUE(out_.GetStringPiece(kPROF, &proof)); |
904 EXPECT_TRUE(out_.GetStringPiece(kSCFG, &scfg_str)); | 903 EXPECT_TRUE(out_.GetStringPiece(kSCFG, &scfg_str)); |
905 std::unique_ptr<CryptoHandshakeMessage> scfg( | 904 std::unique_ptr<CryptoHandshakeMessage> scfg( |
906 CryptoFramer::ParseMessage(scfg_str)); | 905 CryptoFramer::ParseMessage(scfg_str)); |
907 StringPiece scid; | 906 StringPiece scid; |
908 EXPECT_TRUE(scfg->GetStringPiece(kSCID, &scid)); | 907 EXPECT_TRUE(scfg->GetStringPiece(kSCID, &scid)); |
909 EXPECT_NE(scid, kOldConfigId); | 908 EXPECT_NE(scid, kOldConfigId); |
910 | 909 |
911 // Get certs from compressed certs. | 910 // Get certs from compressed certs. |
912 const CommonCertSets* common_cert_sets(CommonCertSets::GetInstanceQUIC()); | 911 const CommonCertSets* common_cert_sets(CommonCertSets::GetInstanceQUIC()); |
913 vector<string> cached_certs; | 912 std::vector<string> cached_certs; |
914 | 913 |
915 vector<string> certs; | 914 std::vector<string> certs; |
916 ASSERT_TRUE(CertCompressor::DecompressChain(cert, cached_certs, | 915 ASSERT_TRUE(CertCompressor::DecompressChain(cert, cached_certs, |
917 common_cert_sets, &certs)); | 916 common_cert_sets, &certs)); |
918 | 917 |
919 // Check that the proof in the REJ message is valid. | 918 // Check that the proof in the REJ message is valid. |
920 std::unique_ptr<ProofVerifier> proof_verifier( | 919 std::unique_ptr<ProofVerifier> proof_verifier( |
921 CryptoTestUtils::ProofVerifierForTesting()); | 920 CryptoTestUtils::ProofVerifierForTesting()); |
922 std::unique_ptr<ProofVerifyContext> verify_context( | 921 std::unique_ptr<ProofVerifyContext> verify_context( |
923 CryptoTestUtils::ProofVerifyContextForTesting()); | 922 CryptoTestUtils::ProofVerifyContextForTesting()); |
924 std::unique_ptr<ProofVerifyDetails> details; | 923 std::unique_ptr<ProofVerifyDetails> details; |
925 string error_details; | 924 string error_details; |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1281 EXPECT_EQ(0, strike_register_client_->PendingVerifications()); | 1280 EXPECT_EQ(0, strike_register_client_->PendingVerifications()); |
1282 } else { | 1281 } else { |
1283 // version 33. | 1282 // version 33. |
1284 ASSERT_EQ(kSHLO, out_.tag()); | 1283 ASSERT_EQ(kSHLO, out_.tag()); |
1285 CheckServerHello(out_); | 1284 CheckServerHello(out_); |
1286 } | 1285 } |
1287 } | 1286 } |
1288 | 1287 |
1289 } // namespace test | 1288 } // namespace test |
1290 } // namespace net | 1289 } // namespace net |
OLD | NEW |