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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 ASSERT_EQ(1u, stream_.messages()->size()); | 91 ASSERT_EQ(1u, stream_.messages()->size()); |
92 const CryptoHandshakeMessage& message = (*stream_.messages())[0]; | 92 const CryptoHandshakeMessage& message = (*stream_.messages())[0]; |
93 EXPECT_EQ(kSHLO, message.tag()); | 93 EXPECT_EQ(kSHLO, message.tag()); |
94 EXPECT_EQ(2u, message.tag_value_map().size()); | 94 EXPECT_EQ(2u, message.tag_value_map().size()); |
95 EXPECT_EQ("abc", CryptoTestUtils::GetValueForTag(message, 1)); | 95 EXPECT_EQ("abc", CryptoTestUtils::GetValueForTag(message, 1)); |
96 EXPECT_EQ("def", CryptoTestUtils::GetValueForTag(message, 2)); | 96 EXPECT_EQ("def", CryptoTestUtils::GetValueForTag(message, 2)); |
97 } | 97 } |
98 | 98 |
99 TEST_F(QuicCryptoStreamTest, ProcessBadData) { | 99 TEST_F(QuicCryptoStreamTest, ProcessBadData) { |
100 string bad(message_data_->data(), message_data_->length()); | 100 string bad(message_data_->data(), message_data_->length()); |
101 bad[8] = 0x7F; // out of order tag | 101 const int kFirstTagIndex = sizeof(uint32) + // message tag |
| 102 sizeof(uint16) + // number of tag-value pairs |
| 103 sizeof(uint16); // padding |
| 104 EXPECT_EQ(1, bad[kFirstTagIndex]); |
| 105 bad[kFirstTagIndex] = 0x7F; // out of order tag |
102 | 106 |
103 EXPECT_CALL(*connection_, | 107 EXPECT_CALL(*connection_, |
104 SendConnectionClose(QUIC_CRYPTO_TAGS_OUT_OF_ORDER)); | 108 SendConnectionClose(QUIC_CRYPTO_TAGS_OUT_OF_ORDER)); |
105 EXPECT_EQ(0u, stream_.ProcessData(bad.data(), bad.length())); | 109 EXPECT_EQ(0u, stream_.ProcessData(bad.data(), bad.length())); |
106 } | 110 } |
107 | 111 |
108 } // namespace | 112 } // namespace |
109 } // namespace test | 113 } // namespace test |
110 } // namespace net | 114 } // namespace net |
OLD | NEW |