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

Unified Diff: net/quic/test_tools/crypto_test_utils.cc

Issue 13976007: Land Recent QUIC Changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated copyright notice Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/test_tools/crypto_test_utils.h ('k') | net/quic/test_tools/mock_crypto_client_stream.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/test_tools/crypto_test_utils.cc
diff --git a/net/quic/test_tools/crypto_test_utils.cc b/net/quic/test_tools/crypto_test_utils.cc
index 5086044a189c9b6e58322f106ab2b0bb717182f2..c2d5988c33e11c94ed609142f88505a01694b27b 100644
--- a/net/quic/test_tools/crypto_test_utils.cc
+++ b/net/quic/test_tools/crypto_test_utils.cc
@@ -5,8 +5,11 @@
#include "net/quic/test_tools/crypto_test_utils.h"
#include "base/strings/string_piece.h"
+#include "net/quic/crypto/crypto_handshake.h"
#include "net/quic/crypto/quic_decrypter.h"
#include "net/quic/crypto/quic_encrypter.h"
+#include "net/quic/crypto/quic_random.h"
+#include "net/quic/quic_clock.h"
#include "net/quic/quic_crypto_client_stream.h"
#include "net/quic/quic_crypto_server_stream.h"
#include "net/quic/quic_crypto_stream.h"
@@ -75,7 +78,15 @@ void CryptoTestUtils::HandshakeWithFakeServer(
PacketSavingConnection* server_conn =
new PacketSavingConnection(guid, addr, true);
TestSession server_session(server_conn, true);
- QuicCryptoServerStream server(&server_session);
+
+ QuicConfig config;
+ QuicCryptoServerConfig crypto_config(QuicCryptoServerConfig::TESTING);
+ SetupCryptoServerConfigForTest(
+ server_session.connection()->clock(),
+ server_session.connection()->random_generator(),
+ &config, &crypto_config);
+
+ QuicCryptoServerStream server(config, crypto_config, &server_session);
// The client's handshake must have been started already.
CHECK_NE(0u, client_conn->packets_.size());
@@ -96,7 +107,13 @@ void CryptoTestUtils::HandshakeWithFakeClient(
PacketSavingConnection* client_conn =
new PacketSavingConnection(guid, addr, false);
TestSession client_session(client_conn, true);
- QuicCryptoClientStream client(&client_session, "test.example.com");
+ QuicConfig config;
+ QuicCryptoClientConfig crypto_config;
+
+ config.SetDefaults();
+ crypto_config.SetDefaults();
+ QuicCryptoClientStream client("test.example.com", config, &client_session,
+ &crypto_config);
CHECK(client.CryptoConnect());
CHECK_EQ(1u, client_conn->packets_.size());
@@ -107,6 +124,23 @@ void CryptoTestUtils::HandshakeWithFakeClient(
}
// static
+void CryptoTestUtils::SetupCryptoServerConfigForTest(
+ const QuicClock* clock,
+ QuicRandom* rand,
+ QuicConfig* config,
+ QuicCryptoServerConfig* crypto_config) {
+ config->SetDefaults();
+ CryptoHandshakeMessage extra_tags;
+ config->ToHandshakeMessage(&extra_tags);
+
+ scoped_ptr<CryptoHandshakeMessage> scfg(
+ crypto_config->AddDefaultConfig(rand, clock, extra_tags));
+ if (!config->SetFromHandshakeMessage(*scfg)) {
+ CHECK(false) << "Crypto config could not be parsed by QuicConfig.";
+ }
+}
+
+// static
string CryptoTestUtils::GetValueForTag(const CryptoHandshakeMessage& message,
CryptoTag tag) {
CryptoTagValueMap::const_iterator it = message.tag_value_map().find(tag);
« no previous file with comments | « net/quic/test_tools/crypto_test_utils.h ('k') | net/quic/test_tools/mock_crypto_client_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698