From f4879cbe88046cbaed80fa78ad9a8e393d093c3f Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Tue, 10 Apr 2018 00:22:23 -0400 Subject: [PATCH] Fix some tests --- http/sys_mount_test.go | 4 +++- .../cassandra/test-fixtures/cassandra.yaml | 2 +- vault/logical_system.go | 14 +++++++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/http/sys_mount_test.go b/http/sys_mount_test.go index 4494a122d3..5ad03b72ed 100644 --- a/http/sys_mount_test.go +++ b/http/sys_mount_test.go @@ -511,7 +511,7 @@ func TestSysRemount(t *testing.T) { } if !reflect.DeepEqual(actual, expected) { - t.Fatalf("bad: %#v", actual) + t.Fatalf("bad:\ngot\n%#v\nexpected\n%#v\n", actual, expected) } } @@ -734,10 +734,12 @@ func TestSysTuneMount_Options(t *testing.T) { "default_lease_ttl": json.Number("2764800"), "max_lease_ttl": json.Number("2764800"), "force_no_cache": false, + "options": map[string]interface{}{"test": "true"}, }, "default_lease_ttl": json.Number("2764800"), "max_lease_ttl": json.Number("2764800"), "force_no_cache": false, + "options": map[string]interface{}{"test": "true"}, } testResponseBody(t, resp, &actual) expected["request_id"] = actual["request_id"] diff --git a/plugins/database/cassandra/test-fixtures/cassandra.yaml b/plugins/database/cassandra/test-fixtures/cassandra.yaml index e8535107c8..82aa35dd4d 100644 --- a/plugins/database/cassandra/test-fixtures/cassandra.yaml +++ b/plugins/database/cassandra/test-fixtures/cassandra.yaml @@ -572,7 +572,7 @@ ssl_storage_port: 7001 # # Setting listen_address to 0.0.0.0 is always wrong. # -listen_address: 172.17.0.2 +listen_address: 172.17.0.5 # Set listen_address OR listen_interface, not both. Interfaces must correspond # to a single address, IP aliasing is not supported. diff --git a/vault/logical_system.go b/vault/logical_system.go index 2a4e74b019..298c69c070 100644 --- a/vault/logical_system.go +++ b/vault/logical_system.go @@ -1646,7 +1646,8 @@ func (b *SystemBackend) handleMount(ctx context.Context, req *logical.Request, d } switch logicalType { - case "kv", "kv-v1": + case "kv": + case "kv-v1": // Alias KV v1 logicalType = "kv" if options == nil { @@ -2117,9 +2118,10 @@ func (b *SystemBackend) handleTuneWriteCommon(ctx context.Context, path string, b.Core.logger.Info("mount tuning of options", "path", path, "options", options) var changed bool - + var numBuiltIn int if v, ok := options["version"]; ok { changed = true + numBuiltIn++ // Special case to make sure we can not disable versioning once it's // enabeled. If the vkv backend suports downgrading this can be removed. meVersion, err := parseutil.ParseInt(mountEntry.Options["version"]) @@ -2137,7 +2139,13 @@ func (b *SystemBackend) handleTuneWriteCommon(ctx context.Context, path string, resp = &logical.Response{} resp.AddWarning(fmt.Sprintf("Upgrading mount from version %d to version %d. This mount will be unavailable for a brief period and will resume service shortly.", meVersion, optVersion)) } - + } + if options != nil { + // For anything we don't recognize and provide special handling, + // always write + if len(options) > numBuiltIn { + changed = true + } } if changed {