func TestPrivateKeyAuth(t *testing.T) {
	s := withPrivateKey(t)
	if _, err := s.Connect(); err != nil {
		t.Fatalf("Connecting should succeed, got: %v", err)
	}
}
nolint:paralleltest // This test may access SSHAuthSockEnv environment variable,
which is a global variable, so to keep things stable, don't run it in parallel.
package ssh
import (
	"bytes"
	"fmt"
	"io/ioutil"
	"net"
	"os"
	"reflect"
	"strings"
	"testing"
	"github.com/flexkube/libflexkube/pkg/host/transport"
)
const testServerAddr = "/run/test.sock"
func TestPasswordAuth(t *testing.T) {
	unsetSSHAuthSockEnv(t)
	passwordFilePath := "/home/core/.password"
	pass, err := ioutil.ReadFile(passwordFilePath)
	if err != nil {
		t.Fatalf("Reading password file %q: %v", passwordFilePath, err)
	}
	c := &Config{
		Address:           "localhost",
		User:              "core",
		ConnectionTimeout: "5s",
		RetryTimeout:      "5s",
		RetryInterval:     "1s",
		Port:              Port,
		Password:          strings.TrimSpace(string(pass)),
	}
	s, err := c.New()
	if err != nil {
		t.Fatalf("Creating new SSH object should succeed, got: %v", err)
	}
	if _, err := s.Connect(); err != nil {
		t.Fatalf("Connecting should succeed, got: %v", err)
	}
}
func TestPasswordAuthFail(t *testing.T) {
	unsetSSHAuthSockEnv(t)
	c := &Config{
		Address:           "localhost",
		User:              "core",
		ConnectionTimeout: "5s",
		RetryTimeout:      "5s",
		RetryInterval:     "1s",
		Port:              Port,
		Password:          "badpassword",
	}
	s, err := c.New()
	if err != nil {
		t.Fatalf("Creating new SSH object should succeed, got: %v", err)
	}
	if _, err := s.Connect(); err == nil {
		t.Fatalf("Connecting with bad password should fail")
	}
}