mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 11:38:02 +00:00
CLI: Tune plugin version for auth/secret mounts (#17277)
* Add -plugin-version flag to vault auth/secrets tune * CLI tests for auth/secrets tune * CLI test for plugin register * Plugin catalog listing bug where plugins of different type with the same name could be double counted * Use constant for -plugin-version flag name
This commit is contained in:
@@ -6,6 +6,8 @@ import (
|
||||
|
||||
"github.com/go-test/deep"
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/hashicorp/vault/sdk/helper/consts"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
@@ -148,7 +150,10 @@ func TestSecretsTuneCommand_Run(t *testing.T) {
|
||||
t.Run("integration", func(t *testing.T) {
|
||||
t.Run("flags_all", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
client, closer := testVaultServer(t)
|
||||
pluginDir, cleanup := vault.MakeTestPluginDir(t)
|
||||
defer cleanup(t)
|
||||
|
||||
client, _, closer := testVaultServerPluginDir(t, pluginDir)
|
||||
defer closer()
|
||||
|
||||
ui, cmd := testSecretsTuneCommand(t)
|
||||
@@ -161,6 +166,21 @@ func TestSecretsTuneCommand_Run(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
mounts, err := client.Sys().ListMounts()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
mountInfo, ok := mounts["mount_tune_integration/"]
|
||||
if !ok {
|
||||
t.Fatalf("expected mount to exist")
|
||||
}
|
||||
|
||||
if exp := ""; mountInfo.PluginVersion != exp {
|
||||
t.Errorf("expected %q to be %q", mountInfo.PluginVersion, exp)
|
||||
}
|
||||
|
||||
_, _, version := testPluginCreateAndRegisterVersioned(t, client, pluginDir, "pki", consts.PluginTypeSecrets)
|
||||
|
||||
code := cmd.Run([]string{
|
||||
"-description", "new description",
|
||||
"-default-lease-ttl", "30m",
|
||||
@@ -172,6 +192,7 @@ func TestSecretsTuneCommand_Run(t *testing.T) {
|
||||
"-allowed-response-headers", "authorization,www-authentication",
|
||||
"-allowed-managed-keys", "key1,key2",
|
||||
"-listing-visibility", "unauth",
|
||||
"-plugin-version", version,
|
||||
"mount_tune_integration/",
|
||||
})
|
||||
if exp := 0; code != exp {
|
||||
@@ -184,12 +205,12 @@ func TestSecretsTuneCommand_Run(t *testing.T) {
|
||||
t.Errorf("expected %q to contain %q", combined, expected)
|
||||
}
|
||||
|
||||
mounts, err := client.Sys().ListMounts()
|
||||
mounts, err = client.Sys().ListMounts()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
mountInfo, ok := mounts["mount_tune_integration/"]
|
||||
mountInfo, ok = mounts["mount_tune_integration/"]
|
||||
if !ok {
|
||||
t.Fatalf("expected mount to exist")
|
||||
}
|
||||
@@ -199,6 +220,9 @@ func TestSecretsTuneCommand_Run(t *testing.T) {
|
||||
if exp := "pki"; mountInfo.Type != exp {
|
||||
t.Errorf("expected %q to be %q", mountInfo.Type, exp)
|
||||
}
|
||||
if exp := version; mountInfo.PluginVersion != exp {
|
||||
t.Errorf("expected %q to be %q", mountInfo.PluginVersion, exp)
|
||||
}
|
||||
if exp := 1800; mountInfo.Config.DefaultLeaseTTL != exp {
|
||||
t.Errorf("expected %d to be %d", mountInfo.Config.DefaultLeaseTTL, exp)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user