forceURLTransport forces the client to route all requests to the client's configured URLs host regardless of hostname.
(t *testing.T, client *codersdk.Client)
| 603 | // forceURLTransport forces the client to route all requests to the client's |
| 604 | // configured URLs host regardless of hostname. |
| 605 | func forceURLTransport(t *testing.T, client *codersdk.Client) { |
| 606 | defaultTransport, ok := http.DefaultTransport.(*http.Transport) |
| 607 | require.True(t, ok) |
| 608 | transport := defaultTransport.Clone() |
| 609 | transport.DialContext = func(ctx context.Context, network, _ string) (net.Conn, error) { |
| 610 | return (&net.Dialer{}).DialContext(ctx, network, client.URL.Host) |
| 611 | } |
| 612 | client.HTTPClient.Transport = transport |
| 613 | t.Cleanup(func() { |
| 614 | transport.CloseIdleConnections() |
| 615 | }) |
| 616 | } |
no test coverage detected