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

Unified Diff: net/quic/crypto/quic_crypto_server_config_test.cc

Issue 623003002: QUIC: if client provides an STK which includes CachedNetworkParams, then (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/crypto/quic_crypto_server_config.cc ('k') | net/quic/crypto/source_address_token.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/crypto/quic_crypto_server_config_test.cc
diff --git a/net/quic/crypto/quic_crypto_server_config_test.cc b/net/quic/crypto/quic_crypto_server_config_test.cc
index f44dc5c1325c3366ce2f8de188e3dd196bbf2d77..26811a20ea39c2d12e3236701af8d5c01be76b08 100644
--- a/net/quic/crypto/quic_crypto_server_config_test.cc
+++ b/net/quic/crypto/quic_crypto_server_config_test.cc
@@ -13,6 +13,7 @@
#include "net/quic/crypto/crypto_server_config_protobuf.h"
#include "net/quic/crypto/quic_random.h"
#include "net/quic/crypto/strike_register_client.h"
+#include "net/quic/quic_flags.h"
#include "net/quic/quic_time.h"
#include "net/quic/test_tools/mock_clock.h"
#include "net/quic/test_tools/quic_test_utils.h"
@@ -52,19 +53,37 @@ class QuicCryptoServerConfigPeer {
string NewSourceAddressToken(
string config_id,
- IPEndPoint ip,
+ const IPEndPoint& ip,
QuicRandom* rand,
QuicWallTime now) {
+ return NewSourceAddressToken(config_id, ip, rand, now, NULL);
+ }
+
+ string NewSourceAddressToken(
+ string config_id,
+ const IPEndPoint& ip,
+ QuicRandom* rand,
+ QuicWallTime now,
+ CachedNetworkParameters* cached_network_params) {
return server_config_->NewSourceAddressToken(
- *GetConfig(config_id), ip, rand, now, nullptr);
+ *GetConfig(config_id), ip, rand, now, cached_network_params);
}
HandshakeFailureReason ValidateSourceAddressToken(string config_id,
StringPiece srct,
- IPEndPoint ip,
+ const IPEndPoint& ip,
QuicWallTime now) {
+ return ValidateSourceAddressToken(config_id, srct, ip, now, NULL);
+ }
+
+ HandshakeFailureReason ValidateSourceAddressToken(
+ string config_id,
+ StringPiece srct,
+ const IPEndPoint& ip,
+ QuicWallTime now,
+ CachedNetworkParameters* cached_network_params) {
return server_config_->ValidateSourceAddressToken(
- *GetConfig(config_id), srct, ip, now);
+ *GetConfig(config_id), srct, ip, now, cached_network_params);
}
string NewServerNonce(QuicRandom* rand, QuicWallTime now) const {
@@ -241,6 +260,8 @@ TEST(QuicCryptoServerConfigTest, GetOrbitIsCalledWithoutTheStrikeRegisterLock) {
}
TEST(QuicCryptoServerConfigTest, SourceAddressTokens) {
+ ValueRestore<bool> old_flag(&FLAGS_quic_store_cached_network_params_from_chlo,
+ true);
const string kPrimary = "<primary>";
const string kOverride = "Config with custom source address token key";
@@ -329,6 +350,21 @@ TEST(QuicCryptoServerConfigTest, SourceAddressTokens) {
now = original_time.Subtract(QuicTime::Delta::FromSeconds(3600 * 2));
DCHECK_EQ(SOURCE_ADDRESS_TOKEN_CLOCK_SKEW_FAILURE,
peer.ValidateSourceAddressToken(kPrimary, token4, ip4, now));
+
+ // Make sure that if the source address token contains CachedNetworkParameters
+ // that this gets written to ValidateSourceAddressToken output argument.
+ CachedNetworkParameters cached_network_params_input;
+ cached_network_params_input.set_bandwidth_estimate_bytes_per_second(1234);
+ const string token4_with_cached_network_params = peer.NewSourceAddressToken(
+ kPrimary, ip4, rand, now, &cached_network_params_input);
+
+ CachedNetworkParameters cached_network_params_output;
+ EXPECT_NE(cached_network_params_output, cached_network_params_input);
+ peer.ValidateSourceAddressToken(kPrimary, token4_with_cached_network_params,
+ ip4, now, &cached_network_params_output);
+ // TODO(rtenneti): For server, enable the following check after serialization
+ // of optional CachedNetworkParameters is implemented.
+ // EXPECT_EQ(cached_network_params_output, cached_network_params_input);
}
TEST(QuicCryptoServerConfigTest, ValidateServerNonce) {
« no previous file with comments | « net/quic/crypto/quic_crypto_server_config.cc ('k') | net/quic/crypto/source_address_token.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698