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_crypto_client_stream.h" | 5 #include "net/quic/quic_crypto_client_stream.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" | 8 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" |
9 #include "net/quic/crypto/quic_decrypter.h" | 9 #include "net/quic/crypto/quic_decrypter.h" |
10 #include "net/quic/crypto/quic_encrypter.h" | 10 #include "net/quic/crypto/quic_encrypter.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 namespace { | 22 namespace { |
23 | 23 |
24 const char kServerHostname[] = "example.com"; | 24 const char kServerHostname[] = "example.com"; |
25 const uint16 kServerPort = 80; | 25 const uint16 kServerPort = 80; |
26 | 26 |
27 class QuicCryptoClientStreamTest : public ::testing::Test { | 27 class QuicCryptoClientStreamTest : public ::testing::Test { |
28 public: | 28 public: |
29 QuicCryptoClientStreamTest() | 29 QuicCryptoClientStreamTest() |
30 : connection_(new PacketSavingConnection(false)), | 30 : connection_(new PacketSavingConnection(false)), |
31 session_(new TestClientSession(connection_, DefaultQuicConfig())), | 31 session_(new TestClientSession(connection_, DefaultQuicConfig())), |
32 server_key_(kServerHostname, kServerPort, false, kPrivacyModeDisabled), | 32 server_key_(kServerHostname, kServerPort, false, PRIVACY_MODE_DISABLED), |
33 stream_(new QuicCryptoClientStream( | 33 stream_(new QuicCryptoClientStream( |
34 server_key_, session_.get(), NULL, &crypto_config_)) { | 34 server_key_, session_.get(), NULL, &crypto_config_)) { |
35 session_->SetCryptoStream(stream_.get()); | 35 session_->SetCryptoStream(stream_.get()); |
36 session_->config()->SetDefaults(); | 36 session_->config()->SetDefaults(); |
37 crypto_config_.SetDefaults(); | 37 crypto_config_.SetDefaults(); |
38 } | 38 } |
39 | 39 |
40 void CompleteCryptoHandshake() { | 40 void CompleteCryptoHandshake() { |
41 EXPECT_TRUE(stream_->CryptoConnect()); | 41 EXPECT_TRUE(stream_->CryptoConnect()); |
42 CryptoTestUtils::HandshakeWithFakeServer(connection_, stream_.get()); | 42 CryptoTestUtils::HandshakeWithFakeServer(connection_, stream_.get()); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 config->max_streams_per_connection()); | 100 config->max_streams_per_connection()); |
101 EXPECT_EQ(0, config->keepalive_timeout().ToSeconds()); | 101 EXPECT_EQ(0, config->keepalive_timeout().ToSeconds()); |
102 | 102 |
103 const QuicCryptoNegotiatedParameters& crypto_params( | 103 const QuicCryptoNegotiatedParameters& crypto_params( |
104 stream_->crypto_negotiated_params()); | 104 stream_->crypto_negotiated_params()); |
105 EXPECT_EQ(crypto_config_.aead[0], crypto_params.aead); | 105 EXPECT_EQ(crypto_config_.aead[0], crypto_params.aead); |
106 EXPECT_EQ(crypto_config_.kexs[0], crypto_params.key_exchange); | 106 EXPECT_EQ(crypto_config_.kexs[0], crypto_params.key_exchange); |
107 } | 107 } |
108 | 108 |
109 TEST_F(QuicCryptoClientStreamTest, InvalidHostname) { | 109 TEST_F(QuicCryptoClientStreamTest, InvalidHostname) { |
110 QuicSessionKey server_key("invalid", 80, false, kPrivacyModeDisabled); | 110 QuicSessionKey server_key("invalid", 80, false, PRIVACY_MODE_DISABLED); |
111 stream_.reset(new QuicCryptoClientStream(server_key, session_.get(), NULL, | 111 stream_.reset(new QuicCryptoClientStream(server_key, session_.get(), NULL, |
112 &crypto_config_)); | 112 &crypto_config_)); |
113 session_->SetCryptoStream(stream_.get()); | 113 session_->SetCryptoStream(stream_.get()); |
114 | 114 |
115 CompleteCryptoHandshake(); | 115 CompleteCryptoHandshake(); |
116 EXPECT_TRUE(stream_->encryption_established()); | 116 EXPECT_TRUE(stream_->encryption_established()); |
117 EXPECT_TRUE(stream_->handshake_confirmed()); | 117 EXPECT_TRUE(stream_->handshake_confirmed()); |
118 } | 118 } |
119 | 119 |
120 TEST_F(QuicCryptoClientStreamTest, ExpiredServerConfig) { | 120 TEST_F(QuicCryptoClientStreamTest, ExpiredServerConfig) { |
(...skipping 15 matching lines...) Expand all Loading... |
136 | 136 |
137 // Check that a client hello was sent and that CryptoConnect doesn't fail | 137 // Check that a client hello was sent and that CryptoConnect doesn't fail |
138 // with an error. | 138 // with an error. |
139 EXPECT_TRUE(stream_->CryptoConnect()); | 139 EXPECT_TRUE(stream_->CryptoConnect()); |
140 ASSERT_EQ(1u, connection_->packets_.size()); | 140 ASSERT_EQ(1u, connection_->packets_.size()); |
141 } | 141 } |
142 | 142 |
143 } // namespace | 143 } // namespace |
144 } // namespace test | 144 } // namespace test |
145 } // namespace net | 145 } // namespace net |
OLD | NEW |