mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 11:08:10 +00:00
Run all builtins as plugins (#5536)
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/hashicorp/vault/helper/consts"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
@@ -36,13 +37,13 @@ func TestPluginRegisterCommand_Run(t *testing.T) {
|
||||
},
|
||||
{
|
||||
"too_many_args",
|
||||
[]string{"foo", "bar"},
|
||||
[]string{"foo", "bar", "fizz"},
|
||||
"Too many arguments",
|
||||
1,
|
||||
},
|
||||
{
|
||||
"not_a_plugin",
|
||||
[]string{"nope_definitely_never_a_plugin_nope"},
|
||||
[]string{consts.PluginTypeCredential.String(), "nope_definitely_never_a_plugin_nope"},
|
||||
"",
|
||||
2,
|
||||
},
|
||||
@@ -90,7 +91,7 @@ func TestPluginRegisterCommand_Run(t *testing.T) {
|
||||
|
||||
code := cmd.Run([]string{
|
||||
"-sha256", sha256Sum,
|
||||
pluginName,
|
||||
consts.PluginTypeCredential.String(), pluginName,
|
||||
})
|
||||
if exp := 0; code != exp {
|
||||
t.Errorf("expected %d to be %d", code, exp)
|
||||
@@ -102,19 +103,23 @@ func TestPluginRegisterCommand_Run(t *testing.T) {
|
||||
t.Errorf("expected %q to contain %q", combined, expected)
|
||||
}
|
||||
|
||||
resp, err := client.Sys().ListPlugins(&api.ListPluginsInput{})
|
||||
resp, err := client.Sys().ListPlugins(&api.ListPluginsInput{
|
||||
Type: consts.PluginTypeCredential,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
found := false
|
||||
for _, p := range resp.Names {
|
||||
if p == pluginName {
|
||||
found = true
|
||||
for _, plugins := range resp.PluginsByType {
|
||||
for _, p := range plugins {
|
||||
if p == pluginName {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Errorf("expected %q to be in %q", pluginName, resp.Names)
|
||||
t.Errorf("expected %q to be in %q", pluginName, resp.PluginsByType)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -129,7 +134,7 @@ func TestPluginRegisterCommand_Run(t *testing.T) {
|
||||
|
||||
code := cmd.Run([]string{
|
||||
"-sha256", "abcd1234",
|
||||
"my-plugin",
|
||||
consts.PluginTypeCredential.String(), "my-plugin",
|
||||
})
|
||||
if exp := 2; code != exp {
|
||||
t.Errorf("expected %d to be %d", code, exp)
|
||||
|
||||
Reference in New Issue
Block a user