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

Side by Side Diff: net/tools/quic/stateless_rejector_test.cc

Issue 2678973002: Replace va_arg version of crypto_test_utils::Message with a more modern vector argument version. (Closed)
Patch Set: Created 3 years, 10 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/tools/quic/quic_dispatcher_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 string stk_hex_; 163 string stk_hex_;
164 }; 164 };
165 165
166 INSTANTIATE_TEST_CASE_P(Flags, 166 INSTANTIATE_TEST_CASE_P(Flags,
167 StatelessRejectorTest, 167 StatelessRejectorTest,
168 ::testing::ValuesIn(GetTestParams()), 168 ::testing::ValuesIn(GetTestParams()),
169 TestParamToString); 169 TestParamToString);
170 170
171 TEST_P(StatelessRejectorTest, InvalidChlo) { 171 TEST_P(StatelessRejectorTest, InvalidChlo) {
172 // clang-format off 172 // clang-format off
173 const CryptoHandshakeMessage client_hello = crypto_test_utils::Message( 173 const CryptoHandshakeMessage client_hello = crypto_test_utils::CreateCHLO(
174 "CHLO", 174 {{"PDMD", "X509"},
175 "PDMD", "X509", 175 {"COPT", "SREJ"}});
176 "COPT", "SREJ",
177 nullptr);
178 // clang-format on 176 // clang-format on
179 rejector_->OnChlo(GetParam().version, kConnectionId, 177 rejector_->OnChlo(GetParam().version, kConnectionId,
180 kServerDesignateConnectionId, client_hello); 178 kServerDesignateConnectionId, client_hello);
181 179
182 if (GetParam().flags != ENABLED) { 180 if (GetParam().flags != ENABLED) {
183 EXPECT_EQ(StatelessRejector::UNSUPPORTED, rejector_->state()); 181 EXPECT_EQ(StatelessRejector::UNSUPPORTED, rejector_->state());
184 return; 182 return;
185 } 183 }
186 184
187 // The StatelessRejector is undecided - proceed with async processing 185 // The StatelessRejector is undecided - proceed with async processing
188 ASSERT_EQ(StatelessRejector::UNKNOWN, rejector_->state()); 186 ASSERT_EQ(StatelessRejector::UNKNOWN, rejector_->state());
189 StatelessRejector::Process(std::move(rejector_), 187 StatelessRejector::Process(std::move(rejector_),
190 QuicMakeUnique<ProcessDoneCallback>(this)); 188 QuicMakeUnique<ProcessDoneCallback>(this));
191 189
192 EXPECT_EQ(StatelessRejector::FAILED, rejector_->state()); 190 EXPECT_EQ(StatelessRejector::FAILED, rejector_->state());
193 EXPECT_EQ(QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER, rejector_->error()); 191 EXPECT_EQ(QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER, rejector_->error());
194 } 192 }
195 193
196 TEST_P(StatelessRejectorTest, ValidChloWithoutSrejSupport) { 194 TEST_P(StatelessRejectorTest, ValidChloWithoutSrejSupport) {
197 // clang-format off 195 // clang-format off
198 const CryptoHandshakeMessage client_hello = crypto_test_utils::Message( 196 const CryptoHandshakeMessage client_hello = crypto_test_utils::CreateCHLO(
199 "CHLO", 197 {{"PDMD", "X509"},
200 "PDMD", "X509", 198 {"AEAD", "AESG"},
201 "AEAD", "AESG", 199 {"KEXS", "C255"},
202 "KEXS", "C255", 200 {"PUBS", pubs_hex_},
203 "PUBS", pubs_hex_.c_str(), 201 {"NONC", nonc_hex_},
204 "NONC", nonc_hex_.c_str(), 202 {"VER\0", ver_hex_}},
205 "VER\0", ver_hex_.c_str(), 203 kClientHelloMinimumSize);
206 "$padding", static_cast<int>(kClientHelloMinimumSize),
207 nullptr);
208 // clang-format on 204 // clang-format on
209 205
210 rejector_->OnChlo(GetParam().version, kConnectionId, 206 rejector_->OnChlo(GetParam().version, kConnectionId,
211 kServerDesignateConnectionId, client_hello); 207 kServerDesignateConnectionId, client_hello);
212 EXPECT_EQ(StatelessRejector::UNSUPPORTED, rejector_->state()); 208 EXPECT_EQ(StatelessRejector::UNSUPPORTED, rejector_->state());
213 } 209 }
214 210
215 TEST_P(StatelessRejectorTest, RejectChlo) { 211 TEST_P(StatelessRejectorTest, RejectChlo) {
216 // clang-format off 212 // clang-format off
217 const CryptoHandshakeMessage client_hello = crypto_test_utils::Message( 213 const CryptoHandshakeMessage client_hello = crypto_test_utils::CreateCHLO(
218 "CHLO", 214 {{"PDMD", "X509"},
219 "PDMD", "X509", 215 {"AEAD", "AESG"},
220 "AEAD", "AESG", 216 {"KEXS", "C255"},
221 "KEXS", "C255", 217 {"COPT", "SREJ"},
222 "COPT", "SREJ", 218 {"SCID", scid_hex_},
223 "SCID", scid_hex_.c_str(), 219 {"PUBS", pubs_hex_},
224 "PUBS", pubs_hex_.c_str(), 220 {"NONC", nonc_hex_},
225 "NONC", nonc_hex_.c_str(), 221 {"#004b5453", stk_hex_},
226 "#004b5453", stk_hex_.c_str(), 222 {"VER\0", ver_hex_}},
227 "VER\0", ver_hex_.c_str(), 223 kClientHelloMinimumSize);
228 "$padding", static_cast<int>(kClientHelloMinimumSize),
229 nullptr);
230 // clang-format on 224 // clang-format on
231 225
232 rejector_->OnChlo(GetParam().version, kConnectionId, 226 rejector_->OnChlo(GetParam().version, kConnectionId,
233 kServerDesignateConnectionId, client_hello); 227 kServerDesignateConnectionId, client_hello);
234 if (GetParam().flags != ENABLED) { 228 if (GetParam().flags != ENABLED) {
235 EXPECT_EQ(StatelessRejector::UNSUPPORTED, rejector_->state()); 229 EXPECT_EQ(StatelessRejector::UNSUPPORTED, rejector_->state());
236 return; 230 return;
237 } 231 }
238 232
239 // The StatelessRejector is undecided - proceed with async processing 233 // The StatelessRejector is undecided - proceed with async processing
(...skipping 12 matching lines...) Expand all
252 EXPECT_EQ(INVALID_EXPECTED_LEAF_CERTIFICATE, 246 EXPECT_EQ(INVALID_EXPECTED_LEAF_CERTIFICATE,
253 static_cast<HandshakeFailureReason>(reject_reasons[0])); 247 static_cast<HandshakeFailureReason>(reject_reasons[0]));
254 } 248 }
255 249
256 TEST_P(StatelessRejectorTest, AcceptChlo) { 250 TEST_P(StatelessRejectorTest, AcceptChlo) {
257 const uint64_t xlct = crypto_test_utils::LeafCertHashForTesting(); 251 const uint64_t xlct = crypto_test_utils::LeafCertHashForTesting();
258 const string xlct_hex = 252 const string xlct_hex =
259 "#" + QuicTextUtils::HexEncode(reinterpret_cast<const char*>(&xlct), 253 "#" + QuicTextUtils::HexEncode(reinterpret_cast<const char*>(&xlct),
260 sizeof(xlct)); 254 sizeof(xlct));
261 // clang-format off 255 // clang-format off
262 const CryptoHandshakeMessage client_hello = crypto_test_utils::Message( 256 const CryptoHandshakeMessage client_hello = crypto_test_utils::CreateCHLO(
263 "CHLO", 257 {{"PDMD", "X509"},
264 "PDMD", "X509", 258 {"AEAD", "AESG"},
265 "AEAD", "AESG", 259 {"KEXS", "C255"},
266 "KEXS", "C255", 260 {"COPT", "SREJ"},
267 "COPT", "SREJ", 261 {"SCID", scid_hex_},
268 "SCID", scid_hex_.c_str(), 262 {"PUBS", pubs_hex_},
269 "PUBS", pubs_hex_.c_str(), 263 {"NONC", nonc_hex_},
270 "NONC", nonc_hex_.c_str(), 264 {"#004b5453", stk_hex_},
271 "#004b5453", stk_hex_.c_str(), 265 {"VER\0", ver_hex_},
272 "VER\0", ver_hex_.c_str(), 266 {"XLCT", xlct_hex}},
273 "XLCT", xlct_hex.c_str(), 267 kClientHelloMinimumSize);
274 "$padding", static_cast<int>(kClientHelloMinimumSize),
275 nullptr);
276 // clang-format on 268 // clang-format on
277 269
278 rejector_->OnChlo(GetParam().version, kConnectionId, 270 rejector_->OnChlo(GetParam().version, kConnectionId,
279 kServerDesignateConnectionId, client_hello); 271 kServerDesignateConnectionId, client_hello);
280 if (GetParam().flags != ENABLED) { 272 if (GetParam().flags != ENABLED) {
281 EXPECT_EQ(StatelessRejector::UNSUPPORTED, rejector_->state()); 273 EXPECT_EQ(StatelessRejector::UNSUPPORTED, rejector_->state());
282 return; 274 return;
283 } 275 }
284 276
285 // The StatelessRejector is undecided - proceed with async processing 277 // The StatelessRejector is undecided - proceed with async processing
286 ASSERT_EQ(StatelessRejector::UNKNOWN, rejector_->state()); 278 ASSERT_EQ(StatelessRejector::UNKNOWN, rejector_->state());
287 StatelessRejector::Process(std::move(rejector_), 279 StatelessRejector::Process(std::move(rejector_),
288 QuicMakeUnique<ProcessDoneCallback>(this)); 280 QuicMakeUnique<ProcessDoneCallback>(this));
289 281
290 EXPECT_EQ(StatelessRejector::ACCEPTED, rejector_->state()); 282 EXPECT_EQ(StatelessRejector::ACCEPTED, rejector_->state());
291 } 283 }
292 284
293 } // namespace 285 } // namespace
294 } // namespace test 286 } // namespace test
295 } // namespace net 287 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_dispatcher_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698