mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
Allow vault ssh to work with single ssh args like -v (#4825)
This commit is contained in:
committed by
Jeff Mitchell
parent
5d26376460
commit
e32ba81b52
@@ -133,6 +133,31 @@ func TestParseSSHCommand(t *testing.T) {
|
||||
"",
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"Allow single args which don't have a value",
|
||||
[]string{
|
||||
"-v",
|
||||
"hostname",
|
||||
},
|
||||
"hostname",
|
||||
"",
|
||||
"",
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"Allow single args before and after the hostname and command",
|
||||
[]string{
|
||||
"-v",
|
||||
"hostname",
|
||||
"-v",
|
||||
"command",
|
||||
"-v",
|
||||
},
|
||||
"hostname",
|
||||
"",
|
||||
"",
|
||||
nil,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
@@ -154,3 +179,39 @@ func TestParseSSHCommand(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsSingleSSHArg(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
_, cmd := testSSHCommand(t)
|
||||
var tests = []struct {
|
||||
name string
|
||||
arg string
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
"-v is a single ssh arg",
|
||||
"-v",
|
||||
true,
|
||||
},
|
||||
{
|
||||
"-o is NOT a single ssh arg",
|
||||
"-o",
|
||||
false,
|
||||
},
|
||||
{
|
||||
"Repeated args like -vvv is still a single ssh arg",
|
||||
"-vvv",
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
got := cmd.isSingleSSHArg(test.arg)
|
||||
if got != test.want {
|
||||
t.Errorf("arg %q got %v want %v", test.arg, got, test.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user