Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: net/tools/quic/quic_client_session_test.cc

Issue 515303003: Landing Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bug fix for 409191 Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/test_tools/quic_sent_packet_manager_peer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/base/ip_endpoint.h" 9 #include "net/base/ip_endpoint.h"
10 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" 10 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h"
11 #include "net/quic/quic_flags.h" 11 #include "net/quic/quic_flags.h"
12 #include "net/quic/test_tools/crypto_test_utils.h" 12 #include "net/quic/test_tools/crypto_test_utils.h"
13 #include "net/quic/test_tools/quic_session_peer.h" 13 #include "net/quic/test_tools/quic_session_peer.h"
14 #include "net/quic/test_tools/quic_test_utils.h" 14 #include "net/quic/test_tools/quic_test_utils.h"
15 #include "net/tools/quic/quic_spdy_client_stream.h" 15 #include "net/tools/quic/quic_spdy_client_stream.h"
16 #include "net/tools/quic/test_tools/quic_test_utils.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 using net::test::CryptoTestUtils; 19 using net::test::CryptoTestUtils;
19 using net::test::DefaultQuicConfig; 20 using net::test::DefaultQuicConfig;
20 using net::test::PacketSavingConnection; 21 using net::test::PacketSavingConnection;
21 using net::test::QuicSessionPeer; 22 using net::test::QuicSessionPeer;
22 using net::test::SupportedVersions; 23 using net::test::SupportedVersions;
24 using net::test::TestPeerIPAddress;
23 using net::test::ValueRestore; 25 using net::test::ValueRestore;
26 using net::test::kTestPort;
27 using net::tools::test::MockConnection;
28 using testing::Invoke;
24 using testing::_; 29 using testing::_;
25 30
26 namespace net { 31 namespace net {
27 namespace tools { 32 namespace tools {
28 namespace test { 33 namespace test {
29 namespace { 34 namespace {
30 35
31 const char kServerHostname[] = "www.example.com"; 36 const char kServerHostname[] = "www.example.com";
32 const uint16 kPort = 80; 37 const uint16 kPort = 80;
33 38
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 107
103 // Verify that headers stream is always protected and data streams are 108 // Verify that headers stream is always protected and data streams are
104 // optionally protected. 109 // optionally protected.
105 EXPECT_EQ(FEC_PROTECT_ALWAYS, 110 EXPECT_EQ(FEC_PROTECT_ALWAYS,
106 QuicSessionPeer::GetHeadersStream(session_.get())->fec_policy()); 111 QuicSessionPeer::GetHeadersStream(session_.get())->fec_policy());
107 QuicSpdyClientStream* stream = session_->CreateOutgoingDataStream(); 112 QuicSpdyClientStream* stream = session_->CreateOutgoingDataStream();
108 ASSERT_TRUE(stream); 113 ASSERT_TRUE(stream);
109 EXPECT_EQ(FEC_PROTECT_OPTIONAL, stream->fec_policy()); 114 EXPECT_EQ(FEC_PROTECT_OPTIONAL, stream->fec_policy());
110 } 115 }
111 116
117 TEST_P(ToolsQuicClientSessionTest, EmptyPacketReceived) {
118 // This test covers broken behavior that empty packets cause QUIC connection
119 // broken.
120
121 // Create Packet with 0 length.
122 QuicEncryptedPacket invalid_packet(nullptr, 0, false);
123 IPEndPoint server_address(TestPeerIPAddress(), kTestPort);
124 IPEndPoint client_address(TestPeerIPAddress(), kTestPort);
125
126 EXPECT_CALL(*reinterpret_cast<MockConnection*>(session_->connection()),
127 ProcessUdpPacket(server_address, client_address, _))
128 .WillRepeatedly(
129 Invoke(reinterpret_cast<MockConnection*>(session_->connection()),
130 &MockConnection::ReallyProcessUdpPacket));
131
132 // Expect call to close connection with error QUIC_INVALID_PACKET_HEADER.
133 // TODO(b/17206611): Correct behavior: packet should get dropped and
134 // connection should remain open.
135 EXPECT_CALL(*connection_, SendConnectionCloseWithDetails(
136 QUIC_INVALID_PACKET_HEADER, _)).Times(1);
137 session_->connection()->ProcessUdpPacket(client_address, server_address,
138 invalid_packet);
139
140 // Create a packet that causes DecryptPacket failed. The packet will get
141 // dropped without closing connection. This is a correct behavior.
142 char buf[2] = {0x00, 0x01};
143 QuicEncryptedPacket valid_packet(buf, 2, false);
144 // Close connection shouldn't be called.
145 EXPECT_CALL(*connection_, SendConnectionCloseWithDetails(_, _)).Times(0);
146 session_->connection()->ProcessUdpPacket(client_address, server_address,
147 valid_packet);
148 }
149
112 } // namespace 150 } // namespace
113 } // namespace test 151 } // namespace test
114 } // namespace tools 152 } // namespace tools
115 } // namespace net 153 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/quic_sent_packet_manager_peer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698