mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 19:17:58 +00:00
Validate operator init args (#4838)
This commit is contained in:
committed by
Chris Hoffman
parent
2a3ee08dfa
commit
1d688e2bc6
@@ -259,6 +259,12 @@ func (c *OperatorInitCommand) Run(args []string) int {
|
|||||||
c.flagStatus = true
|
c.flagStatus = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
args = f.Args()
|
||||||
|
if len(args) > 0 {
|
||||||
|
c.UI.Error(fmt.Sprintf("Too many arguments (expected 0, got %d)", len(args)))
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
// Build the initial init request
|
// Build the initial init request
|
||||||
initReq := &api.InitRequest{
|
initReq := &api.InitRequest{
|
||||||
SecretShares: c.flagKeyShares,
|
SecretShares: c.flagKeyShares,
|
||||||
|
|||||||
@@ -35,6 +35,12 @@ func TestOperatorInitCommand_Run(t *testing.T) {
|
|||||||
out string
|
out string
|
||||||
code int
|
code int
|
||||||
}{
|
}{
|
||||||
|
{
|
||||||
|
"too_many_args",
|
||||||
|
[]string{"foo"},
|
||||||
|
"Too many arguments",
|
||||||
|
1,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"pgp_keys_multi",
|
"pgp_keys_multi",
|
||||||
[]string{
|
[]string{
|
||||||
@@ -341,7 +347,8 @@ func TestOperatorInitCommand_Run(t *testing.T) {
|
|||||||
cmd.client = client
|
cmd.client = client
|
||||||
|
|
||||||
code := cmd.Run([]string{
|
code := cmd.Run([]string{
|
||||||
"secret/foo",
|
"-key-shares=1",
|
||||||
|
"-key-threshold=1",
|
||||||
})
|
})
|
||||||
if exp := 2; code != exp {
|
if exp := 2; code != exp {
|
||||||
t.Errorf("expected %d to be %d", code, exp)
|
t.Errorf("expected %d to be %d", code, exp)
|
||||||
|
|||||||
Reference in New Issue
Block a user