@ -26,6 +26,7 @@ import (
"strconv"
"strconv"
"strings"
"strings"
"testing"
"testing"
"time"
"github.com/pkg/errors"
"github.com/pkg/errors"
@ -48,6 +49,7 @@ func TestHTTPGetter(t *testing.T) {
join := filepath . Join
join := filepath . Join
ca , pub , priv := join ( cd , "rootca.crt" ) , join ( cd , "crt.pem" ) , join ( cd , "key.pem" )
ca , pub , priv := join ( cd , "rootca.crt" ) , join ( cd , "crt.pem" ) , join ( cd , "key.pem" )
insecure := false
insecure := false
timeout := time . Second * 5
// Test with options
// Test with options
g , err = NewHTTPGetter (
g , err = NewHTTPGetter (
@ -55,6 +57,7 @@ func TestHTTPGetter(t *testing.T) {
WithUserAgent ( "Groot" ) ,
WithUserAgent ( "Groot" ) ,
WithTLSClientConfig ( pub , priv , ca ) ,
WithTLSClientConfig ( pub , priv , ca ) ,
WithInsecureSkipVerifyTLS ( insecure ) ,
WithInsecureSkipVerifyTLS ( insecure ) ,
WithTimeout ( timeout ) ,
)
)
if err != nil {
if err != nil {
t . Fatal ( err )
t . Fatal ( err )
@ -93,6 +96,10 @@ func TestHTTPGetter(t *testing.T) {
t . Errorf ( "Expected NewHTTPGetter to contain %t as InsecureSkipVerifyTLs flag, got %t" , false , hg . opts . insecureSkipVerifyTLS )
t . Errorf ( "Expected NewHTTPGetter to contain %t as InsecureSkipVerifyTLs flag, got %t" , false , hg . opts . insecureSkipVerifyTLS )
}
}
if hg . opts . timeout != timeout {
t . Errorf ( "Expected NewHTTPGetter to contain %s as Timeout flag, got %s" , timeout , hg . opts . timeout )
}
// Test if setting insecureSkipVerifyTLS is being passed to the ops
// Test if setting insecureSkipVerifyTLS is being passed to the ops
insecure = true
insecure = true