OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "net/quic/crypto/quic_crypto_client_config.h" | 5 #include "net/quic/crypto/quic_crypto_client_config.h" |
6 | 6 |
7 #include "net/quic/crypto/proof_verifier.h" | 7 #include "net/quic/crypto/proof_verifier.h" |
8 #include "net/quic/quic_server_id.h" | 8 #include "net/quic/quic_server_id.h" |
9 #include "net/quic/test_tools/mock_random.h" | 9 #include "net/quic/test_tools/mock_random.h" |
10 #include "net/quic/test_tools/quic_test_utils.h" | 10 #include "net/quic/test_tools/quic_test_utils.h" |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 CryptoHandshakeMessage rej; | 363 CryptoHandshakeMessage rej; |
364 FillInDummyReject(&rej, /* stateless */ true); | 364 FillInDummyReject(&rej, /* stateless */ true); |
365 const QuicConnectionId kConnectionId = 0xdeadbeef; | 365 const QuicConnectionId kConnectionId = 0xdeadbeef; |
366 rej.SetValue(kRCID, kConnectionId); | 366 rej.SetValue(kRCID, kConnectionId); |
367 | 367 |
368 // Now process the rejection. | 368 // Now process the rejection. |
369 QuicCryptoClientConfig::CachedState cached; | 369 QuicCryptoClientConfig::CachedState cached; |
370 QuicCryptoNegotiatedParameters out_params; | 370 QuicCryptoNegotiatedParameters out_params; |
371 string error; | 371 string error; |
372 QuicCryptoClientConfig config; | 372 QuicCryptoClientConfig config; |
373 EXPECT_EQ( | 373 EXPECT_EQ(QUIC_NO_ERROR, config.ProcessRejection( |
374 QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT, | 374 rej, QuicWallTime::FromUNIXSeconds(0), &cached, |
375 config.ProcessRejection(rej, QuicWallTime::FromUNIXSeconds(0), &cached, | 375 true, // is_https |
376 true, // is_https | 376 &out_params, &error)); |
377 &out_params, &error)); | |
378 EXPECT_TRUE(cached.has_server_designated_connection_id()); | 377 EXPECT_TRUE(cached.has_server_designated_connection_id()); |
379 EXPECT_EQ(kConnectionId, cached.GetNextServerDesignatedConnectionId()); | 378 EXPECT_EQ(kConnectionId, cached.GetNextServerDesignatedConnectionId()); |
380 } | 379 } |
381 | 380 |
382 TEST(QuicCryptoClientConfigTest, BadlyFormattedStatelessReject) { | 381 TEST(QuicCryptoClientConfigTest, BadlyFormattedStatelessReject) { |
383 // Create a dummy reject message and mark it as stateless. Do not | 382 // Create a dummy reject message and mark it as stateless. Do not |
384 // add an server-designated connection-id. | 383 // add an server-designated connection-id. |
385 CryptoHandshakeMessage rej; | 384 CryptoHandshakeMessage rej; |
386 FillInDummyReject(&rej, /* stateless */ true); | 385 FillInDummyReject(&rej, /* stateless */ true); |
387 | 386 |
388 // Now process the rejection. | 387 // Now process the rejection. |
389 QuicCryptoClientConfig::CachedState cached; | 388 QuicCryptoClientConfig::CachedState cached; |
390 QuicCryptoNegotiatedParameters out_params; | 389 QuicCryptoNegotiatedParameters out_params; |
391 string error; | 390 string error; |
392 QuicCryptoClientConfig config; | 391 QuicCryptoClientConfig config; |
393 EXPECT_EQ( | 392 EXPECT_EQ( |
394 QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND, | 393 QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND, |
395 config.ProcessRejection(rej, QuicWallTime::FromUNIXSeconds(0), &cached, | 394 config.ProcessRejection(rej, QuicWallTime::FromUNIXSeconds(0), &cached, |
396 true, // is_https | 395 true, // is_https |
397 &out_params, &error)); | 396 &out_params, &error)); |
398 EXPECT_FALSE(cached.has_server_designated_connection_id()); | 397 EXPECT_FALSE(cached.has_server_designated_connection_id()); |
399 EXPECT_EQ("Missing kRCID", error); | 398 EXPECT_EQ("Missing kRCID", error); |
400 } | 399 } |
401 | 400 |
402 } // namespace test | 401 } // namespace test |
403 } // namespace net | 402 } // namespace net |
OLD | NEW |