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_encrypter.h" | 8 #include "net/quic/crypto/aes_128_gcm_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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 return QuicSession::WriteData(id, data, offset, fin); | 59 return QuicSession::WriteData(id, data, offset, fin); |
60 } | 60 } |
61 }; | 61 }; |
62 | 62 |
63 class QuicCryptoClientStreamTest : public ::testing::Test { | 63 class QuicCryptoClientStreamTest : public ::testing::Test { |
64 public: | 64 public: |
65 QuicCryptoClientStreamTest() | 65 QuicCryptoClientStreamTest() |
66 : addr_(), | 66 : addr_(), |
67 connection_(new PacketSavingConnection(1, addr_, true)), | 67 connection_(new PacketSavingConnection(1, addr_, true)), |
68 session_(connection_, true), | 68 session_(connection_, true), |
69 stream_(&session_, kServerHostname) { | 69 stream_(kServerHostname, config_, &session_, &crypto_config_) { |
| 70 config_.SetDefaults(); |
| 71 crypto_config_.SetDefaults(); |
70 } | 72 } |
71 | 73 |
72 void CompleteCryptoHandshake() { | 74 void CompleteCryptoHandshake() { |
73 EXPECT_TRUE(stream_.CryptoConnect()); | 75 EXPECT_TRUE(stream_.CryptoConnect()); |
74 CryptoTestUtils::HandshakeWithFakeServer(connection_, &stream_); | 76 CryptoTestUtils::HandshakeWithFakeServer(connection_, &stream_); |
75 } | 77 } |
76 | 78 |
77 void ConstructHandshakeMessage() { | 79 void ConstructHandshakeMessage() { |
78 CryptoFramer framer; | 80 CryptoFramer framer; |
79 message_data_.reset(framer.ConstructHandshakeMessage(message_)); | 81 message_data_.reset(framer.ConstructHandshakeMessage(message_)); |
80 } | 82 } |
81 | 83 |
82 IPEndPoint addr_; | 84 IPEndPoint addr_; |
83 PacketSavingConnection* connection_; | 85 PacketSavingConnection* connection_; |
84 TestMockSession session_; | 86 TestMockSession session_; |
85 QuicCryptoClientStream stream_; | 87 QuicCryptoClientStream stream_; |
86 CryptoHandshakeMessage message_; | 88 CryptoHandshakeMessage message_; |
87 scoped_ptr<QuicData> message_data_; | 89 scoped_ptr<QuicData> message_data_; |
| 90 QuicConfig config_; |
| 91 QuicCryptoClientConfig crypto_config_; |
88 }; | 92 }; |
89 | 93 |
90 TEST_F(QuicCryptoClientStreamTest, NotInitiallyConected) { | 94 TEST_F(QuicCryptoClientStreamTest, NotInitiallyConected) { |
91 if (!Aes128GcmEncrypter::IsSupported()) { | 95 if (!Aes128GcmEncrypter::IsSupported()) { |
92 LOG(INFO) << "AES GCM not supported. Test skipped."; | 96 LOG(INFO) << "AES GCM not supported. Test skipped."; |
93 return; | 97 return; |
94 } | 98 } |
95 | 99 |
96 EXPECT_FALSE(stream_.handshake_complete()); | 100 EXPECT_FALSE(stream_.handshake_complete()); |
97 } | 101 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 156 |
153 const QuicCryptoNegotiatedParameters& crypto_params( | 157 const QuicCryptoNegotiatedParameters& crypto_params( |
154 stream_.crypto_negotiated_params()); | 158 stream_.crypto_negotiated_params()); |
155 EXPECT_EQ(kAESG, crypto_params.aead); | 159 EXPECT_EQ(kAESG, crypto_params.aead); |
156 EXPECT_EQ(kC255, crypto_params.key_exchange); | 160 EXPECT_EQ(kC255, crypto_params.key_exchange); |
157 } | 161 } |
158 | 162 |
159 } // namespace | 163 } // namespace |
160 } // namespace test | 164 } // namespace test |
161 } // namespace net | 165 } // namespace net |
OLD | NEW |