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

Side by Side Diff: net/quic/quic_crypto_server_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_server_stream.cc ('k') | net/quic/quic_crypto_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_server_stream.h" 5 #include "net/quic/quic_crypto_server_stream.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 }; 49 };
50 50
51 namespace { 51 namespace {
52 52
53 const char kServerHostname[] = "test.example.com"; 53 const char kServerHostname[] = "test.example.com";
54 const uint16 kServerPort = 80; 54 const uint16 kServerPort = 80;
55 55
56 class QuicCryptoServerStreamTest : public ::testing::TestWithParam<bool> { 56 class QuicCryptoServerStreamTest : public ::testing::TestWithParam<bool> {
57 public: 57 public:
58 QuicCryptoServerStreamTest() 58 QuicCryptoServerStreamTest()
59 : connection_(new PacketSavingConnection(/*is_server=*/true)), 59 : connection_(new PacketSavingConnection(Perspective::IS_SERVER)),
60 session_(connection_, DefaultQuicConfig()), 60 session_(connection_, DefaultQuicConfig()),
61 crypto_config_(QuicCryptoServerConfig::TESTING, 61 crypto_config_(QuicCryptoServerConfig::TESTING,
62 QuicRandom::GetInstance()), 62 QuicRandom::GetInstance()),
63 stream_(crypto_config_, &session_), 63 stream_(crypto_config_, &session_),
64 strike_register_client_(nullptr) { 64 strike_register_client_(nullptr) {
65 session_.SetCryptoStream(&stream_); 65 session_.SetCryptoStream(&stream_);
66 // We advance the clock initially because the default time is zero and the 66 // We advance the clock initially because the default time is zero and the
67 // strike register worries that we've just overflowed a uint32 time. 67 // strike register worries that we've just overflowed a uint32 time.
68 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(100000)); 68 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(100000));
69 // TODO(wtc): replace this with ProofSourceForTesting() when Chromium has 69 // TODO(wtc): replace this with ProofSourceForTesting() when Chromium has
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // test should send: 127 // test should send:
128 // * One to get a source-address token and certificates. 128 // * One to get a source-address token and certificates.
129 // * One to complete the handshake. 129 // * One to complete the handshake.
130 EXPECT_EQ(2, CompleteCryptoHandshake()); 130 EXPECT_EQ(2, CompleteCryptoHandshake());
131 EXPECT_TRUE(stream_.encryption_established()); 131 EXPECT_TRUE(stream_.encryption_established());
132 EXPECT_TRUE(stream_.handshake_confirmed()); 132 EXPECT_TRUE(stream_.handshake_confirmed());
133 } 133 }
134 134
135 TEST_P(QuicCryptoServerStreamTest, ZeroRTT) { 135 TEST_P(QuicCryptoServerStreamTest, ZeroRTT) {
136 PacketSavingConnection* client_conn = 136 PacketSavingConnection* client_conn =
137 new PacketSavingConnection(/*is_server=*/false); 137 new PacketSavingConnection(Perspective::IS_CLIENT);
138 PacketSavingConnection* server_conn = 138 PacketSavingConnection* server_conn =
139 new PacketSavingConnection(/*is_server=*/true); 139 new PacketSavingConnection(Perspective::IS_SERVER);
140 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(100000)); 140 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(100000));
141 server_conn->AdvanceTime(QuicTime::Delta::FromSeconds(100000)); 141 server_conn->AdvanceTime(QuicTime::Delta::FromSeconds(100000));
142 142
143 QuicConfig client_config; 143 QuicConfig client_config;
144 scoped_ptr<TestClientSession> client_session( 144 scoped_ptr<TestClientSession> client_session(
145 new TestClientSession(client_conn, client_config)); 145 new TestClientSession(client_conn, client_config));
146 QuicCryptoClientConfig client_crypto_config; 146 QuicCryptoClientConfig client_crypto_config;
147 147
148 QuicServerId server_id(kServerHostname, kServerPort, false, 148 QuicServerId server_id(kServerHostname, kServerPort, false,
149 PRIVACY_MODE_DISABLED); 149 PRIVACY_MODE_DISABLED);
(...skipping 11 matching lines...) Expand all
161 new QuicCryptoServerStream(crypto_config_, server_session.get())); 161 new QuicCryptoServerStream(crypto_config_, server_session.get()));
162 server_session->SetCryptoStream(server.get()); 162 server_session->SetCryptoStream(server.get());
163 163
164 CryptoTestUtils::CommunicateHandshakeMessages( 164 CryptoTestUtils::CommunicateHandshakeMessages(
165 client_conn, client.get(), server_conn, server.get()); 165 client_conn, client.get(), server_conn, server.get());
166 EXPECT_EQ(2, client->num_sent_client_hellos()); 166 EXPECT_EQ(2, client->num_sent_client_hellos());
167 167
168 // Now do another handshake, hopefully in 0-RTT. 168 // Now do another handshake, hopefully in 0-RTT.
169 LOG(INFO) << "Resetting for 0-RTT handshake attempt"; 169 LOG(INFO) << "Resetting for 0-RTT handshake attempt";
170 170
171 client_conn = new PacketSavingConnection(/*is_server=*/false); 171 client_conn = new PacketSavingConnection(Perspective::IS_CLIENT);
172 server_conn = new PacketSavingConnection(/*is_server=*/true); 172 server_conn = new PacketSavingConnection(Perspective::IS_SERVER);
173 // We need to advance time past the strike-server window so that it's 173 // We need to advance time past the strike-server window so that it's
174 // authoritative in this time span. 174 // authoritative in this time span.
175 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(102000)); 175 client_conn->AdvanceTime(QuicTime::Delta::FromSeconds(102000));
176 server_conn->AdvanceTime(QuicTime::Delta::FromSeconds(102000)); 176 server_conn->AdvanceTime(QuicTime::Delta::FromSeconds(102000));
177 177
178 // This causes the client's nonce to be different and thus stops the 178 // This causes the client's nonce to be different and thus stops the
179 // strike-register from rejecting the repeated nonce. 179 // strike-register from rejecting the repeated nonce.
180 reinterpret_cast<MockRandom*>(client_conn->random_generator())->ChangeValue(); 180 reinterpret_cast<MockRandom*>(client_conn->random_generator())->ChangeValue();
181 client_session.reset(new TestClientSession(client_conn, client_config)); 181 client_session.reset(new TestClientSession(client_conn, client_config));
182 server_session.reset(new TestSession(server_conn, config_)); 182 server_session.reset(new TestSession(server_conn, config_));
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 274
275 TEST_P(QuicCryptoServerStreamTest, OnlySendSCUPAfterHandshakeComplete) { 275 TEST_P(QuicCryptoServerStreamTest, OnlySendSCUPAfterHandshakeComplete) {
276 // An attempt to send a SCUP before completing handshake should fail. 276 // An attempt to send a SCUP before completing handshake should fail.
277 stream_.SendServerConfigUpdate(nullptr); 277 stream_.SendServerConfigUpdate(nullptr);
278 EXPECT_EQ(0, stream_.num_server_config_update_messages_sent()); 278 EXPECT_EQ(0, stream_.num_server_config_update_messages_sent());
279 } 279 }
280 280
281 } // namespace 281 } // namespace
282 } // namespace test 282 } // namespace test
283 } // namespace net 283 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_crypto_server_stream.cc ('k') | net/quic/quic_crypto_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698