-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure http client Transport is defined before trying to set Insecure…
…SkipVerify The http client we get from the oci-go-sdk lets it default to http.DefaultTransport, but this isn't set at the time we try and configure the TLSClientConfig to set InsecureSkipVerify to true (when the provider has disable-certs set).
- Loading branch information
Showing
2 changed files
with
33 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package oracle | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
) | ||
|
||
func TestInsecureRoundTripper(t *testing.T) { | ||
testCases := []http.RoundTripper{ | ||
http.DefaultTransport, // Normal case | ||
nil, // Ensure it creates a DefaultTransport in the nil case | ||
} | ||
|
||
for _, transport := range testCases { | ||
roundTripper := InsecureRoundTripper(transport) | ||
transport, ok := roundTripper.(*http.Transport) | ||
|
||
if !ok { | ||
t.Fatal("Transport not correctly returned") | ||
} | ||
|
||
if transport.TLSClientConfig == nil || !transport.TLSClientConfig.InsecureSkipVerify { | ||
t.Fatal("InsecureSkipVerify not correctly set on transport") | ||
} | ||
} | ||
} |