|
| 1 | +/* |
| 2 | +Copyright 2025 The Kubernetes Authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package utils |
| 18 | + |
| 19 | +import ( |
| 20 | + "crypto/tls" |
| 21 | + "testing" |
| 22 | + "time" |
| 23 | +) |
| 24 | + |
| 25 | +func TestDefaultTransport(t *testing.T) { |
| 26 | + if DefaultTransport == nil { |
| 27 | + t.Fatal("DefaultTransport is nil") |
| 28 | + } |
| 29 | + |
| 30 | + if DefaultTransport.DialContext == nil { |
| 31 | + t.Error("DialContext is nil") |
| 32 | + } |
| 33 | + |
| 34 | + if !DefaultTransport.ForceAttemptHTTP2 { |
| 35 | + t.Error("ForceAttemptHTTP2 is false") |
| 36 | + } |
| 37 | + |
| 38 | + if DefaultTransport.MaxIdleConns != 100 { |
| 39 | + t.Errorf("Expected MaxIdleConns to be 100, got %d", DefaultTransport.MaxIdleConns) |
| 40 | + } |
| 41 | + |
| 42 | + if DefaultTransport.MaxConnsPerHost != 100 { |
| 43 | + t.Errorf("Expected MaxConnsPerHost to be 100, got %d", DefaultTransport.MaxConnsPerHost) |
| 44 | + } |
| 45 | + |
| 46 | + if DefaultTransport.IdleConnTimeout != 90*time.Second { |
| 47 | + t.Errorf("Expected IdleConnTimeout to be 90s, got %v", DefaultTransport.IdleConnTimeout) |
| 48 | + } |
| 49 | + |
| 50 | + if DefaultTransport.TLSHandshakeTimeout != 10*time.Second { |
| 51 | + t.Errorf("Expected TLSHandshakeTimeout to be 10s, got %v", DefaultTransport.TLSHandshakeTimeout) |
| 52 | + } |
| 53 | + |
| 54 | + if DefaultTransport.ExpectContinueTimeout != 1*time.Second { |
| 55 | + t.Errorf("Expected ExpectContinueTimeout to be 1s, got %v", DefaultTransport.ExpectContinueTimeout) |
| 56 | + } |
| 57 | + |
| 58 | + if DefaultTransport.ResponseHeaderTimeout != 60*time.Second { |
| 59 | + t.Errorf("Expected ResponseHeaderTimeout to be 60s, got %v", DefaultTransport.ResponseHeaderTimeout) |
| 60 | + } |
| 61 | + |
| 62 | + if DefaultTransport.TLSClientConfig == nil { |
| 63 | + t.Fatal("TLSClientConfig is nil") |
| 64 | + } |
| 65 | + |
| 66 | + if DefaultTransport.TLSClientConfig.MinVersion != tls.VersionTLS12 { |
| 67 | + t.Errorf("Expected MinVersion to be TLS1.2, got %v", DefaultTransport.TLSClientConfig.MinVersion) |
| 68 | + } |
| 69 | + |
| 70 | + if DefaultTransport.TLSClientConfig.Renegotiation != tls.RenegotiateNever { |
| 71 | + t.Errorf("Expected Renegotiation to be RenegotiateNever, got %v", DefaultTransport.TLSClientConfig.Renegotiation) |
| 72 | + } |
| 73 | + |
| 74 | + // NOTE: http2 transport settings are not exposed hence testing is skipped. |
| 75 | +} |
0 commit comments