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 "net/base/capturing_net_log.h" | 12 #include "net/base/capturing_net_log.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/quic/crypto/aes_128_gcm_12_encrypter.h" | 17 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" |
18 #include "net/quic/crypto/crypto_protocol.h" | 18 #include "net/quic/crypto/crypto_protocol.h" |
19 #include "net/quic/crypto/proof_verifier_chromium.h" | 19 #include "net/quic/crypto/proof_verifier_chromium.h" |
20 #include "net/quic/crypto/quic_decrypter.h" | 20 #include "net/quic/crypto/quic_decrypter.h" |
21 #include "net/quic/crypto/quic_encrypter.h" | 21 #include "net/quic/crypto/quic_encrypter.h" |
22 #include "net/quic/crypto/quic_server_info.h" | 22 #include "net/quic/crypto/quic_server_info.h" |
23 #include "net/quic/network_connection.h" | |
23 #include "net/quic/test_tools/crypto_test_utils.h" | 24 #include "net/quic/test_tools/crypto_test_utils.h" |
24 #include "net/quic/test_tools/quic_client_session_peer.h" | 25 #include "net/quic/test_tools/quic_client_session_peer.h" |
25 #include "net/quic/test_tools/quic_test_utils.h" | 26 #include "net/quic/test_tools/quic_test_utils.h" |
26 #include "net/quic/test_tools/simple_quic_framer.h" | 27 #include "net/quic/test_tools/simple_quic_framer.h" |
27 #include "net/socket/socket_test_util.h" | 28 #include "net/socket/socket_test_util.h" |
28 #include "net/spdy/spdy_test_utils.h" | 29 #include "net/spdy/spdy_test_utils.h" |
29 #include "net/test/cert_test_util.h" | 30 #include "net/test/cert_test_util.h" |
30 #include "net/udp/datagram_client_socket.h" | 31 #include "net/udp/datagram_client_socket.h" |
31 | 32 |
32 using testing::_; | 33 using testing::_; |
33 | 34 |
34 namespace net { | 35 namespace net { |
35 namespace test { | 36 namespace test { |
36 namespace { | 37 namespace { |
37 | 38 |
38 const char kServerHostname[] = "www.example.org"; | 39 const char kServerHostname[] = "www.example.org"; |
39 const uint16 kServerPort = 80; | 40 const uint16 kServerPort = 80; |
40 | 41 |
41 class QuicClientSessionTest : public ::testing::TestWithParam<QuicVersion> { | 42 class QuicClientSessionTest : public ::testing::TestWithParam<QuicVersion> { |
42 protected: | 43 protected: |
43 QuicClientSessionTest() | 44 QuicClientSessionTest() |
44 : connection_( | 45 : connection_( |
45 new PacketSavingConnection(false, SupportedVersions(GetParam()))), | 46 new PacketSavingConnection(false, SupportedVersions(GetParam()))), |
46 session_(connection_, GetSocket().Pass(), nullptr, | 47 network_connection_(), |
48 session_(connection_, | |
49 GetSocket().Pass(), | |
50 nullptr, | |
47 &transport_security_state_, | 51 &transport_security_state_, |
48 make_scoped_ptr((QuicServerInfo*)nullptr), DefaultQuicConfig(), | 52 make_scoped_ptr((QuicServerInfo*)nullptr), |
53 DefaultQuicConfig(), | |
54 network_connection_.GetDescription(), | |
Ryan Hamilton
2015/02/23 20:42:19
I think you can just pass in any string you want h
ramant (doing other things)
2015/02/23 21:05:29
Done.
| |
49 base::MessageLoop::current()->message_loop_proxy().get(), | 55 base::MessageLoop::current()->message_loop_proxy().get(), |
50 &net_log_) { | 56 &net_log_) { |
51 session_.InitializeSession(QuicServerId(kServerHostname, kServerPort, | 57 session_.InitializeSession(QuicServerId(kServerHostname, kServerPort, |
52 /*is_secure=*/false, | 58 /*is_secure=*/false, |
53 PRIVACY_MODE_DISABLED), | 59 PRIVACY_MODE_DISABLED), |
54 &crypto_config_, nullptr); | 60 &crypto_config_, nullptr); |
55 // Advance the time, because timers do not like uninitialized times. | 61 // Advance the time, because timers do not like uninitialized times. |
56 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); | 62 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); |
57 } | 63 } |
58 | 64 |
(...skipping 12 matching lines...) Expand all Loading... | |
71 CryptoTestUtils::HandshakeWithFakeServer( | 77 CryptoTestUtils::HandshakeWithFakeServer( |
72 connection_, session_.GetCryptoStream()); | 78 connection_, session_.GetCryptoStream()); |
73 ASSERT_EQ(OK, callback_.WaitForResult()); | 79 ASSERT_EQ(OK, callback_.WaitForResult()); |
74 } | 80 } |
75 | 81 |
76 PacketSavingConnection* connection_; | 82 PacketSavingConnection* connection_; |
77 CapturingNetLog net_log_; | 83 CapturingNetLog net_log_; |
78 MockClientSocketFactory socket_factory_; | 84 MockClientSocketFactory socket_factory_; |
79 StaticSocketDataProvider socket_data_; | 85 StaticSocketDataProvider socket_data_; |
80 TransportSecurityState transport_security_state_; | 86 TransportSecurityState transport_security_state_; |
87 NetworkConnection network_connection_; | |
81 QuicClientSession session_; | 88 QuicClientSession session_; |
82 MockClock clock_; | 89 MockClock clock_; |
83 MockRandom random_; | 90 MockRandom random_; |
84 QuicConnectionVisitorInterface* visitor_; | 91 QuicConnectionVisitorInterface* visitor_; |
85 TestCompletionCallback callback_; | 92 TestCompletionCallback callback_; |
86 QuicCryptoClientConfig crypto_config_; | 93 QuicCryptoClientConfig crypto_config_; |
87 }; | 94 }; |
88 | 95 |
89 INSTANTIATE_TEST_CASE_P(Tests, QuicClientSessionTest, | 96 INSTANTIATE_TEST_CASE_P(Tests, QuicClientSessionTest, |
90 ::testing::ValuesIn(QuicSupportedVersions())); | 97 ::testing::ValuesIn(QuicSupportedVersions())); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 session_.OnProofVerifyDetailsAvailable(details); | 232 session_.OnProofVerifyDetailsAvailable(details); |
226 CompleteCryptoHandshake(); | 233 CompleteCryptoHandshake(); |
227 QuicClientSessionPeer::SetChannelIDSent(&session_, true); | 234 QuicClientSessionPeer::SetChannelIDSent(&session_, true); |
228 | 235 |
229 EXPECT_TRUE(session_.CanPool("mail.example.org", PRIVACY_MODE_DISABLED)); | 236 EXPECT_TRUE(session_.CanPool("mail.example.org", PRIVACY_MODE_DISABLED)); |
230 } | 237 } |
231 | 238 |
232 } // namespace | 239 } // namespace |
233 } // namespace test | 240 } // namespace test |
234 } // namespace net | 241 } // namespace net |
OLD | NEW |