Chromium Code Reviews| Index: net/quic/quic_client_session_test.cc |
| diff --git a/net/quic/quic_client_session_test.cc b/net/quic/quic_client_session_test.cc |
| index 264fbfa52708d69cc545cc15640f6acd24c5a28e..504afbd7d1ffafe5a7d67698c3cd79368ac6b810 100644 |
| --- a/net/quic/quic_client_session_test.cc |
| +++ b/net/quic/quic_client_session_test.cc |
| @@ -6,9 +6,11 @@ |
| #include <vector> |
| +#include "base/files/file_path.h" |
| #include "base/rand_util.h" |
| #include "net/base/capturing_net_log.h" |
| #include "net/base/test_completion_callback.h" |
| +#include "net/base/test_data_directory.h" |
| #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" |
| #include "net/quic/crypto/crypto_protocol.h" |
| #include "net/quic/crypto/quic_decrypter.h" |
| @@ -20,6 +22,7 @@ |
| #include "net/quic/test_tools/quic_test_utils.h" |
| #include "net/quic/test_tools/simple_quic_framer.h" |
| #include "net/socket/socket_test_util.h" |
| +#include "net/test/cert_test_util.h" |
| #include "net/udp/datagram_client_socket.h" |
| using testing::_; |
| @@ -67,7 +70,8 @@ class QuicClientSessionTest : public ::testing::TestWithParam<QuicVersion> { |
| : writer_(new TestPacketWriter(GetParam())), |
| connection_( |
| new PacketSavingConnection(false, SupportedVersions(GetParam()))), |
| - session_(connection_, GetSocket().Pass(), writer_.Pass(), NULL, NULL, |
| + session_(host_port_pair, connection_, GetSocket().Pass(), |
| + writer_.Pass(), NULL, NULL, |
| make_scoped_ptr((QuicServerInfo*)NULL), |
| QuicServerId(kServerHostname, kServerPort, false, |
| PRIVACY_MODE_DISABLED), |
| @@ -98,6 +102,7 @@ class QuicClientSessionTest : public ::testing::TestWithParam<QuicVersion> { |
| } |
| scoped_ptr<QuicDefaultPacketWriter> writer_; |
| + const HostPortPair host_port_pair; |
|
wtc
2014/06/27 23:55:51
1. The member name is missing the trailing '_'.
2
Ryan Hamilton
2014/07/01 18:37:17
Done.
|
| PacketSavingConnection* connection_; |
| CapturingNetLog net_log_; |
| MockClientSocketFactory socket_factory_; |
| @@ -166,6 +171,73 @@ TEST_P(QuicClientSessionTest, GoAwayReceived) { |
| EXPECT_EQ(NULL, session_.CreateOutgoingDataStream()); |
| } |
| +TEST_P(QuicClientSessionTest, CanPool) { |
| + // Load a cert that is valid for: |
| + // www.example.org |
| + // mail.example.org |
| + // www.example.com |
| + base::FilePath certs_dir = GetTestCertsDirectory(); |
| + scoped_refptr<X509Certificate> test_cert( |
| + ImportCertFromFile(certs_dir, "spdy_pooling.pem")); |
| + ASSERT_NE(static_cast<X509Certificate*>(NULL), test_cert); |
| + |
| + SSLSocketDataProvider ssl(SYNCHRONOUS, OK); |
| + ssl.cert = test_cert; |
| + socket_factory_.AddSSLSocketDataProvider(&ssl); |
| + |
| + CompleteCryptoHandshake(); |
| + |
| + EXPECT_TRUE(session_.CanPool("www.example.org")); |
| + EXPECT_TRUE(session_.CanPool("mail.example.org")); |
| + EXPECT_TRUE(session_.CanPool("mail.example.com")); |
| + EXPECT_FALSE(session_.CanPool("mail.google.com")); |
| +} |
| + |
| +/* |
|
wtc
2014/06/27 23:55:51
Nit: use #if 0 to comment out a block of code. Ple
Ryan Hamilton
2014/07/01 18:37:17
Sorry, this was not yet implemented since it depen
|
| +TEST_P(QuicClientSessionTest, ConnectionPooledWithTlsChannelId) { |
| + session_deps_.host_resolver->set_synchronous_mode(true); |
| + |
| + MockConnect connect_data(SYNCHRONOUS, OK); |
| + |
| + // No actual data will be sent. |
| + MockWrite writes[] = { |
| + MockWrite(ASYNC, 0, 1) // EOF |
| + }; |
| + |
| + MockRead reads[] = { |
| + MockRead(ASYNC, 0, 0) // EOF |
| + }; |
| + DeterministicSocketData data(reads, arraysize(reads), |
| + writes, arraysize(writes)); |
| + data.set_connect_data(connect_data); |
| + session_deps_.deterministic_socket_factory->AddSocketDataProvider(&data); |
| + |
| + // Load a cert that is valid for: |
| + // www.example.org |
| + // mail.example.org |
| + // www.example.com |
| + base::FilePath certs_dir = GetTestCertsDirectory(); |
| + scoped_refptr<X509Certificate> test_cert( |
| + ImportCertFromFile(certs_dir, "spdy_pooling.pem")); |
| + ASSERT_NE(static_cast<X509Certificate*>(NULL), test_cert); |
| + |
| + SSLSocketDataProvider ssl(SYNCHRONOUS, OK); |
| + ssl.channel_id_sent = true; |
| + ssl.cert = test_cert; |
| + session_deps_.deterministic_socket_factory->AddSSLSocketDataProvider(&ssl); |
| + |
| + CreateDeterministicNetworkSession(); |
| + |
| + base::WeakPtr<SpdySession> session = |
| + CreateSecureSpdySession(http_session_, key_, BoundNetLog()); |
| + |
| + EXPECT_TRUE(session->CanPool("www.example.org")); |
| + EXPECT_TRUE(session->CanPool("mail.example.org")); |
| + EXPECT_FALSE(session->CanPool("mail.example.com")); |
| + EXPECT_FALSE(session->CanPool("mail.google.com")); |
| +} |
| +*/ |
| + |
| } // namespace |
| } // namespace test |
| } // namespace net |