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

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

Issue 1009543004: Create a Perspective enum to use instead of a bool is_server to improve (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added NET_EXPORT_PRIVATE to fix compiler error Created 5 years, 9 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
« no previous file with comments | « net/quic/quic_crypto_client_stream.cc ('k') | net/quic/quic_crypto_server_stream.cc » ('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_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 12 matching lines...) Expand all
23 namespace net { 23 namespace net {
24 namespace test { 24 namespace test {
25 namespace { 25 namespace {
26 26
27 const char kServerHostname[] = "example.com"; 27 const char kServerHostname[] = "example.com";
28 const uint16 kServerPort = 80; 28 const uint16 kServerPort = 80;
29 29
30 class QuicCryptoClientStreamTest : public ::testing::Test { 30 class QuicCryptoClientStreamTest : public ::testing::Test {
31 public: 31 public:
32 QuicCryptoClientStreamTest() 32 QuicCryptoClientStreamTest()
33 : connection_(new PacketSavingConnection(/*is_server=*/false)), 33 : connection_(new PacketSavingConnection(Perspective::IS_CLIENT)),
34 session_(new TestClientSession(connection_, DefaultQuicConfig())), 34 session_(new TestClientSession(connection_, DefaultQuicConfig())),
35 server_id_(kServerHostname, kServerPort, false, PRIVACY_MODE_DISABLED), 35 server_id_(kServerHostname, kServerPort, false, PRIVACY_MODE_DISABLED),
36 stream_(new QuicCryptoClientStream(server_id_, 36 stream_(new QuicCryptoClientStream(server_id_,
37 session_.get(), 37 session_.get(),
38 nullptr, 38 nullptr,
39 &crypto_config_)) { 39 &crypto_config_)) {
40 session_->SetCryptoStream(stream_.get()); 40 session_->SetCryptoStream(stream_.get());
41 // Advance the time, because timers do not like uninitialized times. 41 // Advance the time, because timers do not like uninitialized times.
42 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); 42 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1));
43 } 43 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 116
117 CompleteCryptoHandshake(); 117 CompleteCryptoHandshake();
118 EXPECT_TRUE(stream_->encryption_established()); 118 EXPECT_TRUE(stream_->encryption_established());
119 EXPECT_TRUE(stream_->handshake_confirmed()); 119 EXPECT_TRUE(stream_->handshake_confirmed());
120 } 120 }
121 121
122 TEST_F(QuicCryptoClientStreamTest, ExpiredServerConfig) { 122 TEST_F(QuicCryptoClientStreamTest, ExpiredServerConfig) {
123 // Seed the config with a cached server config. 123 // Seed the config with a cached server config.
124 CompleteCryptoHandshake(); 124 CompleteCryptoHandshake();
125 125
126 connection_ = new PacketSavingConnection(/*is_server=*/false); 126 connection_ = new PacketSavingConnection(Perspective::IS_CLIENT);
127 session_.reset(new TestClientSession(connection_, DefaultQuicConfig())); 127 session_.reset(new TestClientSession(connection_, DefaultQuicConfig()));
128 stream_.reset(new QuicCryptoClientStream(server_id_, session_.get(), nullptr, 128 stream_.reset(new QuicCryptoClientStream(server_id_, session_.get(), nullptr,
129 &crypto_config_)); 129 &crypto_config_));
130 130
131 session_->SetCryptoStream(stream_.get()); 131 session_->SetCryptoStream(stream_.get());
132 132
133 // Advance time 5 years to ensure that we pass the expiry time of the cached 133 // Advance time 5 years to ensure that we pass the expiry time of the cached
134 // server config. 134 // server config.
135 connection_->AdvanceTime( 135 connection_->AdvanceTime(
136 QuicTime::Delta::FromSeconds(60 * 60 * 24 * 365 * 5)); 136 QuicTime::Delta::FromSeconds(60 * 60 * 24 * 365 * 5));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 CryptoHandshakeMessage server_config_update; 196 CryptoHandshakeMessage server_config_update;
197 server_config_update.set_tag(kSCUP); 197 server_config_update.set_tag(kSCUP);
198 scoped_ptr<QuicData> data( 198 scoped_ptr<QuicData> data(
199 CryptoFramer::ConstructHandshakeMessage(server_config_update)); 199 CryptoFramer::ConstructHandshakeMessage(server_config_update));
200 stream_->ProcessRawData(data->data(), data->length()); 200 stream_->ProcessRawData(data->data(), data->length());
201 } 201 }
202 202
203 } // namespace 203 } // namespace
204 } // namespace test 204 } // namespace test
205 } // namespace net 205 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_crypto_client_stream.cc ('k') | net/quic/quic_crypto_server_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698