package fleetapi // White-box (package fleetapi, not fleetapi_test): pins the transport // construction New() does, which no exported surface exposes — C2's fix // shape (a Transport with dial/TLS/response-header timeouts and no // Client.Timeout) is otherwise invisible to a caller until an actual slow // transfer either survives or doesn't. import ( "net/http" "testing" ) func TestClientHasNoWholeExchangeTimeoutButBoundsResponseHeaders(t *testing.T) { s, err := New("https://tunnel.example.com", "pi/box-a", "tok") if err != nil { t.Fatalf("New: %v", err) } st, ok := s.(*store) if !ok { t.Fatalf("New returned %T, want *store", s) } if st.client.Timeout != 0 { t.Errorf("client.Timeout = %v, want 0 (a whole-exchange deadline would fail slow-but-progressing artifact downloads)", st.client.Timeout) } tr, ok := st.client.Transport.(*http.Transport) if !ok { t.Fatalf("client.Transport = %T, want *http.Transport", st.client.Transport) } if tr.ResponseHeaderTimeout != callTimeout { t.Errorf("ResponseHeaderTimeout = %v, want %v (a wedged edge must still fail fast)", tr.ResponseHeaderTimeout, callTimeout) } if tr.TLSHandshakeTimeout != callTimeout { t.Errorf("TLSHandshakeTimeout = %v, want %v", tr.TLSHandshakeTimeout, callTimeout) } if tr.DialContext == nil { t.Error("DialContext = nil, want a dialer with a connect timeout set") } }