Fix idle timeout negotiation

When clients configure the maximum idle timeout to a different value (as Chrome does), we need to use that maximum instead of the default maximum.

gfe-relnote: fix idle timeout negotiation, protected by disabled TLS flag
PiperOrigin-RevId: 268567456
Change-Id: I4db42fdcb73530a5049cf7b2953128b8b917b10f
diff --git a/quic/core/quic_config_test.cc b/quic/core/quic_config_test.cc
index 630e67a..5e3bb65 100644
--- a/quic/core/quic_config_test.cc
+++ b/quic/core/quic_config_test.cc
@@ -306,6 +306,22 @@
       kTBBR, Perspective::IS_SERVER));
 }
 
+TEST_P(QuicConfigTest, IncomingLargeIdleTimeoutTransportParameter) {
+  // Configure our default to 30s and max to 60s, then receive 120s from peer.
+  // Since the received value is above the max, we should then use the max.
+  config_.SetIdleNetworkTimeout(quic::QuicTime::Delta::FromSeconds(60),
+                                quic::QuicTime::Delta::FromSeconds(30));
+  TransportParameters params;
+  params.idle_timeout_milliseconds.set_value(120000);
+
+  std::string error_details = "foobar";
+  EXPECT_EQ(QUIC_NO_ERROR,
+            config_.ProcessTransportParameters(params, SERVER, &error_details));
+  EXPECT_EQ("", error_details);
+  EXPECT_EQ(quic::QuicTime::Delta::FromSeconds(60),
+            config_.IdleNetworkTimeout());
+}
+
 }  // namespace
 }  // namespace test
 }  // namespace quic