| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/quic_crypto_stream.h" | 5 #include "net/quic/quic_crypto_stream.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 MockSession session_; | 67 MockSession session_; |
| 68 MockQuicCryptoStream stream_; | 68 MockQuicCryptoStream stream_; |
| 69 CryptoHandshakeMessage message_; | 69 CryptoHandshakeMessage message_; |
| 70 scoped_ptr<QuicData> message_data_; | 70 scoped_ptr<QuicData> message_data_; |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 DISALLOW_COPY_AND_ASSIGN(QuicCryptoStreamTest); | 73 DISALLOW_COPY_AND_ASSIGN(QuicCryptoStreamTest); |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 TEST_F(QuicCryptoStreamTest, NotInitiallyConected) { | 76 TEST_F(QuicCryptoStreamTest, NotInitiallyConected) { |
| 77 EXPECT_FALSE(stream_.handshake_complete()); | 77 EXPECT_FALSE(stream_.encryption_established()); |
| 78 EXPECT_FALSE(stream_.handshake_confirmed()); |
| 78 } | 79 } |
| 79 | 80 |
| 80 TEST_F(QuicCryptoStreamTest, OnErrorClosesConnection) { | 81 TEST_F(QuicCryptoStreamTest, OnErrorClosesConnection) { |
| 81 CryptoFramer framer; | 82 CryptoFramer framer; |
| 82 EXPECT_CALL(session_, ConnectionClose(QUIC_NO_ERROR, false)); | 83 EXPECT_CALL(session_, ConnectionClose(QUIC_NO_ERROR, false)); |
| 83 stream_.OnError(&framer); | 84 stream_.OnError(&framer); |
| 84 } | 85 } |
| 85 | 86 |
| 86 TEST_F(QuicCryptoStreamTest, ProcessData) { | 87 TEST_F(QuicCryptoStreamTest, ProcessData) { |
| 87 EXPECT_EQ(message_data_->length(), | 88 EXPECT_EQ(message_data_->length(), |
| 88 stream_.ProcessData(message_data_->data(), | 89 stream_.ProcessData(message_data_->data(), |
| 89 message_data_->length())); | 90 message_data_->length())); |
| 90 ASSERT_EQ(1u, stream_.messages()->size()); | 91 ASSERT_EQ(1u, stream_.messages()->size()); |
| 91 const CryptoHandshakeMessage& message = (*stream_.messages())[0]; | 92 const CryptoHandshakeMessage& message = (*stream_.messages())[0]; |
| 92 EXPECT_EQ(kSHLO, message.tag()); | 93 EXPECT_EQ(kSHLO, message.tag()); |
| 93 EXPECT_EQ(2u, message.tag_value_map().size()); | 94 EXPECT_EQ(2u, message.tag_value_map().size()); |
| 94 EXPECT_EQ("abc", CryptoTestUtils::GetValueForTag(message, 1)); | 95 EXPECT_EQ("abc", CryptoTestUtils::GetValueForTag(message, 1)); |
| 95 EXPECT_EQ("def", CryptoTestUtils::GetValueForTag(message, 2)); | 96 EXPECT_EQ("def", CryptoTestUtils::GetValueForTag(message, 2)); |
| 96 } | 97 } |
| 97 | 98 |
| 98 TEST_F(QuicCryptoStreamTest, ProcessBadData) { | 99 TEST_F(QuicCryptoStreamTest, ProcessBadData) { |
| 99 string bad(message_data_->data(), message_data_->length()); | 100 string bad(message_data_->data(), message_data_->length()); |
| 100 bad[6] = 0x7F; // out of order tag | 101 bad[8] = 0x7F; // out of order tag |
| 101 | 102 |
| 102 EXPECT_CALL(*connection_, | 103 EXPECT_CALL(*connection_, |
| 103 SendConnectionClose(QUIC_CRYPTO_TAGS_OUT_OF_ORDER)); | 104 SendConnectionClose(QUIC_CRYPTO_TAGS_OUT_OF_ORDER)); |
| 104 EXPECT_EQ(0u, stream_.ProcessData(bad.data(), bad.length())); | 105 EXPECT_EQ(0u, stream_.ProcessData(bad.data(), bad.length())); |
| 105 } | 106 } |
| 106 | 107 |
| 107 } // namespace | 108 } // namespace |
| 108 } // namespace test | 109 } // namespace test |
| 109 } // namespace net | 110 } // namespace net |
| OLD | NEW |