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

Side by Side Diff: net/quic/crypto/quic_crypto_client_config_test.cc

Issue 185203003: Killing off QUICv12, including cleaning out all of the code for handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Deleted unused StripUint32 Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/crypto/quic_crypto_client_config.h" 5 #include "net/quic/crypto/quic_crypto_client_config.h"
6 6
7 #include "net/quic/test_tools/quic_test_utils.h" 7 #include "net/quic/test_tools/quic_test_utils.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 using std::string; 10 using std::string;
11 11
12 namespace net { 12 namespace net {
13 namespace test { 13 namespace test {
14 14
15 TEST(QuicCryptoClientConfigTest, InchoateChlo) { 15 TEST(QuicCryptoClientConfigTest, InchoateChlo) {
16 QuicCryptoClientConfig::CachedState state; 16 QuicCryptoClientConfig::CachedState state;
17 QuicCryptoClientConfig config; 17 QuicCryptoClientConfig config;
18 QuicCryptoNegotiatedParameters params; 18 QuicCryptoNegotiatedParameters params;
19 CryptoHandshakeMessage msg; 19 CryptoHandshakeMessage msg;
20 config.FillInchoateClientHello("www.google.com", QuicVersionMax(), &state, 20 config.FillInchoateClientHello("www.google.com", QuicVersionMax(), &state,
21 &params, &msg); 21 &params, &msg);
22 22
23 QuicTag cver; 23 QuicTag cver;
24 EXPECT_EQ(QUIC_NO_ERROR, msg.GetUint32(kVER, &cver)); 24 EXPECT_EQ(QUIC_NO_ERROR, msg.GetUint32(kVER, &cver));
25 EXPECT_EQ(QuicVersionToQuicTag(QuicVersionMax()), cver); 25 EXPECT_EQ(QuicVersionToQuicTag(QuicVersionMax()), cver);
26
27 // TODO(rch): Remove once we remove QUIC_VERSION_12.
28 uint16 vers;
29 EXPECT_EQ(QUIC_NO_ERROR, msg.GetUint16(kVERS, &vers));
30 EXPECT_EQ(0u, vers);
31 } 26 }
32 27
33 TEST(QuicCryptoClientConfigTest, ProcessServerDowngradeAttack) { 28 TEST(QuicCryptoClientConfigTest, ProcessServerDowngradeAttack) {
34 QuicVersionVector supported_versions = QuicSupportedVersions(); 29 QuicVersionVector supported_versions = QuicSupportedVersions();
35 if (supported_versions.size() == 1) { 30 if (supported_versions.size() == 1) {
36 // No downgrade attack is possible if the client only supports one version. 31 // No downgrade attack is possible if the client only supports one version.
37 return; 32 return;
38 } 33 }
39 QuicTagVector supported_version_tags; 34 QuicTagVector supported_version_tags;
40 for (size_t i = supported_versions.size(); i > 0; --i) { 35 for (size_t i = supported_versions.size(); i > 0; --i) {
41 supported_version_tags.push_back( 36 supported_version_tags.push_back(
42 QuicVersionToQuicTag(supported_versions[i - 1])); 37 QuicVersionToQuicTag(supported_versions[i - 1]));
43 } 38 }
44 CryptoHandshakeMessage msg; 39 CryptoHandshakeMessage msg;
45 msg.set_tag(kSHLO); 40 msg.set_tag(kSHLO);
46 msg.SetVector(kVER, supported_version_tags); 41 msg.SetVector(kVER, supported_version_tags);
47 42
48 QuicCryptoClientConfig::CachedState cached; 43 QuicCryptoClientConfig::CachedState cached;
49 QuicCryptoNegotiatedParameters out_params; 44 QuicCryptoNegotiatedParameters out_params;
50 string error; 45 string error;
51 QuicCryptoClientConfig config; 46 QuicCryptoClientConfig config;
52 EXPECT_EQ(QUIC_VERSION_NEGOTIATION_MISMATCH, 47 EXPECT_EQ(QUIC_VERSION_NEGOTIATION_MISMATCH,
53 config.ProcessServerHello(msg, 0, supported_versions, 48 config.ProcessServerHello(msg, 0, supported_versions,
54 &cached, &out_params, &error)); 49 &cached, &out_params, &error));
55 EXPECT_EQ("Downgrade attack detected", error); 50 EXPECT_EQ("Downgrade attack detected", error);
56 } 51 }
57 52
58 } // namespace test 53 } // namespace test
59 } // namespace net 54 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/quic_crypto_client_config.cc ('k') | net/quic/crypto/quic_crypto_server_config.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698