Fix to disable TLS in tests

This commit is contained in:
Marc Di Luzio 2020-07-26 23:53:29 +01:00
parent 500e0f9557
commit 94767f06d3
2 changed files with 7 additions and 3 deletions

View file

@ -187,12 +187,15 @@ func InnerMain(command string, args ...string) error {
return fmt.Errorf("no host set in %s, set one with '%s config {HOST}'", ConfigPath(), os.Args[0])
}
tls := &tls.Config{
InsecureSkipVerify: true,
var opts []grpc.DialOption
if len(os.Getenv("NO_TLS")) == 0 {
opts = append(opts, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})))
} else {
opts = append(opts, grpc.WithInsecure())
}
// Set up the server
clientConn, err := grpc.Dial(fmt.Sprintf("%s:%d", config.Host, gRPCport), grpc.WithTransportCredentials(credentials.NewTLS(tls)))
clientConn, err := grpc.Dial(fmt.Sprintf("%s:%d", config.Host, gRPCport), opts...)
if err != nil {
return err
}

View file

@ -13,6 +13,7 @@ import (
)
func Test_InnerMain(t *testing.T) {
os.Setenv("NO_TLS", "1")
// Use temporary local user data
tmp, err := ioutil.TempDir(os.TempDir(), "rove-")