(t *testing.T)
| 150 | } |
| 151 | |
| 152 | func TestParseSSHConfigOption(t *testing.T) { |
| 153 | t.Parallel() |
| 154 | |
| 155 | testCases := []struct { |
| 156 | name string |
| 157 | option string |
| 158 | wantKey string |
| 159 | wantValue string |
| 160 | wantErr bool |
| 161 | }{ |
| 162 | { |
| 163 | name: "ProxyCommandWithSpaces", |
| 164 | option: "ProxyCommand=ssh -W %h:%p bastion", |
| 165 | wantKey: "ProxyCommand", |
| 166 | wantValue: "ssh -W %h:%p bastion", |
| 167 | }, |
| 168 | { |
| 169 | name: "SetEnvWithEquals", |
| 170 | option: "SetEnv=FOO=bar BAZ=qux", |
| 171 | wantKey: "SetEnv", |
| 172 | wantValue: "FOO=bar BAZ=qux", |
| 173 | }, |
| 174 | { |
| 175 | name: "SetEnvWithSpaceSeparator", |
| 176 | option: "SetEnv FOO=bar BAZ=qux", |
| 177 | wantKey: "SetEnv", |
| 178 | wantValue: "FOO=bar BAZ=qux", |
| 179 | }, |
| 180 | { |
| 181 | name: "HostName", |
| 182 | option: "HostName example.com", |
| 183 | wantKey: "HostName", |
| 184 | wantValue: "example.com", |
| 185 | }, |
| 186 | { |
| 187 | name: "NewlineInValue", |
| 188 | option: "ProxyCommand=echo hi\nHost *", |
| 189 | wantErr: true, |
| 190 | }, |
| 191 | { |
| 192 | name: "CarriageReturnInValue", |
| 193 | option: "ProxyCommand=echo hi\rHost *", |
| 194 | wantErr: true, |
| 195 | }, |
| 196 | { |
| 197 | name: "NULInValue", |
| 198 | option: "ProxyCommand=echo hi\x00Host *", |
| 199 | wantErr: true, |
| 200 | }, |
| 201 | { |
| 202 | name: "NewlineInKey", |
| 203 | option: "Proxy\nCommand=value", |
| 204 | wantErr: true, |
| 205 | }, |
| 206 | { |
| 207 | name: "CarriageReturnInKey", |
| 208 | option: "Proxy\rCommand=value", |
| 209 | wantErr: true, |
nothing calls this directly
no test coverage detected