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_client_session.h" | 5 #include "net/quic/quic_client_session.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
13 #include "net/base/test_completion_callback.h" | 13 #include "net/base/test_completion_callback.h" |
14 #include "net/base/test_data_directory.h" | 14 #include "net/base/test_data_directory.h" |
15 #include "net/cert/cert_verify_result.h" | 15 #include "net/cert/cert_verify_result.h" |
16 #include "net/http/transport_security_state.h" | 16 #include "net/http/transport_security_state.h" |
17 #include "net/log/test_net_log.h" | 17 #include "net/log/test_net_log.h" |
18 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" | 18 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" |
19 #include "net/quic/crypto/crypto_protocol.h" | 19 #include "net/quic/crypto/crypto_protocol.h" |
20 #include "net/quic/crypto/proof_verifier_chromium.h" | 20 #include "net/quic/crypto/proof_verifier_chromium.h" |
21 #include "net/quic/crypto/quic_decrypter.h" | 21 #include "net/quic/crypto/quic_decrypter.h" |
22 #include "net/quic/crypto/quic_encrypter.h" | 22 #include "net/quic/crypto/quic_encrypter.h" |
23 #include "net/quic/crypto/quic_server_info.h" | 23 #include "net/quic/crypto/quic_server_info.h" |
24 #include "net/quic/test_tools/crypto_test_utils.h" | 24 #include "net/quic/test_tools/crypto_test_utils.h" |
25 #include "net/quic/test_tools/quic_client_session_peer.h" | 25 #include "net/quic/test_tools/quic_client_session_peer.h" |
| 26 #include "net/quic/test_tools/quic_spdy_session_peer.h" |
26 #include "net/quic/test_tools/quic_test_utils.h" | 27 #include "net/quic/test_tools/quic_test_utils.h" |
27 #include "net/quic/test_tools/simple_quic_framer.h" | 28 #include "net/quic/test_tools/simple_quic_framer.h" |
28 #include "net/socket/socket_test_util.h" | 29 #include "net/socket/socket_test_util.h" |
29 #include "net/spdy/spdy_test_utils.h" | 30 #include "net/spdy/spdy_test_utils.h" |
30 #include "net/test/cert_test_util.h" | 31 #include "net/test/cert_test_util.h" |
31 #include "net/udp/datagram_client_socket.h" | 32 #include "net/udp/datagram_client_socket.h" |
32 | 33 |
33 using testing::_; | 34 using testing::_; |
34 | 35 |
35 namespace net { | 36 namespace net { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 103 |
103 TEST_P(QuicClientSessionTest, CryptoConnect) { | 104 TEST_P(QuicClientSessionTest, CryptoConnect) { |
104 CompleteCryptoHandshake(); | 105 CompleteCryptoHandshake(); |
105 } | 106 } |
106 | 107 |
107 TEST_P(QuicClientSessionTest, MaxNumStreams) { | 108 TEST_P(QuicClientSessionTest, MaxNumStreams) { |
108 CompleteCryptoHandshake(); | 109 CompleteCryptoHandshake(); |
109 | 110 |
110 std::vector<QuicReliableClientStream*> streams; | 111 std::vector<QuicReliableClientStream*> streams; |
111 for (size_t i = 0; i < kDefaultMaxStreamsPerConnection; i++) { | 112 for (size_t i = 0; i < kDefaultMaxStreamsPerConnection; i++) { |
112 QuicReliableClientStream* stream = session_.CreateOutgoingDataStream(); | 113 QuicReliableClientStream* stream = session_.CreateOutgoingDynamicStream(); |
113 EXPECT_TRUE(stream); | 114 EXPECT_TRUE(stream); |
114 streams.push_back(stream); | 115 streams.push_back(stream); |
115 } | 116 } |
116 EXPECT_FALSE(session_.CreateOutgoingDataStream()); | 117 EXPECT_FALSE(session_.CreateOutgoingDynamicStream()); |
117 | 118 |
118 // Close a stream and ensure I can now open a new one. | 119 // Close a stream and ensure I can now open a new one. |
119 session_.CloseStream(streams[0]->id()); | 120 session_.CloseStream(streams[0]->id()); |
120 EXPECT_TRUE(session_.CreateOutgoingDataStream()); | 121 EXPECT_TRUE(session_.CreateOutgoingDynamicStream()); |
121 } | 122 } |
122 | 123 |
123 TEST_P(QuicClientSessionTest, MaxNumStreamsViaRequest) { | 124 TEST_P(QuicClientSessionTest, MaxNumStreamsViaRequest) { |
124 CompleteCryptoHandshake(); | 125 CompleteCryptoHandshake(); |
125 | 126 |
126 std::vector<QuicReliableClientStream*> streams; | 127 std::vector<QuicReliableClientStream*> streams; |
127 for (size_t i = 0; i < kDefaultMaxStreamsPerConnection; i++) { | 128 for (size_t i = 0; i < kDefaultMaxStreamsPerConnection; i++) { |
128 QuicReliableClientStream* stream = session_.CreateOutgoingDataStream(); | 129 QuicReliableClientStream* stream = session_.CreateOutgoingDynamicStream(); |
129 EXPECT_TRUE(stream); | 130 EXPECT_TRUE(stream); |
130 streams.push_back(stream); | 131 streams.push_back(stream); |
131 } | 132 } |
132 | 133 |
133 QuicReliableClientStream* stream; | 134 QuicReliableClientStream* stream; |
134 QuicClientSession::StreamRequest stream_request; | 135 QuicClientSession::StreamRequest stream_request; |
135 TestCompletionCallback callback; | 136 TestCompletionCallback callback; |
136 ASSERT_EQ(ERR_IO_PENDING, | 137 ASSERT_EQ(ERR_IO_PENDING, |
137 stream_request.StartRequest(session_.GetWeakPtr(), &stream, | 138 stream_request.StartRequest(session_.GetWeakPtr(), &stream, |
138 callback.callback())); | 139 callback.callback())); |
139 | 140 |
140 // Close a stream and ensure I can now open a new one. | 141 // Close a stream and ensure I can now open a new one. |
141 session_.CloseStream(streams[0]->id()); | 142 session_.CloseStream(streams[0]->id()); |
142 ASSERT_TRUE(callback.have_result()); | 143 ASSERT_TRUE(callback.have_result()); |
143 EXPECT_EQ(OK, callback.WaitForResult()); | 144 EXPECT_EQ(OK, callback.WaitForResult()); |
144 EXPECT_TRUE(stream != nullptr); | 145 EXPECT_TRUE(stream != nullptr); |
145 } | 146 } |
146 | 147 |
147 TEST_P(QuicClientSessionTest, GoAwayReceived) { | 148 TEST_P(QuicClientSessionTest, GoAwayReceived) { |
148 CompleteCryptoHandshake(); | 149 CompleteCryptoHandshake(); |
149 | 150 |
150 // After receiving a GoAway, I should no longer be able to create outgoing | 151 // After receiving a GoAway, I should no longer be able to create outgoing |
151 // streams. | 152 // streams. |
152 session_.OnGoAway(QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away.")); | 153 session_.OnGoAway(QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away.")); |
153 EXPECT_EQ(nullptr, session_.CreateOutgoingDataStream()); | 154 EXPECT_EQ(nullptr, session_.CreateOutgoingDynamicStream()); |
154 } | 155 } |
155 | 156 |
156 TEST_P(QuicClientSessionTest, CanPool) { | 157 TEST_P(QuicClientSessionTest, CanPool) { |
157 // Load a cert that is valid for: | 158 // Load a cert that is valid for: |
158 // www.example.org | 159 // www.example.org |
159 // mail.example.org | 160 // mail.example.org |
160 // www.example.com | 161 // www.example.com |
161 | 162 |
162 ProofVerifyDetailsChromium details; | 163 ProofVerifyDetailsChromium details; |
163 details.cert_verify_result.verified_cert = | 164 details.cert_verify_result.verified_cert = |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 session_.OnProofVerifyDetailsAvailable(details); | 237 session_.OnProofVerifyDetailsAvailable(details); |
237 CompleteCryptoHandshake(); | 238 CompleteCryptoHandshake(); |
238 QuicClientSessionPeer::SetChannelIDSent(&session_, true); | 239 QuicClientSessionPeer::SetChannelIDSent(&session_, true); |
239 | 240 |
240 EXPECT_TRUE(session_.CanPool("mail.example.org", PRIVACY_MODE_DISABLED)); | 241 EXPECT_TRUE(session_.CanPool("mail.example.org", PRIVACY_MODE_DISABLED)); |
241 } | 242 } |
242 | 243 |
243 } // namespace | 244 } // namespace |
244 } // namespace test | 245 } // namespace test |
245 } // namespace net | 246 } // namespace net |
OLD | NEW |