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/core/crypto/quic_crypto_client_config.h" | 5 #include "net/quic/core/crypto/quic_crypto_client_config.h" |
6 | 6 |
7 #include "net/quic/core/crypto/proof_verifier.h" | 7 #include "net/quic/core/crypto/proof_verifier.h" |
8 #include "net/quic/core/quic_server_id.h" | 8 #include "net/quic/core/quic_server_id.h" |
| 9 #include "net/quic/core/quic_utils.h" |
| 10 #include "net/quic/platform/api/quic_endian.h" |
9 #include "net/quic/test_tools/crypto_test_utils.h" | 11 #include "net/quic/test_tools/crypto_test_utils.h" |
10 #include "net/quic/test_tools/mock_random.h" | 12 #include "net/quic/test_tools/mock_random.h" |
11 #include "net/quic/test_tools/quic_test_utils.h" | 13 #include "net/quic/test_tools/quic_test_utils.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
13 | 15 |
14 using std::string; | 16 using std::string; |
15 | 17 |
16 namespace net { | 18 namespace net { |
17 namespace test { | 19 namespace test { |
18 namespace { | 20 namespace { |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 QuicCryptoClientConfig::CachedState cached; | 520 QuicCryptoClientConfig::CachedState cached; |
519 QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params( | 521 QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params( |
520 new QuicCryptoNegotiatedParameters); | 522 new QuicCryptoNegotiatedParameters); |
521 string error; | 523 string error; |
522 QuicCryptoClientConfig config(crypto_test_utils::ProofVerifierForTesting()); | 524 QuicCryptoClientConfig config(crypto_test_utils::ProofVerifierForTesting()); |
523 EXPECT_EQ(QUIC_NO_ERROR, | 525 EXPECT_EQ(QUIC_NO_ERROR, |
524 config.ProcessRejection(rej, QuicWallTime::FromUNIXSeconds(0), | 526 config.ProcessRejection(rej, QuicWallTime::FromUNIXSeconds(0), |
525 AllSupportedVersions().front(), "", &cached, | 527 AllSupportedVersions().front(), "", &cached, |
526 out_params, &error)); | 528 out_params, &error)); |
527 EXPECT_TRUE(cached.has_server_designated_connection_id()); | 529 EXPECT_TRUE(cached.has_server_designated_connection_id()); |
528 EXPECT_EQ(kConnectionId, cached.GetNextServerDesignatedConnectionId()); | 530 EXPECT_EQ(QuicUtils::IsConnectionIdWireFormatBigEndian(Perspective::IS_CLIENT) |
| 531 ? QuicEndian::NetToHost64(kConnectionId) |
| 532 : kConnectionId, |
| 533 cached.GetNextServerDesignatedConnectionId()); |
529 EXPECT_EQ(server_nonce, cached.GetNextServerNonce()); | 534 EXPECT_EQ(server_nonce, cached.GetNextServerNonce()); |
530 } | 535 } |
531 | 536 |
532 TEST(QuicCryptoClientConfigTest, BadlyFormattedStatelessReject) { | 537 TEST(QuicCryptoClientConfigTest, BadlyFormattedStatelessReject) { |
533 // Create a dummy reject message and mark it as stateless. Do not | 538 // Create a dummy reject message and mark it as stateless. Do not |
534 // add an server-designated connection-id. | 539 // add an server-designated connection-id. |
535 CryptoHandshakeMessage rej; | 540 CryptoHandshakeMessage rej; |
536 crypto_test_utils::FillInDummyReject(&rej, /* stateless */ true); | 541 crypto_test_utils::FillInDummyReject(&rej, /* stateless */ true); |
537 | 542 |
538 // Now process the rejection. | 543 // Now process the rejection. |
(...skipping 28 matching lines...) Expand all Loading... |
567 new QuicCryptoNegotiatedParameters); | 572 new QuicCryptoNegotiatedParameters); |
568 string error_details; | 573 string error_details; |
569 EXPECT_EQ(QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER, | 574 EXPECT_EQ(QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER, |
570 config.ProcessServerHello(msg, 0, version, supported_versions, | 575 config.ProcessServerHello(msg, 0, version, supported_versions, |
571 &cached, out_params, &error_details)); | 576 &cached, out_params, &error_details)); |
572 EXPECT_EQ("server hello missing server nonce", error_details); | 577 EXPECT_EQ("server hello missing server nonce", error_details); |
573 } | 578 } |
574 | 579 |
575 } // namespace test | 580 } // namespace test |
576 } // namespace net | 581 } // namespace net |
OLD | NEW |