| 1 | package ssh_configscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/ |
| 2 | |
| 3 | import ( |
| 4 | "bytesscip-go gomod github.com/golang/go/src go1.18 bytes/" |
| 5 | "logscip-go gomod github.com/golang/go/src go1.18 log/" |
| 6 | "osscip-go gomod github.com/golang/go/src go1.18 os/" |
| 7 | "path/filepathscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/" |
| 8 | "stringsscip-go gomod github.com/golang/go/src go1.18 strings/" |
| 9 | "testingscip-go gomod github.com/golang/go/src go1.18 testing/" |
| 10 | ) |
| 11 | |
| 12 | func loadFilescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/loadFile().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#, filename string) []byte { |
| 13 | t.Helperscip-go gomod github.com/golang/go/src go1.18 testing/common#Helper().() |
| 14 | data, err := osscip-go gomod github.com/golang/go/src go1.18 os/.ReadFilescip-go gomod github.com/golang/go/src go1.18 os/ReadFile().(filename) |
| 15 | if err != nil { |
| 16 | t.Fatalscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatal().(err) |
| 17 | } |
| 18 | return data |
| 19 | } |
| 20 | |
| 21 | var filesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/files. = []string{ |
| 22 | "testdata/config1", |
| 23 | "testdata/config2", |
| 24 | "testdata/eol-comments", |
| 25 | } |
| 26 | |
| 27 | func TestDecodescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestDecode().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 28 | for _, filename := range filesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/files. { |
| 29 | data := loadFilescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/loadFile().(t, filename) |
| 30 | cfg, err := Decodescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Decode().(bytesscip-go gomod github.com/golang/go/src go1.18 bytes/.NewReaderscip-go gomod github.com/golang/go/src go1.18 bytes/NewReader().(data), false) |
| 31 | if err != nil { |
| 32 | t.Fatalscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatal().(err) |
| 33 | } |
| 34 | out := cfg.Stringscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#String().() |
| 35 | if out != string(data) { |
| 36 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("%s out != data: got:\n%s\nwant:\n%s\n", filename, out, string(data)) |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | func testConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/testConfigFinder().(filename string) func() string { |
| 42 | return func() string { return filename } |
| 43 | } |
| 44 | |
| 45 | func nullConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/nullConfigFinder().() string { |
| 46 | return "" |
| 47 | } |
| 48 | |
| 49 | func TestGetscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestGet().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 50 | us := &UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{ |
| 51 | userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfigFinder.: testConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/testConfigFinder().("testdata/config1"), |
| 52 | } |
| 53 | |
| 54 | val := us.Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#Get().("wap", "User") |
| 55 | if val != "root" { |
| 56 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected to find User root, got %q", val) |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | func TestGetWithDefaultscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestGetWithDefault().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 61 | us := &UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{ |
| 62 | userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfigFinder.: testConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/testConfigFinder().("testdata/config1"), |
| 63 | } |
| 64 | |
| 65 | val, err := us.GetStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetStrict().("wap", "PasswordAuthentication") |
| 66 | if err != nil { |
| 67 | t.Fatalfscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatalf().("expected nil err, got %v", err) |
| 68 | } |
| 69 | if val != "yes" { |
| 70 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected to get PasswordAuthentication yes, got %q", val) |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | func TestGetAllWithDefaultscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestGetAllWithDefault().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 75 | us := &UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{ |
| 76 | userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfigFinder.: testConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/testConfigFinder().("testdata/config1"), |
| 77 | } |
| 78 | |
| 79 | val, err := us.GetAllStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetAllStrict().("wap", "PasswordAuthentication") |
| 80 | if err != nil { |
| 81 | t.Fatalfscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatalf().("expected nil err, got %v", err) |
| 82 | } |
| 83 | if len(val) != 1 || val[0] != "yes" { |
| 84 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected to get PasswordAuthentication yes, got %q", val) |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | func TestGetIdentitiesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestGetIdentities().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 89 | us := &UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{ |
| 90 | userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfigFinder.: testConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/testConfigFinder().("testdata/identities"), |
| 91 | } |
| 92 | |
| 93 | val, err := us.GetAllStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetAllStrict().("hasidentity", "IdentityFile") |
| 94 | if err != nil { |
| 95 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected nil err, got %v", err) |
| 96 | } |
| 97 | if len(val) != 1 || val[0] != "file1" { |
| 98 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().(`expected ["file1"], got %v`, val) |
| 99 | } |
| 100 | |
| 101 | val, err = us.GetAllStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetAllStrict().("has2identity", "IdentityFile") |
| 102 | if err != nil { |
| 103 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected nil err, got %v", err) |
| 104 | } |
| 105 | if len(val) != 2 || val[0] != "f1" || val[1] != "f2" { |
| 106 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().(`expected [\"f1\", \"f2\"], got %v`, val) |
| 107 | } |
| 108 | |
| 109 | val, err = us.GetAllStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetAllStrict().("randomhost", "IdentityFile") |
| 110 | if err != nil { |
| 111 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected nil err, got %v", err) |
| 112 | } |
| 113 | if len(val) != len(defaultProtocol2Identitiesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/defaultProtocol2Identities.) { |
| 114 | // TODO: return the right values here. |
| 115 | logscip-go gomod github.com/golang/go/src go1.18 log/.Printfscip-go gomod github.com/golang/go/src go1.18 log/Printf().("expected defaults, got %v", val) |
| 116 | } else { |
| 117 | for i, v := range defaultProtocol2Identitiesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/defaultProtocol2Identities. { |
| 118 | if val[i] != v { |
| 119 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("invalid %d in val, expected %s got %s", i, v, val[i]) |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | val, err = us.GetAllStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetAllStrict().("protocol1", "IdentityFile") |
| 125 | if err != nil { |
| 126 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected nil err, got %v", err) |
| 127 | } |
| 128 | if len(val) != 1 || val[0] != "~/.ssh/identity" { |
| 129 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected [\"~/.ssh/identity\"], got %v", val) |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | func TestGetInvalidPortscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestGetInvalidPort().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 134 | us := &UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{ |
| 135 | userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfigFinder.: testConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/testConfigFinder().("testdata/invalid-port"), |
| 136 | } |
| 137 | |
| 138 | val, err := us.GetStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetStrict().("test.test", "Port") |
| 139 | if err == nil { |
| 140 | t.Fatalfscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatalf().("expected non-nil err, got nil") |
| 141 | } |
| 142 | if val != "" { |
| 143 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected to get '' for val, got %q", val) |
| 144 | } |
| 145 | if err.Error() != `ssh_config: strconv.ParseUint: parsing "notanumber": invalid syntax` { |
| 146 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("wrong error: got %v", err) |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | func TestGetNotFoundNoDefaultscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestGetNotFoundNoDefault().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 151 | us := &UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{ |
| 152 | userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfigFinder.: testConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/testConfigFinder().("testdata/config1"), |
| 153 | } |
| 154 | |
| 155 | val, err := us.GetStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetStrict().("wap", "CanonicalDomains") |
| 156 | if err != nil { |
| 157 | t.Fatalfscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatalf().("expected nil err, got %v", err) |
| 158 | } |
| 159 | if val != "" { |
| 160 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected to get CanonicalDomains '', got %q", val) |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | func TestGetAllNotFoundNoDefaultscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestGetAllNotFoundNoDefault().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 165 | us := &UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{ |
| 166 | userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfigFinder.: testConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/testConfigFinder().("testdata/config1"), |
| 167 | } |
| 168 | |
| 169 | val, err := us.GetAllStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetAllStrict().("wap", "CanonicalDomains") |
| 170 | if err != nil { |
| 171 | t.Fatalfscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatalf().("expected nil err, got %v", err) |
| 172 | } |
| 173 | if len(val) != 0 { |
| 174 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected to get CanonicalDomains '', got %q", val) |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | func TestGetWildcardscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestGetWildcard().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 179 | us := &UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{ |
| 180 | userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfigFinder.: testConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/testConfigFinder().("testdata/config3"), |
| 181 | } |
| 182 | |
| 183 | val := us.Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#Get().("bastion.stage.i.us.example.net", "Port") |
| 184 | if val != "22" { |
| 185 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected to find Port 22, got %q", val) |
| 186 | } |
| 187 | |
| 188 | val = us.Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#Get().("bastion.net", "Port") |
| 189 | if val != "25" { |
| 190 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected to find Port 24, got %q", val) |
| 191 | } |
| 192 | |
| 193 | val = us.Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#Get().("10.2.3.4", "Port") |
| 194 | if val != "23" { |
| 195 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected to find Port 23, got %q", val) |
| 196 | } |
| 197 | val = us.Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#Get().("101.2.3.4", "Port") |
| 198 | if val != "25" { |
| 199 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected to find Port 24, got %q", val) |
| 200 | } |
| 201 | val = us.Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#Get().("20.20.20.4", "Port") |
| 202 | if val != "24" { |
| 203 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected to find Port 24, got %q", val) |
| 204 | } |
| 205 | val = us.Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#Get().("20.20.20.20", "Port") |
| 206 | if val != "25" { |
| 207 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected to find Port 25, got %q", val) |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | func TestGetExtraSpacesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestGetExtraSpaces().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 212 | us := &UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{ |
| 213 | userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfigFinder.: testConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/testConfigFinder().("testdata/extraspace"), |
| 214 | } |
| 215 | |
| 216 | val := us.Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#Get().("test.test", "Port") |
| 217 | if val != "1234" { |
| 218 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected to find Port 1234, got %q", val) |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | func TestGetCaseInsensitivescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestGetCaseInsensitive().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 223 | us := &UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{ |
| 224 | userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfigFinder.: testConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/testConfigFinder().("testdata/config1"), |
| 225 | } |
| 226 | |
| 227 | val := us.Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#Get().("wap", "uSER") |
| 228 | if val != "root" { |
| 229 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected to find User root, got %q", val) |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | func TestGetEmptyscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestGetEmpty().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 234 | us := &UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{ |
| 235 | userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfigFinder.: nullConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/nullConfigFinder()., |
| 236 | systemConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#systemConfigFinder.: nullConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/nullConfigFinder()., |
| 237 | } |
| 238 | val, err := us.GetStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetStrict().("wap", "User") |
| 239 | if err != nil { |
| 240 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected nil error, got %v", err) |
| 241 | } |
| 242 | if val != "" { |
| 243 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected to get empty string, got %q", val) |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | func TestGetEqsignscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestGetEqsign().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 248 | us := &UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{ |
| 249 | userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfigFinder.: testConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/testConfigFinder().("testdata/eqsign"), |
| 250 | } |
| 251 | |
| 252 | val := us.Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#Get().("test.test", "Port") |
| 253 | if val != "1234" { |
| 254 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected to find Port 1234, got %q", val) |
| 255 | } |
| 256 | val = us.Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#Get().("test.test", "Port2") |
| 257 | if val != "5678" { |
| 258 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected to find Port2 5678, got %q", val) |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | var includeFilescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/includeFile. = []byte(` |
| 263 | # This host should not exist, so we can use it for test purposes / it won't |
| 264 | # interfere with any other configurations. |
| 265 | Host kevinburke.ssh_config.test.example.com |
| 266 | Port 4567 |
| 267 | `) |
| 268 | |
| 269 | func TestIncludescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestInclude().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 270 | if testingscip-go gomod github.com/golang/go/src go1.18 testing/.Shortscip-go gomod github.com/golang/go/src go1.18 testing/Short().() { |
| 271 | t.Skipscip-go gomod github.com/golang/go/src go1.18 testing/common#Skip().("skipping fs write in short mode") |
| 272 | } |
| 273 | testPath := filepathscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/Join().(homedirscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/homedir().(), ".ssh", "kevinburke-ssh-config-test-file") |
| 274 | err := osscip-go gomod github.com/golang/go/src go1.18 os/.WriteFilescip-go gomod github.com/golang/go/src go1.18 os/WriteFile().(testPath, includeFilescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/includeFile., 0644) |
| 275 | if err != nil { |
| 276 | t.Skipfscip-go gomod github.com/golang/go/src go1.18 testing/common#Skipf().("couldn't write SSH config file: %v", err.Error()) |
| 277 | } |
| 278 | defer osscip-go gomod github.com/golang/go/src go1.18 os/.Removescip-go gomod github.com/golang/go/src go1.18 os/Remove().(testPath) |
| 279 | us := &UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{ |
| 280 | userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfigFinder.: testConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/testConfigFinder().("testdata/include"), |
| 281 | } |
| 282 | val := us.Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#Get().("kevinburke.ssh_config.test.example.com", "Port") |
| 283 | if val != "4567" { |
| 284 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected to find Port=4567 in included file, got %q", val) |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | func TestIncludeSystemscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestIncludeSystem().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 289 | if testingscip-go gomod github.com/golang/go/src go1.18 testing/.Shortscip-go gomod github.com/golang/go/src go1.18 testing/Short().() { |
| 290 | t.Skipscip-go gomod github.com/golang/go/src go1.18 testing/common#Skip().("skipping fs write in short mode") |
| 291 | } |
| 292 | testPath := filepathscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/Join().("/", "etc", "ssh", "kevinburke-ssh-config-test-file") |
| 293 | err := osscip-go gomod github.com/golang/go/src go1.18 os/.WriteFilescip-go gomod github.com/golang/go/src go1.18 os/WriteFile().(testPath, includeFilescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/includeFile., 0644) |
| 294 | if err != nil { |
| 295 | t.Skipfscip-go gomod github.com/golang/go/src go1.18 testing/common#Skipf().("couldn't write SSH config file: %v", err.Error()) |
| 296 | } |
| 297 | defer osscip-go gomod github.com/golang/go/src go1.18 os/.Removescip-go gomod github.com/golang/go/src go1.18 os/Remove().(testPath) |
| 298 | us := &UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{ |
| 299 | systemConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#systemConfigFinder.: testConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/testConfigFinder().("testdata/include"), |
| 300 | } |
| 301 | val := us.Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#Get().("kevinburke.ssh_config.test.example.com", "Port") |
| 302 | if val != "4567" { |
| 303 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected to find Port=4567 in included file, got %q", val) |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | var recursiveIncludeFilescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/recursiveIncludeFile. = []byte(` |
| 308 | Host kevinburke.ssh_config.test.example.com |
| 309 | Include kevinburke-ssh-config-recursive-include |
| 310 | `) |
| 311 | |
| 312 | func TestIncludeRecursivescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestIncludeRecursive().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 313 | if testingscip-go gomod github.com/golang/go/src go1.18 testing/.Shortscip-go gomod github.com/golang/go/src go1.18 testing/Short().() { |
| 314 | t.Skipscip-go gomod github.com/golang/go/src go1.18 testing/common#Skip().("skipping fs write in short mode") |
| 315 | } |
| 316 | testPath := filepathscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.18 `path/filepath`/Join().(homedirscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/homedir().(), ".ssh", "kevinburke-ssh-config-recursive-include") |
| 317 | err := osscip-go gomod github.com/golang/go/src go1.18 os/.WriteFilescip-go gomod github.com/golang/go/src go1.18 os/WriteFile().(testPath, recursiveIncludeFilescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/recursiveIncludeFile., 0644) |
| 318 | if err != nil { |
| 319 | t.Skipfscip-go gomod github.com/golang/go/src go1.18 testing/common#Skipf().("couldn't write SSH config file: %v", err.Error()) |
| 320 | } |
| 321 | defer osscip-go gomod github.com/golang/go/src go1.18 os/.Removescip-go gomod github.com/golang/go/src go1.18 os/Remove().(testPath) |
| 322 | us := &UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{ |
| 323 | userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfigFinder.: testConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/testConfigFinder().("testdata/include-recursive"), |
| 324 | } |
| 325 | val, err := us.GetStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetStrict().("kevinburke.ssh_config.test.example.com", "Port") |
| 326 | if err != ErrDepthExceededscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/ErrDepthExceeded. { |
| 327 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("Recursive include: expected ErrDepthExceeded, got %v", err) |
| 328 | } |
| 329 | if val != "" { |
| 330 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("non-empty string value %s", val) |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | func TestIncludeStringscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestIncludeString().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 335 | if testingscip-go gomod github.com/golang/go/src go1.18 testing/.Shortscip-go gomod github.com/golang/go/src go1.18 testing/Short().() { |
| 336 | t.Skipscip-go gomod github.com/golang/go/src go1.18 testing/common#Skip().("skipping fs write in short mode") |
| 337 | } |
| 338 | data, err := osscip-go gomod github.com/golang/go/src go1.18 os/.ReadFilescip-go gomod github.com/golang/go/src go1.18 os/ReadFile().("testdata/include") |
| 339 | if err != nil { |
| 340 | logscip-go gomod github.com/golang/go/src go1.18 log/.Fatalscip-go gomod github.com/golang/go/src go1.18 log/Fatal().(err) |
| 341 | } |
| 342 | c, err := Decodescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Decode().(bytesscip-go gomod github.com/golang/go/src go1.18 bytes/.NewReaderscip-go gomod github.com/golang/go/src go1.18 bytes/NewReader().(data), false) |
| 343 | if err != nil { |
| 344 | t.Fatalscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatal().(err) |
| 345 | } |
| 346 | s := c.Stringscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Config#String().() |
| 347 | if s != string(data) { |
| 348 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("mismatch: got %q\nwant %q", s, string(data)) |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | var matchTestsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/matchTests. = []struct { |
| 353 | inscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/matchTests:in. []string |
| 354 | aliasscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/matchTests:alias. string |
| 355 | wantscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/matchTests:want. bool |
| 356 | }{ |
| 357 | {[]string{"*"}, "any.test", true}, |
| 358 | {[]string{"a", "b", "*", "c"}, "any.test", true}, |
| 359 | {[]string{"a", "b", "c"}, "any.test", false}, |
| 360 | {[]string{"any.test"}, "any1test", false}, |
| 361 | {[]string{"192.168.0.?"}, "192.168.0.1", true}, |
| 362 | {[]string{"192.168.0.?"}, "192.168.0.10", false}, |
| 363 | {[]string{"*.co.uk"}, "bbc.co.uk", true}, |
| 364 | {[]string{"*.co.uk"}, "subdomain.bbc.co.uk", true}, |
| 365 | {[]string{"*.*.co.uk"}, "bbc.co.uk", false}, |
| 366 | {[]string{"*.*.co.uk"}, "subdomain.bbc.co.uk", true}, |
| 367 | {[]string{"*.example.com", "!*.dialup.example.com", "foo.dialup.example.com"}, "foo.dialup.example.com", false}, |
| 368 | {[]string{"test.*", "!test.host"}, "test.host", false}, |
| 369 | } |
| 370 | |
| 371 | func TestMatchesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestMatches().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 372 | for _, tt := range matchTestsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/matchTests. { |
| 373 | patterns := make([]*Patternscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Pattern#, len(tt.inscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/matchTests:in.)) |
| 374 | for i := range tt.inscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/matchTests:in. { |
| 375 | pat, err := NewPatternscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/NewPattern().(tt.inscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/matchTests:in.[i]) |
| 376 | if err != nil { |
| 377 | t.Fatalfscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatalf().("error compiling pattern %s: %v", tt.inscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/matchTests:in.[i], err) |
| 378 | } |
| 379 | patterns[i] = pat |
| 380 | } |
| 381 | host := &Hostscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#{ |
| 382 | Patternsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Patterns.: patterns, |
| 383 | } |
| 384 | got := host.Matchesscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/Host#Matches().(tt.aliasscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/matchTests:alias.) |
| 385 | if got != tt.wantscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/matchTests:want. { |
| 386 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("host(%q).Matches(%q): got %v, want %v", tt.inscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/matchTests:in., tt.aliasscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/matchTests:alias., got, tt.wantscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/matchTests:want.) |
| 387 | } |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | func TestMatchUnsupportedscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestMatchUnsupported().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 392 | us := &UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{ |
| 393 | userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfigFinder.: testConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/testConfigFinder().("testdata/match-directive"), |
| 394 | } |
| 395 | |
| 396 | _, err := us.GetStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetStrict().("test.test", "Port") |
| 397 | if err == nil { |
| 398 | t.Fatalscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatal().("expected Match directive to error, didn't") |
| 399 | } |
| 400 | if !stringsscip-go gomod github.com/golang/go/src go1.18 strings/.Containsscip-go gomod github.com/golang/go/src go1.18 strings/Contains().(err.Error(), "ssh_config: Match directive parsing is unsupported") { |
| 401 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("wrong error: %v", err) |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | func TestIndexInRangescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestIndexInRange().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 406 | us := &UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{ |
| 407 | userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfigFinder.: testConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/testConfigFinder().("testdata/config4"), |
| 408 | } |
| 409 | |
| 410 | user, err := us.GetStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetStrict().("wap", "User") |
| 411 | if err != nil { |
| 412 | t.Fatalscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatal().(err) |
| 413 | } |
| 414 | if user != "root" { |
| 415 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected User to be %q, got %q", "root", user) |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | func TestDosLinesEndingsDecodescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestDosLinesEndingsDecode().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 420 | us := &UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{ |
| 421 | userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfigFinder.: testConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/testConfigFinder().("testdata/dos-lines"), |
| 422 | } |
| 423 | |
| 424 | user, err := us.GetStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetStrict().("wap", "User") |
| 425 | if err != nil { |
| 426 | t.Fatalscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatal().(err) |
| 427 | } |
| 428 | |
| 429 | if user != "root" { |
| 430 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected User to be %q, got %q", "root", user) |
| 431 | } |
| 432 | |
| 433 | host, err := us.GetStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetStrict().("wap2", "HostName") |
| 434 | if err != nil { |
| 435 | t.Fatalscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatal().(err) |
| 436 | } |
| 437 | |
| 438 | if host != "8.8.8.8" { |
| 439 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected HostName to be %q, got %q", "8.8.8.8", host) |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | func TestNoTrailingNewlinescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestNoTrailingNewline().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 444 | us := &UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{ |
| 445 | userConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#userConfigFinder.: testConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/testConfigFinder().("testdata/config-no-ending-newline"), |
| 446 | systemConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#systemConfigFinder.: nullConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/nullConfigFinder()., |
| 447 | } |
| 448 | |
| 449 | port, err := us.GetStrictscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#GetStrict().("example", "Port") |
| 450 | if err != nil { |
| 451 | t.Fatalscip-go gomod github.com/golang/go/src go1.18 testing/common#Fatal().(err) |
| 452 | } |
| 453 | |
| 454 | if port != "4242" { |
| 455 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("wrong port: got %q want 4242", port) |
| 456 | } |
| 457 | } |
| 458 | |
| 459 | func TestCustomFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestCustomFinder().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 460 | us := &UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{} |
| 461 | us.ConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#ConfigFinder().(func() string { |
| 462 | return "testdata/config1" |
| 463 | }) |
| 464 | |
| 465 | val := us.Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#Get().("wap", "User") |
| 466 | if val != "root" { |
| 467 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected to find User root, got %q", val) |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | func TestCustomFinderWhenIgnoringMatchDirectivescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestCustomFinderWhenIgnoringMatchDirective().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 472 | us := &UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{ |
| 473 | IgnoreMatchDirectivescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#IgnoreMatchDirective.: true, |
| 474 | } |
| 475 | us.ConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#ConfigFinder().(func() string { |
| 476 | return "testdata/config1-with-match-directive" |
| 477 | }) |
| 478 | |
| 479 | val := us.Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#Get().("git.yahoo.com", "HostName") |
| 480 | if val != "git.proxy.com" { |
| 481 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected to find Hostname git.proxy.com, got %q", val) |
| 482 | } |
| 483 | } |
| 484 | |
| 485 | func TestCustomFinderWhenNotIgnoringMatchDirectivescip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/TestCustomFinderWhenNotIgnoringMatchDirective().(t *testingscip-go gomod github.com/golang/go/src go1.18 testing/.Tscip-go gomod github.com/golang/go/src go1.18 testing/T#) { |
| 486 | us := &UserSettingsscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#{} |
| 487 | us.ConfigFinderscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#ConfigFinder().(func() string { |
| 488 | return "testdata/config1-with-match-directive" |
| 489 | }) |
| 490 | |
| 491 | val := us.Getscip-go gomod github.com/dimonomid/ssh_config . `github.com/dimonomid/ssh_config`/UserSettings#Get().("git.yahoo.com", "HostName") |
| 492 | if val != "" { |
| 493 | t.Errorfscip-go gomod github.com/golang/go/src go1.18 testing/common#Errorf().("expected to find Hostname empty %q", val) |
| 494 | } |
| 495 | } |