Skip to content

Commit

Permalink
Fix test breaking when a proxy is configured on the host (#5471)
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
  • Loading branch information
kfox1111 authored Sep 6, 2024
1 parent b64a225 commit 024435d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pkg/common/plugin/httpchallenge/httpchallenge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,14 @@ func TestValidateChallenge(t *testing.T) {
}))
defer func() { testServer.Close() }()

transport := http.DefaultTransport.(*http.Transport).Clone()
transport.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
if addr == "foo.bar:80" {
addr = strings.TrimPrefix(testServer.URL, "http://")
}
dialer := &net.Dialer{}
return dialer.DialContext(ctx, network, addr)
transport := &http.Transport{
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
if addr == "foo.bar:80" {
addr = strings.TrimPrefix(testServer.URL, "http://")
}
dialer := &net.Dialer{}
return dialer.DialContext(ctx, network, addr)
},
}

err := VerifyChallenge(context.Background(), &http.Client{Transport: transport}, ad, c)
Expand Down

0 comments on commit 024435d

Please sign in to comment.