Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(554)

Side by Side Diff: net/quic/quic_crypto_client_stream_test.cc

Issue 15074007: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix for windows Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_crypto_client_stream_factory.h ('k') | net/quic/quic_crypto_server_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "net/quic/quic_protocol.h"
11 #include "net/quic/test_tools/crypto_test_utils.h" 12 #include "net/quic/test_tools/crypto_test_utils.h"
12 #include "net/quic/test_tools/quic_test_utils.h" 13 #include "net/quic/test_tools/quic_test_utils.h"
13 #include "net/quic/test_tools/simple_quic_framer.h" 14 #include "net/quic/test_tools/simple_quic_framer.h"
14 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 namespace net { 18 namespace net {
18 namespace test { 19 namespace test {
19 namespace { 20 namespace {
20 21
(...skipping 22 matching lines...) Expand all
43 bool frame_valid_; 44 bool frame_valid_;
44 45
45 DISALLOW_COPY_AND_ASSIGN(TestQuicVisitor); 46 DISALLOW_COPY_AND_ASSIGN(TestQuicVisitor);
46 }; 47 };
47 48
48 class QuicCryptoClientStreamTest : public ::testing::Test { 49 class QuicCryptoClientStreamTest : public ::testing::Test {
49 public: 50 public:
50 QuicCryptoClientStreamTest() 51 QuicCryptoClientStreamTest()
51 : addr_(), 52 : addr_(),
52 connection_(new PacketSavingConnection(1, addr_, true)), 53 connection_(new PacketSavingConnection(1, addr_, true)),
53 session_(connection_, true), 54 session_(connection_, QuicConfig(), true),
54 stream_(kServerHostname, config_, &session_, &crypto_config_) { 55 stream_(kServerHostname, &session_, &crypto_config_) {
55 session_.SetCryptoStream(&stream_); 56 session_.SetCryptoStream(&stream_);
56 config_.SetDefaults(); 57 session_.config()->SetDefaults();
57 crypto_config_.SetDefaults(); 58 crypto_config_.SetDefaults();
58 } 59 }
59 60
60 void CompleteCryptoHandshake() { 61 void CompleteCryptoHandshake() {
61 EXPECT_TRUE(stream_.CryptoConnect()); 62 EXPECT_TRUE(stream_.CryptoConnect());
62 CryptoTestUtils::HandshakeWithFakeServer(connection_, &stream_); 63 CryptoTestUtils::HandshakeWithFakeServer(connection_, &stream_);
63 } 64 }
64 65
65 void ConstructHandshakeMessage() { 66 void ConstructHandshakeMessage() {
66 CryptoFramer framer; 67 CryptoFramer framer;
67 message_data_.reset(framer.ConstructHandshakeMessage(message_)); 68 message_data_.reset(framer.ConstructHandshakeMessage(message_));
68 } 69 }
69 70
70 IPEndPoint addr_; 71 IPEndPoint addr_;
71 PacketSavingConnection* connection_; 72 PacketSavingConnection* connection_;
72 TestSession session_; 73 TestSession session_;
73 QuicCryptoClientStream stream_; 74 QuicCryptoClientStream stream_;
74 CryptoHandshakeMessage message_; 75 CryptoHandshakeMessage message_;
75 scoped_ptr<QuicData> message_data_; 76 scoped_ptr<QuicData> message_data_;
76 QuicConfig config_;
77 QuicCryptoClientConfig crypto_config_; 77 QuicCryptoClientConfig crypto_config_;
78 }; 78 };
79 79
80 TEST_F(QuicCryptoClientStreamTest, NotInitiallyConected) { 80 TEST_F(QuicCryptoClientStreamTest, NotInitiallyConected) {
81 if (!Aes128GcmEncrypter::IsSupported()) { 81 if (!Aes128GcmEncrypter::IsSupported()) {
82 LOG(INFO) << "AES GCM not supported. Test skipped."; 82 LOG(INFO) << "AES GCM not supported. Test skipped.";
83 return; 83 return;
84 } 84 }
85 85
86 EXPECT_FALSE(stream_.encryption_established()); 86 EXPECT_FALSE(stream_.encryption_established());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 130 }
131 131
132 TEST_F(QuicCryptoClientStreamTest, NegotiatedParameters) { 132 TEST_F(QuicCryptoClientStreamTest, NegotiatedParameters) {
133 if (!Aes128GcmEncrypter::IsSupported()) { 133 if (!Aes128GcmEncrypter::IsSupported()) {
134 LOG(INFO) << "AES GCM not supported. Test skipped."; 134 LOG(INFO) << "AES GCM not supported. Test skipped.";
135 return; 135 return;
136 } 136 }
137 137
138 CompleteCryptoHandshake(); 138 CompleteCryptoHandshake();
139 139
140 const QuicNegotiatedParameters& params(stream_.negotiated_params()); 140 const QuicConfig* config = session_.config();
141 EXPECT_EQ(kQBIC, params.congestion_control); 141 EXPECT_EQ(kQBIC, config->congestion_control());
142 EXPECT_EQ(300, params.idle_connection_state_lifetime.ToSeconds()); 142 EXPECT_EQ(kDefaultTimeoutSecs,
143 EXPECT_EQ(0, params.keepalive_timeout.ToSeconds()); 143 config->idle_connection_state_lifetime().ToSeconds());
144 EXPECT_EQ(kDefaultMaxStreamsPerConnection,
145 config->max_streams_per_connection());
146 EXPECT_EQ(0, config->keepalive_timeout().ToSeconds());
144 147
145 const QuicCryptoNegotiatedParameters& crypto_params( 148 const QuicCryptoNegotiatedParameters& crypto_params(
146 stream_.crypto_negotiated_params()); 149 stream_.crypto_negotiated_params());
147 EXPECT_EQ(kAESG, crypto_params.aead); 150 EXPECT_EQ(kAESG, crypto_params.aead);
148 EXPECT_EQ(kC255, crypto_params.key_exchange); 151 EXPECT_EQ(kC255, crypto_params.key_exchange);
149 } 152 }
150 153
151 } // namespace 154 } // namespace
152 } // namespace test 155 } // namespace test
153 } // namespace net 156 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_crypto_client_stream_factory.h ('k') | net/quic/quic_crypto_server_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698