MCPcopy Create free account
hub / github.com/kopia/kopia / TestSFTPOptions

Function TestSFTPOptions

cli/storage_sftp_test.go:17–182  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func TestSFTPOptions(t *testing.T) {
18 td := t.TempDir()
19
20 myKeyFile := filepath.Join(td, "my-key")
21 myKnownHostsFile := filepath.Join(td, "my-known-hosts")
22
23 require.NoError(t, os.WriteFile(myKeyFile, []byte("fake-key-data"), 0o600))
24 require.NoError(t, os.WriteFile(myKnownHostsFile, []byte("fake-known-hosts-data"), 0o600))
25
26 cases := []struct {
27 input storageSFTPFlags
28 want *sftp.Options
29 wantErr string
30 }{
31 // 0
32 {
33 input: storageSFTPFlags{
34 options: sftp.Options{
35 Host: "some-host",
36 Port: 222,
37 Username: "user",
38 KnownHostsFile: "my-known-hosts",
39 Keyfile: "my-key",
40 },
41 },
42 want: &sftp.Options{
43 Host: "some-host",
44 Port: 222,
45 Username: "user",
46 KnownHostsFile: mustFileAbs(t, "my-known-hosts"),
47 Keyfile: mustFileAbs(t, "my-key"),
48 },
49 },
50 // 1
51 {
52 input: storageSFTPFlags{
53 options: sftp.Options{
54 Host: "some-host",
55 Port: 222,
56 Username: "user",
57 Keyfile: "no-such-file",
58 KnownHostsFile: myKnownHostsFile,
59 },
60 embedCredentials: true,
61 },
62 wantErr: "unable to read key file",
63 },
64 // 2
65 {
66 input: storageSFTPFlags{
67 options: sftp.Options{
68 Host: "some-host",
69 Port: 222,
70 Username: "user",
71 Keyfile: myKeyFile,
72 KnownHostsFile: "no-such-file",
73 },
74 embedCredentials: true,

Callers

nothing calls this directly

Calls 7

mustFileAbsFunction · 0.85
EqualMethod · 0.80
WriteFileMethod · 0.65
RunMethod · 0.65
getOptionsMethod · 0.65
ErrorMethod · 0.65
ContainsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…