From 991c57466083c920b32703fb102feac35a44bbfb Mon Sep 17 00:00:00 2001 From: Mike Palmiotto Date: Wed, 7 Sep 2022 10:45:09 -0400 Subject: [PATCH] Mark database-specific secrets engines Pending Removal (#17038) * plugins: Mark standalone database plugins Pending Removal * Add changelog --- changelog/17038.txt | 3 +++ command/secrets_enable_test.go | 16 +++++++++++++--- helper/builtinplugins/registry.go | 10 +++++----- helper/builtinplugins/registry_test.go | 4 ++-- 4 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 changelog/17038.txt diff --git a/changelog/17038.txt b/changelog/17038.txt new file mode 100644 index 000000000..f6451dc99 --- /dev/null +++ b/changelog/17038.txt @@ -0,0 +1,3 @@ +```release-note:change +secrets: All database-specific (standalone DB) secrets engines are now marked `Pending Removal`. +``` diff --git a/command/secrets_enable_test.go b/command/secrets_enable_test.go index 814f47312..2eaa08aa2 100644 --- a/command/secrets_enable_test.go +++ b/command/secrets_enable_test.go @@ -2,6 +2,7 @@ package command import ( "io/ioutil" + "os" "strings" "testing" @@ -242,14 +243,23 @@ func TestSecretsEnableCommand_Run(t *testing.T) { } for _, b := range backends { + expectedResult := 0 + status, _ := builtinplugins.Registry.DeprecationStatus(b, consts.PluginTypeSecrets) + allowDeprecated := os.Getenv(consts.VaultAllowPendingRemovalMountsEnv) + + // Need to handle deprecated builtins specially + if (status == consts.PendingRemoval && allowDeprecated == "") || status == consts.Removed { + expectedResult = 2 + } + ui, cmd := testSecretsEnableCommand(t) cmd.client = client - code := cmd.Run([]string{ + actualResult := cmd.Run([]string{ b, }) - if exp := 0; code != exp { - t.Errorf("type %s, expected %d to be %d - %s", b, code, exp, ui.OutputWriter.String()+ui.ErrorWriter.String()) + if actualResult != expectedResult { + t.Errorf("type: %s - got: %d, expected: %d - %s", b, actualResult, expectedResult, ui.OutputWriter.String()+ui.ErrorWriter.String()) } } }) diff --git a/helper/builtinplugins/registry.go b/helper/builtinplugins/registry.go index c27fd0ceb..b31885012 100644 --- a/helper/builtinplugins/registry.go +++ b/helper/builtinplugins/registry.go @@ -141,7 +141,7 @@ func newRegistry() *registry { "azure": {Factory: logicalAzure.Factory}, "cassandra": { Factory: logicalCass.Factory, - DeprecationStatus: consts.Deprecated, + DeprecationStatus: consts.PendingRemoval, }, "consul": {Factory: logicalConsul.Factory}, "gcp": {Factory: logicalGcp.Factory}, @@ -150,23 +150,23 @@ func newRegistry() *registry { "kv": {Factory: logicalKv.Factory}, "mongodb": { Factory: logicalMongo.Factory, - DeprecationStatus: consts.Deprecated, + DeprecationStatus: consts.PendingRemoval, }, "mongodbatlas": {Factory: logicalMongoAtlas.Factory}, "mssql": { Factory: logicalMssql.Factory, - DeprecationStatus: consts.Deprecated, + DeprecationStatus: consts.PendingRemoval, }, "mysql": { Factory: logicalMysql.Factory, - DeprecationStatus: consts.Deprecated, + DeprecationStatus: consts.PendingRemoval, }, "nomad": {Factory: logicalNomad.Factory}, "openldap": {Factory: logicalOpenLDAP.Factory}, "pki": {Factory: logicalPki.Factory}, "postgresql": { Factory: logicalPostgres.Factory, - DeprecationStatus: consts.Deprecated, + DeprecationStatus: consts.PendingRemoval, }, "rabbitmq": {Factory: logicalRabbit.Factory}, "ssh": {Factory: logicalSsh.Factory}, diff --git a/helper/builtinplugins/registry_test.go b/helper/builtinplugins/registry_test.go index 25785f563..b726b9009 100644 --- a/helper/builtinplugins/registry_test.go +++ b/helper/builtinplugins/registry_test.go @@ -180,8 +180,8 @@ func Test_RegistryStatus(t *testing.T) { }, { name: "deprecated builtin lookup", - builtin: "mongodb", - pluginType: consts.PluginTypeSecrets, + builtin: "pcf", + pluginType: consts.PluginTypeCredential, want: consts.Deprecated, wantOk: true, },