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/tools/quic/quic_client_session.h" | 5 #include "net/tools/quic/quic_client_session.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "net/quic/core/crypto/aes_128_gcm_12_encrypter.h" | 9 #include "net/quic/core/crypto/aes_128_gcm_12_encrypter.h" |
10 #include "net/quic/core/quic_flags.h" | 10 #include "net/quic/core/quic_flags.h" |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 // Verifiy that small, invalid packets don't close the connection. | 260 // Verifiy that small, invalid packets don't close the connection. |
261 char buf[2] = {0x00, 0x01}; | 261 char buf[2] = {0x00, 0x01}; |
262 QuicReceivedPacket valid_packet(buf, 2, QuicTime::Zero(), false); | 262 QuicReceivedPacket valid_packet(buf, 2, QuicTime::Zero(), false); |
263 // Close connection shouldn't be called. | 263 // Close connection shouldn't be called. |
264 EXPECT_CALL(*connection_, CloseConnection(_, _, _)).Times(0); | 264 EXPECT_CALL(*connection_, CloseConnection(_, _, _)).Times(0); |
265 session_->ProcessUdpPacket(client_address, server_address, valid_packet); | 265 session_->ProcessUdpPacket(client_address, server_address, valid_packet); |
266 | 266 |
267 // Verify that a non-decryptable packet doesn't close the connection. | 267 // Verify that a non-decryptable packet doesn't close the connection. |
268 QuicConnectionId connection_id = session_->connection()->connection_id(); | 268 QuicConnectionId connection_id = session_->connection()->connection_id(); |
269 std::unique_ptr<QuicEncryptedPacket> packet(ConstructEncryptedPacket( | 269 std::unique_ptr<QuicEncryptedPacket> packet(ConstructEncryptedPacket( |
270 connection_id, false, false, false, 100, "data", | 270 connection_id, false, false, 100, "data", PACKET_8BYTE_CONNECTION_ID, |
271 PACKET_8BYTE_CONNECTION_ID, PACKET_6BYTE_PACKET_NUMBER, nullptr, | 271 PACKET_6BYTE_PACKET_NUMBER, nullptr, Perspective::IS_SERVER)); |
272 Perspective::IS_SERVER)); | |
273 std::unique_ptr<QuicReceivedPacket> received( | 272 std::unique_ptr<QuicReceivedPacket> received( |
274 ConstructReceivedPacket(*packet, QuicTime::Zero())); | 273 ConstructReceivedPacket(*packet, QuicTime::Zero())); |
275 // Change the last byte of the encrypted data. | 274 // Change the last byte of the encrypted data. |
276 *(const_cast<char*>(received->data() + received->length() - 1)) += 1; | 275 *(const_cast<char*>(received->data() + received->length() - 1)) += 1; |
277 EXPECT_CALL(*connection_, CloseConnection(_, _, _)).Times(0); | 276 EXPECT_CALL(*connection_, CloseConnection(_, _, _)).Times(0); |
278 EXPECT_CALL(*connection_, OnError(Truly(CheckForDecryptionError))).Times(1); | 277 EXPECT_CALL(*connection_, OnError(Truly(CheckForDecryptionError))).Times(1); |
279 session_->ProcessUdpPacket(client_address, server_address, *received); | 278 session_->ProcessUdpPacket(client_address, server_address, *received); |
280 } | 279 } |
281 | 280 |
282 // A packet with invalid framing should cause a connection to be closed. | 281 // A packet with invalid framing should cause a connection to be closed. |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 QuicClientPromisedInfo* promised = | 496 QuicClientPromisedInfo* promised = |
498 session_->GetPromisedById(promised_stream_id_); | 497 session_->GetPromisedById(promised_stream_id_); |
499 EXPECT_NE(promised, nullptr); | 498 EXPECT_NE(promised, nullptr); |
500 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); | 499 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); |
501 EXPECT_EQ(session_->GetPromisedStream(promised_stream_id_), nullptr); | 500 EXPECT_EQ(session_->GetPromisedStream(promised_stream_id_), nullptr); |
502 } | 501 } |
503 | 502 |
504 } // namespace | 503 } // namespace |
505 } // namespace test | 504 } // namespace test |
506 } // namespace net | 505 } // namespace net |
OLD | NEW |