MCPcopy
hub / github.com/runfinch/finch / Test_hostKeyCallback

Function Test_hostKeyCallback

pkg/fssh/fssh_test.go:20–52  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18)
19
20func Test_hostKeyCallback(t *testing.T) {
21 t.Parallel()
22 testCases := []struct {
23 name string
24 remote net.Addr
25 want error
26 }{
27 {
28 name: "happy path, remote is a valid TCP loopback address",
29 remote: &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 8080},
30 want: nil,
31 },
32 {
33 name: "remote is not a valid address",
34 remote: nil,
35 want: errors.New("failed to convert the remote address to a TCP address"),
36 },
37 {
38 name: "remote is not a loopback address",
39 remote: &net.TCPAddr{IP: net.ParseIP("192.0.2.1"), Port: 8080},
40 want: errors.New("addresses that are not loopback addresses are not supported, address: 192.0.2.1:8080"),
41 },
42 }
43
44 for _, tc := range testCases {
45 t.Run(tc.name, func(t *testing.T) {
46 t.Parallel()
47
48 got := hostKeyCallback()("", tc.remote, nil)
49 assert.Equal(t, tc.want, got)
50 })
51 }
52}
53
54func TestNewClientConfig(t *testing.T) {
55 t.Parallel()

Callers

nothing calls this directly

Calls 2

hostKeyCallbackFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected