-
Notifications
You must be signed in to change notification settings - Fork 13
/
client_config_test.go
58 lines (54 loc) · 1.04 KB
/
client_config_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package go_sftp_test
import (
"testing"
sftp "github.com/moov-io/go-sftp"
"github.com/stretchr/testify/require"
)
func TestClientConfig_HostKeys(t *testing.T) {
tests := []struct {
name string
cfg sftp.ClientConfig
want []string
}{
{
name: "no host keys",
cfg: sftp.ClientConfig{},
want: nil,
},
{
name: "only HostPublicKey",
cfg: sftp.ClientConfig{
HostPublicKey: "public-key",
},
want: []string{"public-key"},
},
{
name: "only HostPublicKeys",
cfg: sftp.ClientConfig{
HostPublicKeys: []string{
"public-key-1",
"public-key-2",
},
},
want: []string{"public-key-1", "public-key-2"},
},
{
name: "combined and unique",
cfg: sftp.ClientConfig{
HostPublicKey: "public-key",
HostPublicKeys: []string{
"public-key",
"public-key-1",
"public-key-1",
},
},
want: []string{"public-key", "public-key-1"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := tt.cfg.HostKeys()
require.Equal(t, tt.want, got)
})
}
}