1 // Copyright 2016 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
16 // Tests that http2.Server.IdleTimeout is initialized from
17 // http.Server.{Idle,Read}Timeout. http.Server.IdleTimeout was
19 func TestConfigureServerIdleTimeout_Go18(t *testing.T) {
20 const timeout = 5 * time.Second
21 const notThisOne = 1 * time.Second
23 // With a zero http2.Server, verify that it copies IdleTimeout:
27 ReadTimeout: notThisOne,
30 if err := ConfigureServer(s1, s2); err != nil {
33 if s2.IdleTimeout != timeout {
34 t.Errorf("s2.IdleTimeout = %v; want %v", s2.IdleTimeout, timeout)
38 // And that it falls back to ReadTimeout:
44 if err := ConfigureServer(s1, s2); err != nil {
47 if s2.IdleTimeout != timeout {
48 t.Errorf("s2.IdleTimeout = %v; want %v", s2.IdleTimeout, timeout)
52 // Verify that s1's IdleTimeout doesn't overwrite an existing setting:
55 IdleTimeout: notThisOne,
60 if err := ConfigureServer(s1, s2); err != nil {
63 if s2.IdleTimeout != timeout {
64 t.Errorf("s2.IdleTimeout = %v; want %v", s2.IdleTimeout, timeout)
69 func TestCertClone(t *testing.T) {
71 GetClientCertificate: func(*tls.CertificateRequestInfo) (*tls.Certificate, error) {
72 panic("shouldn't be called")
75 c2 := cloneTLSConfig(c)
76 if c2.GetClientCertificate == nil {
77 t.Error("GetClientCertificate is nil")