OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/tools/quic/stateless_rejector.h" | 5 #include "net/tools/quic/stateless_rejector.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "net/quic/core/crypto/crypto_handshake_message.h" | 10 #include "net/quic/core/crypto/crypto_handshake_message.h" |
11 #include "net/quic/core/crypto/proof_source.h" | 11 #include "net/quic/core/crypto/proof_source.h" |
12 #include "net/quic/core/quic_utils.h" | 12 #include "net/quic/core/quic_utils.h" |
13 #include "net/quic/platform/api/quic_flags.h" | 13 #include "net/quic/platform/api/quic_flags.h" |
14 #include "net/quic/platform/api/quic_logging.h" | 14 #include "net/quic/platform/api/quic_logging.h" |
15 #include "net/quic/platform/api/quic_ptr_util.h" | 15 #include "net/quic/platform/api/quic_ptr_util.h" |
16 #include "net/quic/platform/api/quic_str_cat.h" | 16 #include "net/quic/platform/api/quic_str_cat.h" |
17 #include "net/quic/platform/api/quic_string_piece.h" | 17 #include "net/quic/platform/api/quic_string_piece.h" |
| 18 #include "net/quic/platform/api/quic_test.h" |
18 #include "net/quic/platform/api/quic_text_utils.h" | 19 #include "net/quic/platform/api/quic_text_utils.h" |
19 #include "net/quic/test_tools/crypto_test_utils.h" | 20 #include "net/quic/test_tools/crypto_test_utils.h" |
20 #include "net/quic/test_tools/quic_crypto_server_config_peer.h" | 21 #include "net/quic/test_tools/quic_crypto_server_config_peer.h" |
21 #include "net/quic/test_tools/quic_test_utils.h" | 22 #include "net/quic/test_tools/quic_test_utils.h" |
22 | 23 |
23 using std::string; | 24 using std::string; |
24 | 25 |
25 namespace net { | 26 namespace net { |
26 namespace test { | 27 namespace test { |
27 namespace { | 28 namespace { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 for (QuicVersion version : AllSupportedVersions()) { | 67 for (QuicVersion version : AllSupportedVersions()) { |
67 TestParams param; | 68 TestParams param; |
68 param.version = version; | 69 param.version = version; |
69 param.flags = flags; | 70 param.flags = flags; |
70 params.push_back(param); | 71 params.push_back(param); |
71 } | 72 } |
72 } | 73 } |
73 return params; | 74 return params; |
74 } | 75 } |
75 | 76 |
76 class StatelessRejectorTest : public ::testing::TestWithParam<TestParams> { | 77 class StatelessRejectorTest : public QuicTestWithParam<TestParams> { |
77 public: | 78 public: |
78 StatelessRejectorTest() | 79 StatelessRejectorTest() |
79 : proof_source_(crypto_test_utils::ProofSourceForTesting()), | 80 : proof_source_(crypto_test_utils::ProofSourceForTesting()), |
80 config_(QuicCryptoServerConfig::TESTING, | 81 config_(QuicCryptoServerConfig::TESTING, |
81 QuicRandom::GetInstance(), | 82 QuicRandom::GetInstance(), |
82 crypto_test_utils::ProofSourceForTesting()), | 83 crypto_test_utils::ProofSourceForTesting()), |
83 config_peer_(&config_), | 84 config_peer_(&config_), |
84 compressed_certs_cache_( | 85 compressed_certs_cache_( |
85 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize), | 86 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize), |
86 rejector_(QuicMakeUnique<StatelessRejector>( | 87 rejector_(QuicMakeUnique<StatelessRejector>( |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 public: | 141 public: |
141 explicit ProcessDoneCallback(StatelessRejectorTest* test) : test_(test) {} | 142 explicit ProcessDoneCallback(StatelessRejectorTest* test) : test_(test) {} |
142 void Run(std::unique_ptr<StatelessRejector> rejector) override { | 143 void Run(std::unique_ptr<StatelessRejector> rejector) override { |
143 test_->rejector_ = std::move(rejector); | 144 test_->rejector_ = std::move(rejector); |
144 } | 145 } |
145 | 146 |
146 private: | 147 private: |
147 StatelessRejectorTest* test_; | 148 StatelessRejectorTest* test_; |
148 }; | 149 }; |
149 | 150 |
150 QuicFlagSaver flags_; // Save/restore all QUIC flag values. | |
151 | |
152 std::unique_ptr<ProofSource> proof_source_; | 151 std::unique_ptr<ProofSource> proof_source_; |
153 MockClock clock_; | 152 MockClock clock_; |
154 QuicCryptoServerConfig config_; | 153 QuicCryptoServerConfig config_; |
155 QuicCryptoServerConfigPeer config_peer_; | 154 QuicCryptoServerConfigPeer config_peer_; |
156 QuicCompressedCertsCache compressed_certs_cache_; | 155 QuicCompressedCertsCache compressed_certs_cache_; |
157 QuicCryptoServerConfig::ConfigOptions config_options_; | 156 QuicCryptoServerConfig::ConfigOptions config_options_; |
158 std::unique_ptr<StatelessRejector> rejector_; | 157 std::unique_ptr<StatelessRejector> rejector_; |
159 | 158 |
160 // Values used in CHLO messages | 159 // Values used in CHLO messages |
161 string scid_hex_; | 160 string scid_hex_; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 ASSERT_EQ(StatelessRejector::UNKNOWN, rejector_->state()); | 279 ASSERT_EQ(StatelessRejector::UNKNOWN, rejector_->state()); |
281 StatelessRejector::Process(std::move(rejector_), | 280 StatelessRejector::Process(std::move(rejector_), |
282 QuicMakeUnique<ProcessDoneCallback>(this)); | 281 QuicMakeUnique<ProcessDoneCallback>(this)); |
283 | 282 |
284 EXPECT_EQ(StatelessRejector::ACCEPTED, rejector_->state()); | 283 EXPECT_EQ(StatelessRejector::ACCEPTED, rejector_->state()); |
285 } | 284 } |
286 | 285 |
287 } // namespace | 286 } // namespace |
288 } // namespace test | 287 } // namespace test |
289 } // namespace net | 288 } // namespace net |
OLD | NEW |