2015-03-16 04:18:25 +00:00
|
|
|
package http
|
|
|
|
|
|
|
|
import (
|
2016-07-06 16:25:40 +00:00
|
|
|
"encoding/json"
|
2022-02-17 20:17:59 +00:00
|
|
|
"fmt"
|
2015-03-16 04:18:25 +00:00
|
|
|
"reflect"
|
|
|
|
"testing"
|
2022-02-17 20:17:59 +00:00
|
|
|
"time"
|
2015-03-16 04:18:25 +00:00
|
|
|
|
2015-09-03 14:20:44 +00:00
|
|
|
"github.com/fatih/structs"
|
Add plugin version to GRPC interface (#17088)
Add plugin version to GRPC interface
Added a version interface in the sdk/logical so that it can be shared between all plugin types, and then wired it up to RunningVersion in the mounts, auth list, and database systems.
I've tested that this works with auth, database, and secrets plugin types, with the following logic to populate RunningVersion:
If a plugin has a PluginVersion() method implemented, then that is used
If not, and the plugin is built into the Vault binary, then the go.mod version is used
Otherwise, the it will be the empty string.
My apologies for the length of this PR.
* Placeholder backend should be external
We use a placeholder backend (previously a framework.Backend) before a
GRPC plugin is lazy-loaded. This makes us later think the plugin is a
builtin plugin.
So we added a `placeholderBackend` type that overrides the
`IsExternal()` method so that later we know that the plugin is external,
and don't give it a default builtin version.
2022-09-15 23:37:59 +00:00
|
|
|
"github.com/go-test/deep"
|
2023-02-01 13:33:16 +00:00
|
|
|
"github.com/hashicorp/vault/helper/testhelpers/corehelpers"
|
Add plugin version to GRPC interface (#17088)
Add plugin version to GRPC interface
Added a version interface in the sdk/logical so that it can be shared between all plugin types, and then wired it up to RunningVersion in the mounts, auth list, and database systems.
I've tested that this works with auth, database, and secrets plugin types, with the following logic to populate RunningVersion:
If a plugin has a PluginVersion() method implemented, then that is used
If not, and the plugin is built into the Vault binary, then the go.mod version is used
Otherwise, the it will be the empty string.
My apologies for the length of this PR.
* Placeholder backend should be external
We use a placeholder backend (previously a framework.Backend) before a
GRPC plugin is lazy-loaded. This makes us later think the plugin is a
builtin plugin.
So we added a `placeholderBackend` type that overrides the
`IsExternal()` method so that later we know that the plugin is external,
and don't give it a default builtin version.
2022-09-15 23:37:59 +00:00
|
|
|
"github.com/hashicorp/vault/helper/versions"
|
|
|
|
"github.com/hashicorp/vault/sdk/helper/consts"
|
2015-03-16 04:18:25 +00:00
|
|
|
"github.com/hashicorp/vault/vault"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestSysMounts(t *testing.T) {
|
2015-03-29 23:14:54 +00:00
|
|
|
core, _, token := vault.TestCoreUnsealed(t)
|
2015-03-16 04:18:25 +00:00
|
|
|
ln, addr := TestServer(t, core)
|
|
|
|
defer ln.Close()
|
2015-03-29 23:14:54 +00:00
|
|
|
TestServerAuth(t, addr, token)
|
2015-03-16 04:18:25 +00:00
|
|
|
|
2015-08-22 00:36:19 +00:00
|
|
|
resp := testHttpGet(t, token, addr+"/v1/sys/mounts")
|
2015-03-16 04:18:25 +00:00
|
|
|
|
|
|
|
var actual map[string]interface{}
|
|
|
|
expected := map[string]interface{}{
|
2016-08-08 20:00:31 +00:00
|
|
|
"lease_id": "",
|
|
|
|
"renewable": false,
|
|
|
|
"lease_duration": json.Number("0"),
|
|
|
|
"wrap_info": nil,
|
|
|
|
"warnings": nil,
|
|
|
|
"auth": nil,
|
|
|
|
"data": map[string]interface{}{
|
|
|
|
"secret/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "key/value secret storage",
|
|
|
|
"type": "kv",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
2017-03-08 14:20:09 +00:00
|
|
|
"force_no_cache": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "kv"),
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
|
|
|
"sys/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "system endpoints used for control, policy and debugging",
|
|
|
|
"type": "system",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
"config": map[string]interface{}{
|
2019-02-20 20:12:21 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
2019-02-15 19:15:02 +00:00
|
|
|
"passthrough_request_headers": []interface{}{"Accept"},
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": true,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.DefaultBuiltinVersion,
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
|
|
|
"cubbyhole/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "per-token private secret storage",
|
|
|
|
"type": "cubbyhole",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
2017-03-08 14:20:09 +00:00
|
|
|
"force_no_cache": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": true,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "cubbyhole"),
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2017-10-11 17:21:20 +00:00
|
|
|
"identity/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "identity store",
|
|
|
|
"type": "identity",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2017-10-11 17:21:20 +00:00
|
|
|
"config": map[string]interface{}{
|
2021-10-14 01:59:36 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"passthrough_request_headers": []interface{}{"Authorization"},
|
2017-10-11 17:21:20 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "identity"),
|
2017-10-11 17:21:20 +00:00
|
|
|
},
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2018-09-05 15:45:17 +00:00
|
|
|
"secret/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "key/value secret storage",
|
|
|
|
"type": "kv",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "kv"),
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
|
|
|
"sys/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "system endpoints used for control, policy and debugging",
|
|
|
|
"type": "system",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
2019-02-20 20:12:21 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
2019-02-15 19:15:02 +00:00
|
|
|
"passthrough_request_headers": []interface{}{"Accept"},
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": true,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.DefaultBuiltinVersion,
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
|
|
|
"cubbyhole/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "per-token private secret storage",
|
|
|
|
"type": "cubbyhole",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": true,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "cubbyhole"),
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
|
|
|
"identity/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "identity store",
|
|
|
|
"type": "identity",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
2021-10-14 01:59:36 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"passthrough_request_headers": []interface{}{"Authorization"},
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "identity"),
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
2015-03-16 04:18:25 +00:00
|
|
|
}
|
|
|
|
testResponseStatus(t, resp, 200)
|
|
|
|
testResponseBody(t, resp, &actual)
|
2016-08-08 20:00:31 +00:00
|
|
|
expected["request_id"] = actual["request_id"]
|
2017-06-26 17:14:36 +00:00
|
|
|
for k, v := range actual["data"].(map[string]interface{}) {
|
|
|
|
if v.(map[string]interface{})["accessor"] == "" {
|
|
|
|
t.Fatalf("no accessor from %s", k)
|
|
|
|
}
|
2019-04-24 19:27:43 +00:00
|
|
|
if v.(map[string]interface{})["uuid"] == "" {
|
|
|
|
t.Fatalf("no uuid from %s", k)
|
|
|
|
}
|
2018-09-05 15:45:17 +00:00
|
|
|
expected[k].(map[string]interface{})["accessor"] = v.(map[string]interface{})["accessor"]
|
2019-04-24 19:27:43 +00:00
|
|
|
expected[k].(map[string]interface{})["uuid"] = v.(map[string]interface{})["uuid"]
|
2017-06-26 17:14:36 +00:00
|
|
|
expected["data"].(map[string]interface{})[k].(map[string]interface{})["accessor"] = v.(map[string]interface{})["accessor"]
|
2019-04-24 19:27:43 +00:00
|
|
|
expected["data"].(map[string]interface{})[k].(map[string]interface{})["uuid"] = v.(map[string]interface{})["uuid"]
|
2017-06-26 17:14:36 +00:00
|
|
|
}
|
|
|
|
|
2019-02-15 19:15:02 +00:00
|
|
|
if diff := deep.Equal(actual, expected); len(diff) > 0 {
|
|
|
|
t.Fatalf("bad, diff: %#v", diff)
|
2015-03-16 04:18:25 +00:00
|
|
|
}
|
|
|
|
}
|
2015-03-16 17:36:29 +00:00
|
|
|
|
|
|
|
func TestSysMount(t *testing.T) {
|
2015-03-29 23:14:54 +00:00
|
|
|
core, _, token := vault.TestCoreUnsealed(t)
|
2015-03-16 17:36:29 +00:00
|
|
|
ln, addr := TestServer(t, core)
|
|
|
|
defer ln.Close()
|
2015-03-29 23:14:54 +00:00
|
|
|
TestServerAuth(t, addr, token)
|
2015-03-16 17:36:29 +00:00
|
|
|
|
2015-08-22 00:36:19 +00:00
|
|
|
resp := testHttpPost(t, token, addr+"/v1/sys/mounts/foo", map[string]interface{}{
|
2017-09-15 13:02:29 +00:00
|
|
|
"type": "kv",
|
2015-03-16 17:36:29 +00:00
|
|
|
"description": "foo",
|
2018-03-21 19:04:27 +00:00
|
|
|
"options": map[string]string{
|
2018-04-09 20:14:44 +00:00
|
|
|
"version": "1",
|
2018-03-21 19:04:27 +00:00
|
|
|
},
|
2015-03-16 17:36:29 +00:00
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 204)
|
|
|
|
|
2015-08-22 00:36:19 +00:00
|
|
|
resp = testHttpGet(t, token, addr+"/v1/sys/mounts")
|
2015-03-16 17:36:29 +00:00
|
|
|
|
|
|
|
var actual map[string]interface{}
|
|
|
|
expected := map[string]interface{}{
|
2016-08-08 20:00:31 +00:00
|
|
|
"lease_id": "",
|
|
|
|
"renewable": false,
|
|
|
|
"lease_duration": json.Number("0"),
|
|
|
|
"wrap_info": nil,
|
|
|
|
"warnings": nil,
|
|
|
|
"auth": nil,
|
|
|
|
"data": map[string]interface{}{
|
|
|
|
"foo/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "foo",
|
|
|
|
"type": "kv",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
2017-03-08 14:20:09 +00:00
|
|
|
"force_no_cache": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "kv"),
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
|
|
|
"secret/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "key/value secret storage",
|
|
|
|
"type": "kv",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
2017-03-08 14:20:09 +00:00
|
|
|
"force_no_cache": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "kv"),
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
|
|
|
"sys/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "system endpoints used for control, policy and debugging",
|
|
|
|
"type": "system",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
"config": map[string]interface{}{
|
2019-02-20 20:12:21 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
2019-02-15 19:28:39 +00:00
|
|
|
"passthrough_request_headers": []interface{}{"Accept"},
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": true,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.DefaultBuiltinVersion,
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
|
|
|
"cubbyhole/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "per-token private secret storage",
|
|
|
|
"type": "cubbyhole",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
2017-03-08 14:20:09 +00:00
|
|
|
"force_no_cache": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": true,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "cubbyhole"),
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2017-10-11 17:21:20 +00:00
|
|
|
"identity/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "identity store",
|
|
|
|
"type": "identity",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2017-10-11 17:21:20 +00:00
|
|
|
"config": map[string]interface{}{
|
2021-10-14 01:59:36 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"passthrough_request_headers": []interface{}{"Authorization"},
|
2017-10-11 17:21:20 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "identity"),
|
2017-10-11 17:21:20 +00:00
|
|
|
},
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2018-09-05 15:45:17 +00:00
|
|
|
"foo/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "foo",
|
|
|
|
"type": "kv",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "kv"),
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
|
|
|
"secret/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "key/value secret storage",
|
|
|
|
"type": "kv",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "kv"),
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
|
|
|
"sys/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "system endpoints used for control, policy and debugging",
|
|
|
|
"type": "system",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
2019-02-20 20:12:21 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
2019-02-15 19:28:39 +00:00
|
|
|
"passthrough_request_headers": []interface{}{"Accept"},
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": true,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.DefaultBuiltinVersion,
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
|
|
|
"cubbyhole/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "per-token private secret storage",
|
|
|
|
"type": "cubbyhole",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": true,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "cubbyhole"),
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
|
|
|
"identity/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "identity store",
|
|
|
|
"type": "identity",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
2021-10-14 01:59:36 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"passthrough_request_headers": []interface{}{"Authorization"},
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "identity"),
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
2015-03-16 17:36:29 +00:00
|
|
|
}
|
|
|
|
testResponseStatus(t, resp, 200)
|
|
|
|
testResponseBody(t, resp, &actual)
|
2016-08-08 20:00:31 +00:00
|
|
|
expected["request_id"] = actual["request_id"]
|
2017-06-26 17:14:36 +00:00
|
|
|
for k, v := range actual["data"].(map[string]interface{}) {
|
|
|
|
if v.(map[string]interface{})["accessor"] == "" {
|
|
|
|
t.Fatalf("no accessor from %s", k)
|
|
|
|
}
|
2019-04-24 19:27:43 +00:00
|
|
|
if v.(map[string]interface{})["uuid"] == "" {
|
|
|
|
t.Fatalf("no uuid from %s", k)
|
|
|
|
}
|
2018-09-05 15:45:17 +00:00
|
|
|
expected[k].(map[string]interface{})["accessor"] = v.(map[string]interface{})["accessor"]
|
2019-04-24 19:27:43 +00:00
|
|
|
expected[k].(map[string]interface{})["uuid"] = v.(map[string]interface{})["uuid"]
|
2017-06-26 17:14:36 +00:00
|
|
|
expected["data"].(map[string]interface{})[k].(map[string]interface{})["accessor"] = v.(map[string]interface{})["accessor"]
|
2019-04-24 19:27:43 +00:00
|
|
|
expected["data"].(map[string]interface{})[k].(map[string]interface{})["uuid"] = v.(map[string]interface{})["uuid"]
|
2017-06-26 17:14:36 +00:00
|
|
|
}
|
|
|
|
|
2019-02-15 19:28:39 +00:00
|
|
|
if diff := deep.Equal(actual, expected); len(diff) > 0 {
|
|
|
|
t.Fatalf("bad, diff: %#v", diff)
|
2015-04-07 17:54:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-16 17:02:15 +00:00
|
|
|
func TestSysMount_put(t *testing.T) {
|
|
|
|
core, _, token := vault.TestCoreUnsealed(t)
|
|
|
|
ln, addr := TestServer(t, core)
|
|
|
|
defer ln.Close()
|
|
|
|
TestServerAuth(t, addr, token)
|
|
|
|
|
2015-08-22 00:36:19 +00:00
|
|
|
resp := testHttpPut(t, token, addr+"/v1/sys/mounts/foo", map[string]interface{}{
|
2017-09-15 13:02:29 +00:00
|
|
|
"type": "kv",
|
2015-06-16 17:02:15 +00:00
|
|
|
"description": "foo",
|
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 204)
|
|
|
|
|
|
|
|
// The TestSysMount test tests the thing is actually created. See that test
|
|
|
|
// for more info.
|
|
|
|
}
|
|
|
|
|
2015-04-07 17:54:58 +00:00
|
|
|
func TestSysRemount(t *testing.T) {
|
|
|
|
core, _, token := vault.TestCoreUnsealed(t)
|
|
|
|
ln, addr := TestServer(t, core)
|
|
|
|
defer ln.Close()
|
|
|
|
TestServerAuth(t, addr, token)
|
|
|
|
|
2015-08-22 00:36:19 +00:00
|
|
|
resp := testHttpPost(t, token, addr+"/v1/sys/mounts/foo", map[string]interface{}{
|
2017-09-15 13:02:29 +00:00
|
|
|
"type": "kv",
|
2015-04-07 17:54:58 +00:00
|
|
|
"description": "foo",
|
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 204)
|
|
|
|
|
2015-08-22 00:36:19 +00:00
|
|
|
resp = testHttpPost(t, token, addr+"/v1/sys/remount", map[string]interface{}{
|
2015-04-07 17:54:58 +00:00
|
|
|
"from": "foo",
|
|
|
|
"to": "bar",
|
|
|
|
})
|
2022-02-17 20:17:59 +00:00
|
|
|
testResponseStatus(t, resp, 200)
|
|
|
|
|
|
|
|
// Poll until the remount succeeds
|
|
|
|
var remountResp map[string]interface{}
|
|
|
|
testResponseBody(t, resp, &remountResp)
|
2023-02-01 13:33:16 +00:00
|
|
|
corehelpers.RetryUntil(t, 5*time.Second, func() error {
|
2022-02-17 20:17:59 +00:00
|
|
|
resp = testHttpGet(t, token, addr+"/v1/sys/remount/status/"+remountResp["migration_id"].(string))
|
|
|
|
testResponseStatus(t, resp, 200)
|
2022-02-16 19:21:42 +00:00
|
|
|
|
2022-02-17 20:17:59 +00:00
|
|
|
var remountStatusResp map[string]interface{}
|
|
|
|
testResponseBody(t, resp, &remountStatusResp)
|
|
|
|
|
|
|
|
status := remountStatusResp["data"].(map[string]interface{})["migration_info"].(map[string]interface{})["status"]
|
|
|
|
if status != "success" {
|
|
|
|
return fmt.Errorf("Expected migration status to be successful, got %q", status)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
2015-08-22 00:36:19 +00:00
|
|
|
resp = testHttpGet(t, token, addr+"/v1/sys/mounts")
|
2015-04-07 17:54:58 +00:00
|
|
|
|
|
|
|
var actual map[string]interface{}
|
|
|
|
expected := map[string]interface{}{
|
2016-08-08 20:00:31 +00:00
|
|
|
"lease_id": "",
|
|
|
|
"renewable": false,
|
|
|
|
"lease_duration": json.Number("0"),
|
|
|
|
"wrap_info": nil,
|
|
|
|
"warnings": nil,
|
|
|
|
"auth": nil,
|
|
|
|
"data": map[string]interface{}{
|
|
|
|
"bar/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "foo",
|
|
|
|
"type": "kv",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
2017-03-08 14:20:09 +00:00
|
|
|
"force_no_cache": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": map[string]interface{}{},
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "kv"),
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
|
|
|
"secret/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "key/value secret storage",
|
|
|
|
"type": "kv",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
2017-03-08 14:20:09 +00:00
|
|
|
"force_no_cache": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "kv"),
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
|
|
|
"sys/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "system endpoints used for control, policy and debugging",
|
|
|
|
"type": "system",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
"config": map[string]interface{}{
|
2019-02-20 20:12:21 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
2019-02-15 19:15:39 +00:00
|
|
|
"passthrough_request_headers": []interface{}{"Accept"},
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": true,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.DefaultBuiltinVersion,
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
|
|
|
"cubbyhole/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "per-token private secret storage",
|
|
|
|
"type": "cubbyhole",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
2017-03-08 14:20:09 +00:00
|
|
|
"force_no_cache": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": true,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "cubbyhole"),
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2017-10-11 17:21:20 +00:00
|
|
|
"identity/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "identity store",
|
|
|
|
"type": "identity",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2017-10-11 17:21:20 +00:00
|
|
|
"config": map[string]interface{}{
|
2021-10-14 01:59:36 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"passthrough_request_headers": []interface{}{"Authorization"},
|
2017-10-11 17:21:20 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "identity"),
|
2017-10-11 17:21:20 +00:00
|
|
|
},
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2018-09-05 15:45:17 +00:00
|
|
|
"bar/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "foo",
|
|
|
|
"type": "kv",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": map[string]interface{}{},
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "kv"),
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
|
|
|
"secret/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "key/value secret storage",
|
|
|
|
"type": "kv",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "kv"),
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
|
|
|
"sys/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "system endpoints used for control, policy and debugging",
|
|
|
|
"type": "system",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
2019-02-20 20:12:21 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
2019-02-15 19:15:39 +00:00
|
|
|
"passthrough_request_headers": []interface{}{"Accept"},
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": true,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.DefaultBuiltinVersion,
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
|
|
|
"cubbyhole/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "per-token private secret storage",
|
|
|
|
"type": "cubbyhole",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": true,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "cubbyhole"),
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
|
|
|
"identity/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "identity store",
|
|
|
|
"type": "identity",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
2021-10-14 01:59:36 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"passthrough_request_headers": []interface{}{"Authorization"},
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "identity"),
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
2015-04-07 17:54:58 +00:00
|
|
|
}
|
|
|
|
testResponseStatus(t, resp, 200)
|
|
|
|
testResponseBody(t, resp, &actual)
|
2016-08-08 20:00:31 +00:00
|
|
|
expected["request_id"] = actual["request_id"]
|
2017-06-26 17:14:36 +00:00
|
|
|
for k, v := range actual["data"].(map[string]interface{}) {
|
|
|
|
if v.(map[string]interface{})["accessor"] == "" {
|
|
|
|
t.Fatalf("no accessor from %s", k)
|
|
|
|
}
|
2019-04-24 19:27:43 +00:00
|
|
|
if v.(map[string]interface{})["uuid"] == "" {
|
|
|
|
t.Fatalf("no uuid from %s", k)
|
|
|
|
}
|
2018-09-05 15:45:17 +00:00
|
|
|
expected[k].(map[string]interface{})["accessor"] = v.(map[string]interface{})["accessor"]
|
2019-04-24 19:27:43 +00:00
|
|
|
expected[k].(map[string]interface{})["uuid"] = v.(map[string]interface{})["uuid"]
|
2017-06-26 17:14:36 +00:00
|
|
|
expected["data"].(map[string]interface{})[k].(map[string]interface{})["accessor"] = v.(map[string]interface{})["accessor"]
|
2019-04-24 19:27:43 +00:00
|
|
|
expected["data"].(map[string]interface{})[k].(map[string]interface{})["uuid"] = v.(map[string]interface{})["uuid"]
|
2017-06-26 17:14:36 +00:00
|
|
|
}
|
|
|
|
|
2015-04-07 17:54:58 +00:00
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
2019-02-15 19:15:39 +00:00
|
|
|
t.Fatalf("bad:\nExpected: %#v\nActual: %#v\n", expected, actual)
|
2015-03-16 17:36:29 +00:00
|
|
|
}
|
|
|
|
}
|
2015-03-16 17:41:08 +00:00
|
|
|
|
|
|
|
func TestSysUnmount(t *testing.T) {
|
2015-03-29 23:14:54 +00:00
|
|
|
core, _, token := vault.TestCoreUnsealed(t)
|
2015-03-16 17:41:08 +00:00
|
|
|
ln, addr := TestServer(t, core)
|
|
|
|
defer ln.Close()
|
2015-03-29 23:14:54 +00:00
|
|
|
TestServerAuth(t, addr, token)
|
2015-03-16 17:41:08 +00:00
|
|
|
|
2015-08-22 00:36:19 +00:00
|
|
|
resp := testHttpPost(t, token, addr+"/v1/sys/mounts/foo", map[string]interface{}{
|
2017-09-15 13:02:29 +00:00
|
|
|
"type": "kv",
|
2015-03-16 17:41:08 +00:00
|
|
|
"description": "foo",
|
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 204)
|
|
|
|
|
2015-08-22 00:36:19 +00:00
|
|
|
resp = testHttpDelete(t, token, addr+"/v1/sys/mounts/foo")
|
2015-03-16 17:41:08 +00:00
|
|
|
testResponseStatus(t, resp, 204)
|
|
|
|
|
2015-08-22 00:36:19 +00:00
|
|
|
resp = testHttpGet(t, token, addr+"/v1/sys/mounts")
|
2015-03-16 17:41:08 +00:00
|
|
|
|
|
|
|
var actual map[string]interface{}
|
|
|
|
expected := map[string]interface{}{
|
2016-08-08 20:00:31 +00:00
|
|
|
"lease_id": "",
|
|
|
|
"renewable": false,
|
|
|
|
"lease_duration": json.Number("0"),
|
|
|
|
"wrap_info": nil,
|
|
|
|
"warnings": nil,
|
|
|
|
"auth": nil,
|
|
|
|
"data": map[string]interface{}{
|
|
|
|
"secret/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "key/value secret storage",
|
|
|
|
"type": "kv",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
2017-03-08 14:20:09 +00:00
|
|
|
"force_no_cache": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "kv"),
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
|
|
|
"sys/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "system endpoints used for control, policy and debugging",
|
|
|
|
"type": "system",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
"config": map[string]interface{}{
|
2019-02-20 20:12:21 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
2019-02-15 18:20:29 +00:00
|
|
|
"passthrough_request_headers": []interface{}{"Accept"},
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": true,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.DefaultBuiltinVersion,
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
|
|
|
"cubbyhole/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "per-token private secret storage",
|
|
|
|
"type": "cubbyhole",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
2017-03-08 14:20:09 +00:00
|
|
|
"force_no_cache": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": true,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "cubbyhole"),
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2017-10-11 17:21:20 +00:00
|
|
|
"identity/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "identity store",
|
|
|
|
"type": "identity",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2017-10-11 17:21:20 +00:00
|
|
|
"config": map[string]interface{}{
|
2021-10-14 01:59:36 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"passthrough_request_headers": []interface{}{"Authorization"},
|
2017-10-11 17:21:20 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "identity"),
|
2017-10-11 17:21:20 +00:00
|
|
|
},
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2018-09-05 15:45:17 +00:00
|
|
|
"secret/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "key/value secret storage",
|
|
|
|
"type": "kv",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "kv"),
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
|
|
|
"sys/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "system endpoints used for control, policy and debugging",
|
|
|
|
"type": "system",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
2019-02-20 20:12:21 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
2019-02-15 18:20:29 +00:00
|
|
|
"passthrough_request_headers": []interface{}{"Accept"},
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": true,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.DefaultBuiltinVersion,
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
|
|
|
"cubbyhole/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "per-token private secret storage",
|
|
|
|
"type": "cubbyhole",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": true,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "cubbyhole"),
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
|
|
|
"identity/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "identity store",
|
|
|
|
"type": "identity",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
2021-10-14 01:59:36 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"passthrough_request_headers": []interface{}{"Authorization"},
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "identity"),
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
2015-03-16 17:41:08 +00:00
|
|
|
}
|
|
|
|
testResponseStatus(t, resp, 200)
|
|
|
|
testResponseBody(t, resp, &actual)
|
2016-08-08 20:00:31 +00:00
|
|
|
expected["request_id"] = actual["request_id"]
|
2017-06-26 17:14:36 +00:00
|
|
|
for k, v := range actual["data"].(map[string]interface{}) {
|
|
|
|
if v.(map[string]interface{})["accessor"] == "" {
|
|
|
|
t.Fatalf("no accessor from %s", k)
|
|
|
|
}
|
2019-04-24 19:27:43 +00:00
|
|
|
if v.(map[string]interface{})["uuid"] == "" {
|
|
|
|
t.Fatalf("no uuid from %s", k)
|
|
|
|
}
|
2018-09-05 15:45:17 +00:00
|
|
|
expected[k].(map[string]interface{})["accessor"] = v.(map[string]interface{})["accessor"]
|
2019-04-24 19:27:43 +00:00
|
|
|
expected[k].(map[string]interface{})["uuid"] = v.(map[string]interface{})["uuid"]
|
2017-06-26 17:14:36 +00:00
|
|
|
expected["data"].(map[string]interface{})[k].(map[string]interface{})["accessor"] = v.(map[string]interface{})["accessor"]
|
2019-04-24 19:27:43 +00:00
|
|
|
expected["data"].(map[string]interface{})[k].(map[string]interface{})["uuid"] = v.(map[string]interface{})["uuid"]
|
2017-06-26 17:14:36 +00:00
|
|
|
}
|
|
|
|
|
2019-02-15 18:20:29 +00:00
|
|
|
if diff := deep.Equal(actual, expected); len(diff) > 0 {
|
|
|
|
t.Fatalf("bad, diff: %#v", diff)
|
2015-03-16 17:41:08 +00:00
|
|
|
}
|
|
|
|
}
|
2015-09-02 21:46:15 +00:00
|
|
|
|
2018-03-21 19:04:27 +00:00
|
|
|
func TestSysTuneMount_Options(t *testing.T) {
|
|
|
|
core, _, token := vault.TestCoreUnsealed(t)
|
|
|
|
ln, addr := TestServer(t, core)
|
|
|
|
defer ln.Close()
|
|
|
|
TestServerAuth(t, addr, token)
|
|
|
|
|
|
|
|
resp := testHttpPost(t, token, addr+"/v1/sys/mounts/foo", map[string]interface{}{
|
|
|
|
"type": "kv",
|
|
|
|
"description": "foo",
|
|
|
|
})
|
|
|
|
|
|
|
|
testResponseStatus(t, resp, 204)
|
|
|
|
// Mount-tune the options
|
|
|
|
resp = testHttpPost(t, token, addr+"/v1/sys/mounts/foo/tune", map[string]interface{}{
|
|
|
|
"options": map[string]string{
|
|
|
|
"test": "true",
|
|
|
|
},
|
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 204)
|
|
|
|
|
|
|
|
// Check results
|
|
|
|
resp = testHttpGet(t, token, addr+"/v1/sys/mounts/foo/tune")
|
|
|
|
testResponseStatus(t, resp, 200)
|
|
|
|
|
|
|
|
actual := map[string]interface{}{}
|
|
|
|
expected := map[string]interface{}{
|
|
|
|
"lease_id": "",
|
|
|
|
"renewable": false,
|
|
|
|
"lease_duration": json.Number("0"),
|
|
|
|
"wrap_info": nil,
|
|
|
|
"warnings": nil,
|
|
|
|
"auth": nil,
|
|
|
|
"data": map[string]interface{}{
|
2020-02-15 18:32:47 +00:00
|
|
|
"description": "foo",
|
2018-03-21 19:04:27 +00:00
|
|
|
"default_lease_ttl": json.Number("2764800"),
|
|
|
|
"max_lease_ttl": json.Number("2764800"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"options": map[string]interface{}{"test": "true"},
|
|
|
|
},
|
2020-02-15 18:32:47 +00:00
|
|
|
"description": "foo",
|
2018-09-05 15:45:17 +00:00
|
|
|
"default_lease_ttl": json.Number("2764800"),
|
|
|
|
"max_lease_ttl": json.Number("2764800"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"options": map[string]interface{}{"test": "true"},
|
2018-03-21 19:04:27 +00:00
|
|
|
}
|
|
|
|
testResponseBody(t, resp, &actual)
|
|
|
|
expected["request_id"] = actual["request_id"]
|
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
|
|
|
t.Fatalf("bad:\nExpected: %#v\nActual:%#v", expected, actual)
|
|
|
|
}
|
|
|
|
|
2018-11-19 22:23:25 +00:00
|
|
|
// Check that we're not allowed to unset the options map once that's set
|
2018-03-21 19:04:27 +00:00
|
|
|
resp = testHttpPost(t, token, addr+"/v1/sys/mounts/foo/tune", map[string]interface{}{
|
|
|
|
"options": map[string]string{},
|
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 204)
|
|
|
|
|
|
|
|
// Check results
|
|
|
|
resp = testHttpGet(t, token, addr+"/v1/sys/mounts/foo/tune")
|
|
|
|
testResponseStatus(t, resp, 200)
|
|
|
|
|
|
|
|
actual = map[string]interface{}{}
|
|
|
|
expected = map[string]interface{}{
|
2020-02-15 18:32:47 +00:00
|
|
|
"description": "foo",
|
2018-03-21 19:04:27 +00:00
|
|
|
"lease_id": "",
|
|
|
|
"renewable": false,
|
|
|
|
"lease_duration": json.Number("0"),
|
|
|
|
"wrap_info": nil,
|
|
|
|
"warnings": nil,
|
|
|
|
"auth": nil,
|
|
|
|
"data": map[string]interface{}{
|
2020-02-15 18:32:47 +00:00
|
|
|
"description": "foo",
|
2018-03-21 19:04:27 +00:00
|
|
|
"default_lease_ttl": json.Number("2764800"),
|
|
|
|
"max_lease_ttl": json.Number("2764800"),
|
|
|
|
"force_no_cache": false,
|
2018-04-10 04:22:23 +00:00
|
|
|
"options": map[string]interface{}{"test": "true"},
|
2018-03-21 19:04:27 +00:00
|
|
|
},
|
2018-09-05 15:45:17 +00:00
|
|
|
"default_lease_ttl": json.Number("2764800"),
|
|
|
|
"max_lease_ttl": json.Number("2764800"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"options": map[string]interface{}{"test": "true"},
|
2018-03-21 19:04:27 +00:00
|
|
|
}
|
|
|
|
testResponseBody(t, resp, &actual)
|
|
|
|
expected["request_id"] = actual["request_id"]
|
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
|
|
|
t.Fatalf("bad:\nExpected: %#v\nActual:%#v", expected, actual)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-02 21:46:15 +00:00
|
|
|
func TestSysTuneMount(t *testing.T) {
|
|
|
|
core, _, token := vault.TestCoreUnsealed(t)
|
|
|
|
ln, addr := TestServer(t, core)
|
|
|
|
defer ln.Close()
|
|
|
|
TestServerAuth(t, addr, token)
|
|
|
|
|
|
|
|
resp := testHttpPost(t, token, addr+"/v1/sys/mounts/foo", map[string]interface{}{
|
2017-09-15 13:02:29 +00:00
|
|
|
"type": "kv",
|
2015-09-02 21:46:15 +00:00
|
|
|
"description": "foo",
|
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 204)
|
|
|
|
|
|
|
|
resp = testHttpGet(t, token, addr+"/v1/sys/mounts")
|
|
|
|
|
|
|
|
var actual map[string]interface{}
|
|
|
|
expected := map[string]interface{}{
|
2016-08-08 20:00:31 +00:00
|
|
|
"lease_id": "",
|
|
|
|
"renewable": false,
|
|
|
|
"lease_duration": json.Number("0"),
|
|
|
|
"wrap_info": nil,
|
|
|
|
"warnings": nil,
|
|
|
|
"auth": nil,
|
|
|
|
"data": map[string]interface{}{
|
|
|
|
"foo/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "foo",
|
|
|
|
"type": "kv",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
2017-03-08 14:20:09 +00:00
|
|
|
"force_no_cache": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": map[string]interface{}{},
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "kv"),
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
|
|
|
"secret/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "key/value secret storage",
|
|
|
|
"type": "kv",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
2017-03-08 14:20:09 +00:00
|
|
|
"force_no_cache": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "kv"),
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
|
|
|
"sys/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "system endpoints used for control, policy and debugging",
|
|
|
|
"type": "system",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
"config": map[string]interface{}{
|
2019-02-20 20:12:21 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
2019-02-15 18:20:29 +00:00
|
|
|
"passthrough_request_headers": []interface{}{"Accept"},
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": true,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.DefaultBuiltinVersion,
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
|
|
|
"cubbyhole/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "per-token private secret storage",
|
|
|
|
"type": "cubbyhole",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
2017-03-08 14:20:09 +00:00
|
|
|
"force_no_cache": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": true,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "cubbyhole"),
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2017-10-11 17:21:20 +00:00
|
|
|
"identity/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "identity store",
|
|
|
|
"type": "identity",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2017-10-11 17:21:20 +00:00
|
|
|
"config": map[string]interface{}{
|
2021-10-14 01:59:36 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"passthrough_request_headers": []interface{}{"Authorization"},
|
2017-10-11 17:21:20 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "identity"),
|
2017-10-11 17:21:20 +00:00
|
|
|
},
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2018-09-05 15:45:17 +00:00
|
|
|
"foo/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "foo",
|
|
|
|
"type": "kv",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": map[string]interface{}{},
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "kv"),
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
|
|
|
"secret/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "key/value secret storage",
|
|
|
|
"type": "kv",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "kv"),
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
|
|
|
"sys/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "system endpoints used for control, policy and debugging",
|
|
|
|
"type": "system",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
2019-02-20 20:12:21 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
2019-02-15 18:20:29 +00:00
|
|
|
"passthrough_request_headers": []interface{}{"Accept"},
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": true,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.DefaultBuiltinVersion,
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
|
|
|
"cubbyhole/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "per-token private secret storage",
|
|
|
|
"type": "cubbyhole",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": true,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "cubbyhole"),
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
|
|
|
"identity/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "identity store",
|
|
|
|
"type": "identity",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
2021-10-14 01:59:36 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"passthrough_request_headers": []interface{}{"Authorization"},
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "identity"),
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
2015-09-02 21:46:15 +00:00
|
|
|
}
|
|
|
|
testResponseStatus(t, resp, 200)
|
|
|
|
testResponseBody(t, resp, &actual)
|
2016-08-08 20:00:31 +00:00
|
|
|
expected["request_id"] = actual["request_id"]
|
2017-06-26 17:14:36 +00:00
|
|
|
for k, v := range actual["data"].(map[string]interface{}) {
|
|
|
|
if v.(map[string]interface{})["accessor"] == "" {
|
|
|
|
t.Fatalf("no accessor from %s", k)
|
|
|
|
}
|
2019-04-24 19:27:43 +00:00
|
|
|
if v.(map[string]interface{})["uuid"] == "" {
|
|
|
|
t.Fatalf("no uuid from %s", k)
|
|
|
|
}
|
2018-09-05 15:45:17 +00:00
|
|
|
expected[k].(map[string]interface{})["accessor"] = v.(map[string]interface{})["accessor"]
|
2019-04-24 19:27:43 +00:00
|
|
|
expected[k].(map[string]interface{})["uuid"] = v.(map[string]interface{})["uuid"]
|
2017-06-26 17:14:36 +00:00
|
|
|
expected["data"].(map[string]interface{})[k].(map[string]interface{})["accessor"] = v.(map[string]interface{})["accessor"]
|
2019-04-24 19:27:43 +00:00
|
|
|
expected["data"].(map[string]interface{})[k].(map[string]interface{})["uuid"] = v.(map[string]interface{})["uuid"]
|
2017-06-26 17:14:36 +00:00
|
|
|
}
|
|
|
|
|
2019-02-15 18:20:29 +00:00
|
|
|
if diff := deep.Equal(actual, expected); len(diff) > 0 {
|
|
|
|
t.Fatalf("bad, diff: %#v", diff)
|
2015-09-02 21:46:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Shorter than system default
|
|
|
|
resp = testHttpPost(t, token, addr+"/v1/sys/mounts/foo/tune", map[string]interface{}{
|
2015-09-25 13:46:20 +00:00
|
|
|
"default_lease_ttl": "72h",
|
2015-09-02 21:46:15 +00:00
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 204)
|
|
|
|
|
2015-09-09 19:24:45 +00:00
|
|
|
// Longer than system max
|
2015-09-02 21:46:15 +00:00
|
|
|
resp = testHttpPost(t, token, addr+"/v1/sys/mounts/foo/tune", map[string]interface{}{
|
2015-09-25 13:46:20 +00:00
|
|
|
"default_lease_ttl": "72000h",
|
2015-09-02 21:46:15 +00:00
|
|
|
})
|
2017-09-05 14:57:25 +00:00
|
|
|
testResponseStatus(t, resp, 204)
|
2015-09-02 21:46:15 +00:00
|
|
|
|
|
|
|
// Longer than system default
|
|
|
|
resp = testHttpPost(t, token, addr+"/v1/sys/mounts/foo/tune", map[string]interface{}{
|
2015-09-25 13:46:20 +00:00
|
|
|
"max_lease_ttl": "72000h",
|
2015-09-02 21:46:15 +00:00
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 204)
|
|
|
|
|
|
|
|
// Longer than backend max
|
|
|
|
resp = testHttpPost(t, token, addr+"/v1/sys/mounts/foo/tune", map[string]interface{}{
|
2015-09-25 13:46:20 +00:00
|
|
|
"default_lease_ttl": "72001h",
|
2015-09-02 21:46:15 +00:00
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 400)
|
|
|
|
|
2015-09-03 14:20:44 +00:00
|
|
|
// Shorter than backend default
|
|
|
|
resp = testHttpPost(t, token, addr+"/v1/sys/mounts/foo/tune", map[string]interface{}{
|
2015-09-25 13:46:20 +00:00
|
|
|
"max_lease_ttl": "1h",
|
2015-09-03 14:20:44 +00:00
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 400)
|
|
|
|
|
2015-09-02 21:46:15 +00:00
|
|
|
// Shorter than backend max, longer than system max
|
|
|
|
resp = testHttpPost(t, token, addr+"/v1/sys/mounts/foo/tune", map[string]interface{}{
|
2015-09-25 13:46:20 +00:00
|
|
|
"default_lease_ttl": "71999h",
|
2015-09-02 21:46:15 +00:00
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 204)
|
|
|
|
|
2018-03-21 19:04:27 +00:00
|
|
|
// mark as versioned
|
|
|
|
resp = testHttpPost(t, token, addr+"/v1/sys/mounts/foo/tune", map[string]interface{}{
|
|
|
|
"options": map[string]string{
|
2018-04-09 20:14:44 +00:00
|
|
|
"version": "1",
|
2018-03-21 19:04:27 +00:00
|
|
|
},
|
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 200)
|
|
|
|
|
2015-09-02 21:46:15 +00:00
|
|
|
resp = testHttpGet(t, token, addr+"/v1/sys/mounts")
|
|
|
|
expected = map[string]interface{}{
|
2016-08-08 20:00:31 +00:00
|
|
|
"lease_id": "",
|
|
|
|
"renewable": false,
|
|
|
|
"lease_duration": json.Number("0"),
|
|
|
|
"wrap_info": nil,
|
|
|
|
"warnings": nil,
|
|
|
|
"auth": nil,
|
|
|
|
"data": map[string]interface{}{
|
|
|
|
"foo/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "foo",
|
|
|
|
"type": "kv",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("259196400"),
|
|
|
|
"max_lease_ttl": json.Number("259200000"),
|
2017-03-08 14:20:09 +00:00
|
|
|
"force_no_cache": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "kv"),
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
|
|
|
"secret/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "key/value secret storage",
|
|
|
|
"type": "kv",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
2017-03-08 14:20:09 +00:00
|
|
|
"force_no_cache": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "kv"),
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
|
|
|
"sys/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "system endpoints used for control, policy and debugging",
|
|
|
|
"type": "system",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
"config": map[string]interface{}{
|
2019-02-20 20:12:21 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
2019-02-15 18:20:29 +00:00
|
|
|
"passthrough_request_headers": []interface{}{"Accept"},
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": true,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.DefaultBuiltinVersion,
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
|
|
|
"cubbyhole/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "per-token private secret storage",
|
|
|
|
"type": "cubbyhole",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
2017-03-08 14:20:09 +00:00
|
|
|
"force_no_cache": false,
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": true,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "cubbyhole"),
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2017-10-11 17:21:20 +00:00
|
|
|
"identity/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "identity store",
|
|
|
|
"type": "identity",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2017-10-11 17:21:20 +00:00
|
|
|
"config": map[string]interface{}{
|
2021-10-14 01:59:36 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"passthrough_request_headers": []interface{}{"Authorization"},
|
2017-10-11 17:21:20 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "identity"),
|
2017-10-11 17:21:20 +00:00
|
|
|
},
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2018-09-05 15:45:17 +00:00
|
|
|
"foo/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "foo",
|
|
|
|
"type": "kv",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("259196400"),
|
|
|
|
"max_lease_ttl": json.Number("259200000"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "kv"),
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
|
|
|
"secret/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "key/value secret storage",
|
|
|
|
"type": "kv",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "kv"),
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
|
|
|
"sys/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "system endpoints used for control, policy and debugging",
|
|
|
|
"type": "system",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
2019-02-20 20:12:21 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
2019-02-15 18:20:29 +00:00
|
|
|
"passthrough_request_headers": []interface{}{"Accept"},
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": true,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "kv"),
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
|
|
|
"cubbyhole/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "per-token private secret storage",
|
|
|
|
"type": "cubbyhole",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": true,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "cubbyhole"),
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
|
|
|
"identity/": map[string]interface{}{
|
2019-11-07 16:54:34 +00:00
|
|
|
"description": "identity store",
|
|
|
|
"type": "identity",
|
2019-10-17 17:33:00 +00:00
|
|
|
"external_entropy_access": false,
|
2018-09-05 15:45:17 +00:00
|
|
|
"config": map[string]interface{}{
|
2021-10-14 01:59:36 +00:00
|
|
|
"default_lease_ttl": json.Number("0"),
|
|
|
|
"max_lease_ttl": json.Number("0"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"passthrough_request_headers": []interface{}{"Authorization"},
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
2022-09-20 11:35:50 +00:00
|
|
|
"local": false,
|
|
|
|
"seal_wrap": false,
|
|
|
|
"options": interface{}(nil),
|
|
|
|
"plugin_version": "",
|
|
|
|
"running_sha256": "",
|
|
|
|
"running_plugin_version": versions.GetBuiltinVersion(consts.PluginTypeSecrets, "identity"),
|
2018-09-05 15:45:17 +00:00
|
|
|
},
|
2015-09-02 21:46:15 +00:00
|
|
|
}
|
2015-09-03 12:54:59 +00:00
|
|
|
|
2015-09-02 21:46:15 +00:00
|
|
|
testResponseStatus(t, resp, 200)
|
|
|
|
testResponseBody(t, resp, &actual)
|
2016-08-08 20:00:31 +00:00
|
|
|
expected["request_id"] = actual["request_id"]
|
2017-06-26 17:14:36 +00:00
|
|
|
for k, v := range actual["data"].(map[string]interface{}) {
|
|
|
|
if v.(map[string]interface{})["accessor"] == "" {
|
|
|
|
t.Fatalf("no accessor from %s", k)
|
|
|
|
}
|
2019-04-24 19:27:43 +00:00
|
|
|
if v.(map[string]interface{})["uuid"] == "" {
|
|
|
|
t.Fatalf("no uuid from %s", k)
|
|
|
|
}
|
2018-09-05 15:45:17 +00:00
|
|
|
expected[k].(map[string]interface{})["accessor"] = v.(map[string]interface{})["accessor"]
|
2019-04-24 19:27:43 +00:00
|
|
|
expected[k].(map[string]interface{})["uuid"] = v.(map[string]interface{})["uuid"]
|
2017-06-26 17:14:36 +00:00
|
|
|
expected["data"].(map[string]interface{})[k].(map[string]interface{})["accessor"] = v.(map[string]interface{})["accessor"]
|
2019-04-24 19:27:43 +00:00
|
|
|
expected["data"].(map[string]interface{})[k].(map[string]interface{})["uuid"] = v.(map[string]interface{})["uuid"]
|
2017-06-26 17:14:36 +00:00
|
|
|
}
|
|
|
|
|
2019-02-15 18:20:29 +00:00
|
|
|
if diff := deep.Equal(actual, expected); len(diff) > 0 {
|
|
|
|
t.Fatalf("bad, diff: %#v", diff)
|
2015-09-02 21:46:15 +00:00
|
|
|
}
|
|
|
|
|
2015-09-03 14:20:44 +00:00
|
|
|
// Check simple configuration endpoint
|
2015-09-02 21:46:15 +00:00
|
|
|
resp = testHttpGet(t, token, addr+"/v1/sys/mounts/foo/tune")
|
2015-09-03 12:54:59 +00:00
|
|
|
actual = map[string]interface{}{}
|
2015-09-02 21:46:15 +00:00
|
|
|
expected = map[string]interface{}{
|
2016-08-08 20:00:31 +00:00
|
|
|
"lease_id": "",
|
|
|
|
"renewable": false,
|
|
|
|
"lease_duration": json.Number("0"),
|
|
|
|
"wrap_info": nil,
|
|
|
|
"warnings": nil,
|
|
|
|
"auth": nil,
|
|
|
|
"data": map[string]interface{}{
|
2020-02-15 18:32:47 +00:00
|
|
|
"description": "foo",
|
2016-08-08 20:00:31 +00:00
|
|
|
"default_lease_ttl": json.Number("259196400"),
|
|
|
|
"max_lease_ttl": json.Number("259200000"),
|
2017-03-08 14:20:09 +00:00
|
|
|
"force_no_cache": false,
|
2018-04-09 20:14:44 +00:00
|
|
|
"options": map[string]interface{}{"version": "1"},
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2020-02-15 18:32:47 +00:00
|
|
|
"description": "foo",
|
2018-09-05 15:45:17 +00:00
|
|
|
"default_lease_ttl": json.Number("259196400"),
|
|
|
|
"max_lease_ttl": json.Number("259200000"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
2015-09-02 21:46:15 +00:00
|
|
|
}
|
2015-09-03 12:54:59 +00:00
|
|
|
|
2015-09-02 21:46:15 +00:00
|
|
|
testResponseStatus(t, resp, 200)
|
|
|
|
testResponseBody(t, resp, &actual)
|
2016-08-08 20:00:31 +00:00
|
|
|
expected["request_id"] = actual["request_id"]
|
2015-09-03 14:20:44 +00:00
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
|
|
|
t.Fatalf("bad:\nExpected: %#v\nActual:%#v", expected, actual)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set a low max
|
|
|
|
resp = testHttpPost(t, token, addr+"/v1/sys/mounts/secret/tune", map[string]interface{}{
|
2020-02-15 18:32:47 +00:00
|
|
|
"description": "foobar",
|
2015-09-25 13:46:20 +00:00
|
|
|
"default_lease_ttl": "40s",
|
|
|
|
"max_lease_ttl": "80s",
|
2015-09-03 14:20:44 +00:00
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 204)
|
2015-09-02 21:46:15 +00:00
|
|
|
|
2015-09-03 14:20:44 +00:00
|
|
|
resp = testHttpGet(t, token, addr+"/v1/sys/mounts/secret/tune")
|
|
|
|
actual = map[string]interface{}{}
|
|
|
|
expected = map[string]interface{}{
|
2016-08-08 20:00:31 +00:00
|
|
|
"lease_id": "",
|
|
|
|
"renewable": false,
|
|
|
|
"lease_duration": json.Number("0"),
|
|
|
|
"wrap_info": nil,
|
|
|
|
"warnings": nil,
|
|
|
|
"auth": nil,
|
|
|
|
"data": map[string]interface{}{
|
2020-02-15 18:32:47 +00:00
|
|
|
"description": "foobar",
|
2016-08-08 20:00:31 +00:00
|
|
|
"default_lease_ttl": json.Number("40"),
|
|
|
|
"max_lease_ttl": json.Number("80"),
|
2017-03-08 14:20:09 +00:00
|
|
|
"force_no_cache": false,
|
2018-04-09 20:14:44 +00:00
|
|
|
"options": map[string]interface{}{"version": "1"},
|
2016-08-08 20:00:31 +00:00
|
|
|
},
|
2020-02-15 18:32:47 +00:00
|
|
|
"description": "foobar",
|
2018-09-05 15:45:17 +00:00
|
|
|
"default_lease_ttl": json.Number("40"),
|
|
|
|
"max_lease_ttl": json.Number("80"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
2015-09-03 14:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
testResponseStatus(t, resp, 200)
|
|
|
|
testResponseBody(t, resp, &actual)
|
2016-08-08 20:00:31 +00:00
|
|
|
expected["request_id"] = actual["request_id"]
|
2015-09-02 21:46:15 +00:00
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
|
|
|
t.Fatalf("bad:\nExpected: %#v\nActual:%#v", expected, actual)
|
|
|
|
}
|
2015-09-03 14:20:44 +00:00
|
|
|
|
|
|
|
// First try with lease above backend max
|
|
|
|
resp = testHttpPut(t, token, addr+"/v1/secret/foo", map[string]interface{}{
|
|
|
|
"data": "bar",
|
|
|
|
"ttl": "28347h",
|
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 204)
|
|
|
|
|
|
|
|
// read secret
|
|
|
|
resp = testHttpGet(t, token, addr+"/v1/secret/foo")
|
|
|
|
var result struct {
|
|
|
|
LeaseID string `json:"lease_id" structs:"lease_id"`
|
|
|
|
LeaseDuration int `json:"lease_duration" structs:"lease_duration"`
|
|
|
|
}
|
|
|
|
|
|
|
|
testResponseBody(t, resp, &result)
|
|
|
|
|
|
|
|
expected = map[string]interface{}{
|
2015-09-25 13:46:20 +00:00
|
|
|
"lease_duration": int(80),
|
2015-09-03 14:20:44 +00:00
|
|
|
"lease_id": result.LeaseID,
|
|
|
|
}
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(structs.Map(result), expected) {
|
|
|
|
t.Fatalf("bad:\nExpected: %#v\nActual:%#v", expected, structs.Map(result))
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now with lease TTL unspecified
|
|
|
|
resp = testHttpPut(t, token, addr+"/v1/secret/foo", map[string]interface{}{
|
|
|
|
"data": "bar",
|
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 204)
|
|
|
|
|
|
|
|
// read secret
|
|
|
|
resp = testHttpGet(t, token, addr+"/v1/secret/foo")
|
|
|
|
|
|
|
|
testResponseBody(t, resp, &result)
|
|
|
|
|
|
|
|
expected = map[string]interface{}{
|
2015-09-25 13:46:20 +00:00
|
|
|
"lease_duration": int(40),
|
2015-09-03 14:20:44 +00:00
|
|
|
"lease_id": result.LeaseID,
|
|
|
|
}
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(structs.Map(result), expected) {
|
|
|
|
t.Fatalf("bad:\nExpected: %#v\nActual:%#v", expected, structs.Map(result))
|
|
|
|
}
|
2015-09-02 21:46:15 +00:00
|
|
|
}
|
2018-03-02 17:18:39 +00:00
|
|
|
|
|
|
|
func TestSysTuneMount_nonHMACKeys(t *testing.T) {
|
|
|
|
core, _, token := vault.TestCoreUnsealed(t)
|
|
|
|
ln, addr := TestServer(t, core)
|
|
|
|
defer ln.Close()
|
|
|
|
TestServerAuth(t, addr, token)
|
|
|
|
|
|
|
|
// Mount-tune the audit_non_hmac_request_keys
|
|
|
|
resp := testHttpPost(t, token, addr+"/v1/sys/mounts/secret/tune", map[string]interface{}{
|
|
|
|
"audit_non_hmac_request_keys": "foo",
|
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 204)
|
|
|
|
|
|
|
|
// Mount-tune the audit_non_hmac_response_keys
|
|
|
|
resp = testHttpPost(t, token, addr+"/v1/sys/mounts/secret/tune", map[string]interface{}{
|
|
|
|
"audit_non_hmac_response_keys": "bar",
|
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 204)
|
|
|
|
|
|
|
|
// Check results
|
|
|
|
resp = testHttpGet(t, token, addr+"/v1/sys/mounts/secret/tune")
|
|
|
|
testResponseStatus(t, resp, 200)
|
|
|
|
|
|
|
|
actual := map[string]interface{}{}
|
|
|
|
expected := map[string]interface{}{
|
|
|
|
"lease_id": "",
|
|
|
|
"renewable": false,
|
|
|
|
"lease_duration": json.Number("0"),
|
|
|
|
"wrap_info": nil,
|
|
|
|
"warnings": nil,
|
|
|
|
"auth": nil,
|
|
|
|
"data": map[string]interface{}{
|
2020-02-15 18:32:47 +00:00
|
|
|
"description": "key/value secret storage",
|
2018-03-02 17:18:39 +00:00
|
|
|
"default_lease_ttl": json.Number("2764800"),
|
|
|
|
"max_lease_ttl": json.Number("2764800"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"audit_non_hmac_request_keys": []interface{}{"foo"},
|
|
|
|
"audit_non_hmac_response_keys": []interface{}{"bar"},
|
2018-04-09 20:14:44 +00:00
|
|
|
"options": map[string]interface{}{"version": "1"},
|
2018-03-02 17:18:39 +00:00
|
|
|
},
|
2020-02-15 18:32:47 +00:00
|
|
|
"description": "key/value secret storage",
|
2018-09-05 15:45:17 +00:00
|
|
|
"default_lease_ttl": json.Number("2764800"),
|
|
|
|
"max_lease_ttl": json.Number("2764800"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"audit_non_hmac_request_keys": []interface{}{"foo"},
|
|
|
|
"audit_non_hmac_response_keys": []interface{}{"bar"},
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
2018-03-02 17:18:39 +00:00
|
|
|
}
|
|
|
|
testResponseBody(t, resp, &actual)
|
|
|
|
expected["request_id"] = actual["request_id"]
|
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
|
|
|
t.Fatalf("bad:\nExpected: %#v\nActual:%#v", expected, actual)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unset those mount tune values
|
|
|
|
resp = testHttpPost(t, token, addr+"/v1/sys/mounts/secret/tune", map[string]interface{}{
|
|
|
|
"audit_non_hmac_request_keys": "",
|
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 204)
|
|
|
|
|
|
|
|
resp = testHttpPost(t, token, addr+"/v1/sys/mounts/secret/tune", map[string]interface{}{
|
|
|
|
"audit_non_hmac_response_keys": "",
|
|
|
|
})
|
2018-03-21 23:56:47 +00:00
|
|
|
testResponseStatus(t, resp, 204)
|
2018-03-02 17:18:39 +00:00
|
|
|
|
|
|
|
// Check results
|
|
|
|
resp = testHttpGet(t, token, addr+"/v1/sys/mounts/secret/tune")
|
|
|
|
testResponseStatus(t, resp, 200)
|
|
|
|
|
|
|
|
actual = map[string]interface{}{}
|
|
|
|
expected = map[string]interface{}{
|
|
|
|
"lease_id": "",
|
|
|
|
"renewable": false,
|
|
|
|
"lease_duration": json.Number("0"),
|
|
|
|
"wrap_info": nil,
|
|
|
|
"warnings": nil,
|
|
|
|
"auth": nil,
|
|
|
|
"data": map[string]interface{}{
|
2020-02-15 18:32:47 +00:00
|
|
|
"description": "key/value secret storage",
|
2018-03-02 17:18:39 +00:00
|
|
|
"default_lease_ttl": json.Number("2764800"),
|
|
|
|
"max_lease_ttl": json.Number("2764800"),
|
|
|
|
"force_no_cache": false,
|
2018-04-09 20:14:44 +00:00
|
|
|
"options": map[string]interface{}{"version": "1"},
|
2018-03-02 17:18:39 +00:00
|
|
|
},
|
2020-02-15 18:32:47 +00:00
|
|
|
"description": "key/value secret storage",
|
2018-09-05 15:45:17 +00:00
|
|
|
"default_lease_ttl": json.Number("2764800"),
|
|
|
|
"max_lease_ttl": json.Number("2764800"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
2018-03-02 17:18:39 +00:00
|
|
|
}
|
|
|
|
testResponseBody(t, resp, &actual)
|
|
|
|
expected["request_id"] = actual["request_id"]
|
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
|
|
|
t.Fatalf("bad:\nExpected: %#v\nActual:%#v", expected, actual)
|
|
|
|
}
|
|
|
|
}
|
2018-03-20 03:16:33 +00:00
|
|
|
|
2018-03-21 23:56:47 +00:00
|
|
|
func TestSysTuneMount_listingVisibility(t *testing.T) {
|
2018-03-20 03:16:33 +00:00
|
|
|
core, _, token := vault.TestCoreUnsealed(t)
|
|
|
|
ln, addr := TestServer(t, core)
|
|
|
|
defer ln.Close()
|
|
|
|
TestServerAuth(t, addr, token)
|
|
|
|
|
|
|
|
// Get original tune values, ensure that listing_visibility is not set
|
|
|
|
resp := testHttpGet(t, token, addr+"/v1/sys/mounts/secret/tune")
|
|
|
|
testResponseStatus(t, resp, 200)
|
|
|
|
|
|
|
|
actual := map[string]interface{}{}
|
|
|
|
expected := map[string]interface{}{
|
|
|
|
"lease_id": "",
|
|
|
|
"renewable": false,
|
|
|
|
"lease_duration": json.Number("0"),
|
|
|
|
"wrap_info": nil,
|
|
|
|
"warnings": nil,
|
|
|
|
"auth": nil,
|
|
|
|
"data": map[string]interface{}{
|
2020-02-15 18:32:47 +00:00
|
|
|
"description": "key/value secret storage",
|
2018-03-20 03:16:33 +00:00
|
|
|
"default_lease_ttl": json.Number("2764800"),
|
|
|
|
"max_lease_ttl": json.Number("2764800"),
|
|
|
|
"force_no_cache": false,
|
2018-04-09 20:14:44 +00:00
|
|
|
"options": map[string]interface{}{"version": "1"},
|
2018-03-20 03:16:33 +00:00
|
|
|
},
|
2020-02-15 18:32:47 +00:00
|
|
|
"description": "key/value secret storage",
|
2018-09-05 15:45:17 +00:00
|
|
|
"default_lease_ttl": json.Number("2764800"),
|
|
|
|
"max_lease_ttl": json.Number("2764800"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
2018-03-20 03:16:33 +00:00
|
|
|
}
|
|
|
|
testResponseBody(t, resp, &actual)
|
|
|
|
expected["request_id"] = actual["request_id"]
|
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
|
|
|
t.Fatalf("bad:\nExpected: %#v\nActual:%#v", expected, actual)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mount-tune the listing_visibility
|
|
|
|
resp = testHttpPost(t, token, addr+"/v1/sys/mounts/secret/tune", map[string]interface{}{
|
|
|
|
"listing_visibility": "unauth",
|
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 204)
|
|
|
|
|
|
|
|
// Check results
|
|
|
|
resp = testHttpGet(t, token, addr+"/v1/sys/mounts/secret/tune")
|
|
|
|
testResponseStatus(t, resp, 200)
|
|
|
|
|
|
|
|
actual = map[string]interface{}{}
|
|
|
|
expected = map[string]interface{}{
|
|
|
|
"lease_id": "",
|
|
|
|
"renewable": false,
|
|
|
|
"lease_duration": json.Number("0"),
|
|
|
|
"wrap_info": nil,
|
|
|
|
"warnings": nil,
|
|
|
|
"auth": nil,
|
|
|
|
"data": map[string]interface{}{
|
2020-02-15 18:32:47 +00:00
|
|
|
"description": "key/value secret storage",
|
2018-03-20 03:16:33 +00:00
|
|
|
"default_lease_ttl": json.Number("2764800"),
|
|
|
|
"max_lease_ttl": json.Number("2764800"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"listing_visibility": "unauth",
|
2018-04-09 20:14:44 +00:00
|
|
|
"options": map[string]interface{}{"version": "1"},
|
2018-03-20 03:16:33 +00:00
|
|
|
},
|
2020-02-15 18:32:47 +00:00
|
|
|
"description": "key/value secret storage",
|
2018-09-05 15:45:17 +00:00
|
|
|
"default_lease_ttl": json.Number("2764800"),
|
|
|
|
"max_lease_ttl": json.Number("2764800"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"listing_visibility": "unauth",
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
2018-03-20 03:16:33 +00:00
|
|
|
}
|
|
|
|
testResponseBody(t, resp, &actual)
|
|
|
|
expected["request_id"] = actual["request_id"]
|
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
|
|
|
t.Fatalf("bad:\nExpected: %#v\nActual:%#v", expected, actual)
|
|
|
|
}
|
|
|
|
}
|
2018-03-21 23:56:47 +00:00
|
|
|
|
|
|
|
func TestSysTuneMount_passthroughRequestHeaders(t *testing.T) {
|
|
|
|
core, _, token := vault.TestCoreUnsealed(t)
|
|
|
|
ln, addr := TestServer(t, core)
|
|
|
|
defer ln.Close()
|
|
|
|
TestServerAuth(t, addr, token)
|
|
|
|
|
|
|
|
// Mount-tune the audit_non_hmac_request_keys
|
|
|
|
resp := testHttpPost(t, token, addr+"/v1/sys/mounts/secret/tune", map[string]interface{}{
|
|
|
|
"passthrough_request_headers": "X-Vault-Foo",
|
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 204)
|
|
|
|
|
|
|
|
// Check results
|
|
|
|
resp = testHttpGet(t, token, addr+"/v1/sys/mounts/secret/tune")
|
|
|
|
testResponseStatus(t, resp, 200)
|
|
|
|
|
|
|
|
actual := map[string]interface{}{}
|
|
|
|
expected := map[string]interface{}{
|
|
|
|
"lease_id": "",
|
|
|
|
"renewable": false,
|
|
|
|
"lease_duration": json.Number("0"),
|
|
|
|
"wrap_info": nil,
|
|
|
|
"warnings": nil,
|
|
|
|
"auth": nil,
|
|
|
|
"data": map[string]interface{}{
|
2020-02-15 18:32:47 +00:00
|
|
|
"description": "key/value secret storage",
|
2018-03-21 23:56:47 +00:00
|
|
|
"default_lease_ttl": json.Number("2764800"),
|
|
|
|
"max_lease_ttl": json.Number("2764800"),
|
2018-04-09 20:14:44 +00:00
|
|
|
"options": map[string]interface{}{"version": "1"},
|
2018-03-21 23:56:47 +00:00
|
|
|
"force_no_cache": false,
|
|
|
|
"passthrough_request_headers": []interface{}{"X-Vault-Foo"},
|
|
|
|
},
|
2020-02-15 18:32:47 +00:00
|
|
|
"description": "key/value secret storage",
|
2018-09-05 15:45:17 +00:00
|
|
|
"default_lease_ttl": json.Number("2764800"),
|
|
|
|
"max_lease_ttl": json.Number("2764800"),
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
|
|
|
"force_no_cache": false,
|
|
|
|
"passthrough_request_headers": []interface{}{"X-Vault-Foo"},
|
2018-03-21 23:56:47 +00:00
|
|
|
}
|
|
|
|
testResponseBody(t, resp, &actual)
|
|
|
|
expected["request_id"] = actual["request_id"]
|
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
|
|
|
t.Fatalf("bad:\nExpected: %#v\nActual:%#v", expected, actual)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unset the mount tune value
|
|
|
|
resp = testHttpPost(t, token, addr+"/v1/sys/mounts/secret/tune", map[string]interface{}{
|
|
|
|
"passthrough_request_headers": "",
|
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 204)
|
|
|
|
|
|
|
|
// Check results
|
|
|
|
resp = testHttpGet(t, token, addr+"/v1/sys/mounts/secret/tune")
|
2021-11-22 01:08:38 +00:00
|
|
|
testResponseStatus(t, resp, 200)
|
|
|
|
|
|
|
|
actual = map[string]interface{}{}
|
|
|
|
expected = map[string]interface{}{
|
|
|
|
"lease_id": "",
|
|
|
|
"renewable": false,
|
|
|
|
"lease_duration": json.Number("0"),
|
|
|
|
"wrap_info": nil,
|
|
|
|
"warnings": nil,
|
|
|
|
"auth": nil,
|
|
|
|
"data": map[string]interface{}{
|
|
|
|
"description": "key/value secret storage",
|
|
|
|
"default_lease_ttl": json.Number("2764800"),
|
|
|
|
"max_lease_ttl": json.Number("2764800"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
|
|
|
},
|
|
|
|
"description": "key/value secret storage",
|
|
|
|
"default_lease_ttl": json.Number("2764800"),
|
|
|
|
"max_lease_ttl": json.Number("2764800"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
|
|
|
}
|
|
|
|
testResponseBody(t, resp, &actual)
|
|
|
|
expected["request_id"] = actual["request_id"]
|
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
|
|
|
t.Fatalf("bad:\nExpected: %#v\nActual:%#v", expected, actual)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSysTuneMount_allowedManagedKeys(t *testing.T) {
|
|
|
|
core, _, token := vault.TestCoreUnsealed(t)
|
|
|
|
ln, addr := TestServer(t, core)
|
|
|
|
defer ln.Close()
|
|
|
|
TestServerAuth(t, addr, token)
|
|
|
|
|
|
|
|
// Mount-tune the allowed_managed_keys
|
|
|
|
resp := testHttpPost(t, token, addr+"/v1/sys/mounts/secret/tune", map[string]interface{}{
|
|
|
|
"allowed_managed_keys": "test_key",
|
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 204)
|
|
|
|
|
|
|
|
// Check results
|
|
|
|
resp = testHttpGet(t, token, addr+"/v1/sys/mounts/secret/tune")
|
|
|
|
testResponseStatus(t, resp, 200)
|
|
|
|
|
|
|
|
actual := map[string]interface{}{}
|
|
|
|
expected := map[string]interface{}{
|
|
|
|
"lease_id": "",
|
|
|
|
"renewable": false,
|
|
|
|
"lease_duration": json.Number("0"),
|
|
|
|
"wrap_info": nil,
|
|
|
|
"warnings": nil,
|
|
|
|
"auth": nil,
|
|
|
|
"data": map[string]interface{}{
|
2022-01-27 18:06:34 +00:00
|
|
|
"description": "key/value secret storage",
|
|
|
|
"default_lease_ttl": json.Number("2764800"),
|
|
|
|
"max_lease_ttl": json.Number("2764800"),
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
|
|
|
"force_no_cache": false,
|
2021-11-22 01:08:38 +00:00
|
|
|
"allowed_managed_keys": []interface{}{"test_key"},
|
|
|
|
},
|
2022-01-27 18:06:34 +00:00
|
|
|
"description": "key/value secret storage",
|
|
|
|
"default_lease_ttl": json.Number("2764800"),
|
|
|
|
"max_lease_ttl": json.Number("2764800"),
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
|
|
|
"force_no_cache": false,
|
2021-11-22 01:08:38 +00:00
|
|
|
"allowed_managed_keys": []interface{}{"test_key"},
|
|
|
|
}
|
|
|
|
testResponseBody(t, resp, &actual)
|
|
|
|
expected["request_id"] = actual["request_id"]
|
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
|
|
|
t.Fatalf("bad:\nExpected: %#v\nActual:%#v", expected, actual)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unset the mount tune value
|
|
|
|
resp = testHttpPost(t, token, addr+"/v1/sys/mounts/secret/tune", map[string]interface{}{
|
|
|
|
"allowed_managed_keys": "",
|
|
|
|
})
|
|
|
|
testResponseStatus(t, resp, 204)
|
|
|
|
|
|
|
|
// Check results
|
|
|
|
resp = testHttpGet(t, token, addr+"/v1/sys/mounts/secret/tune")
|
2018-03-21 23:56:47 +00:00
|
|
|
testResponseStatus(t, resp, 200)
|
|
|
|
|
|
|
|
actual = map[string]interface{}{}
|
|
|
|
expected = map[string]interface{}{
|
|
|
|
"lease_id": "",
|
|
|
|
"renewable": false,
|
|
|
|
"lease_duration": json.Number("0"),
|
|
|
|
"wrap_info": nil,
|
|
|
|
"warnings": nil,
|
|
|
|
"auth": nil,
|
|
|
|
"data": map[string]interface{}{
|
2020-02-15 18:32:47 +00:00
|
|
|
"description": "key/value secret storage",
|
2018-03-21 23:56:47 +00:00
|
|
|
"default_lease_ttl": json.Number("2764800"),
|
|
|
|
"max_lease_ttl": json.Number("2764800"),
|
|
|
|
"force_no_cache": false,
|
2018-04-09 20:14:44 +00:00
|
|
|
"options": map[string]interface{}{"version": "1"},
|
2018-03-21 23:56:47 +00:00
|
|
|
},
|
2020-02-15 18:32:47 +00:00
|
|
|
"description": "key/value secret storage",
|
2018-09-05 15:45:17 +00:00
|
|
|
"default_lease_ttl": json.Number("2764800"),
|
|
|
|
"max_lease_ttl": json.Number("2764800"),
|
|
|
|
"force_no_cache": false,
|
|
|
|
"options": map[string]interface{}{"version": "1"},
|
2018-03-21 23:56:47 +00:00
|
|
|
}
|
|
|
|
testResponseBody(t, resp, &actual)
|
|
|
|
expected["request_id"] = actual["request_id"]
|
|
|
|
if !reflect.DeepEqual(actual, expected) {
|
|
|
|
t.Fatalf("bad:\nExpected: %#v\nActual:%#v", expected, actual)
|
|
|
|
}
|
|
|
|
}
|