Skip to content

Commit

Permalink
Refactor creation of mounts for enterprise
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
  • Loading branch information
cipherboy committed May 4, 2023
1 parent 7c7b4bf commit 917ee5b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions builtin/logical/pki/path_acme_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ func setupAcmeBackendOnClusterAtPath(t *testing.T, cluster *vault.TestCluster, c
pathConfig := client.Address() + "/v1/" + mount

namespace := ""
mountName := mount
if mount != "pki" {
if strings.Contains(mount, "/") && constants.IsEnterprise {
ns_pieces := strings.Split(mount, "/")
Expand All @@ -483,17 +484,18 @@ func setupAcmeBackendOnClusterAtPath(t *testing.T, cluster *vault.TestCluster, c
ns_name := ns_pieces[c-2]
if len(ns_pieces) > 2 {
// Parent's namespaces
parent := strings.Join(ns_pieces[0:c-3], "/")
parent := strings.Join(ns_pieces[0:c-2], "/")
_, err := client.WithNamespace(parent).Logical().Write("/sys/namespaces/"+ns_name, nil)
require.NoError(t, err, "failed to create nested namespaces "+parent+" -> "+ns_name)
} else {
_, err := client.Logical().Write("/sys/namespaces/"+ns_name, nil)
require.NoError(t, err, "failed to create nested namespace "+ns_name)
}
namespace = strings.Join(ns_pieces[0:c-2], "/")
namespace = strings.Join(ns_pieces[0:c-1], "/")
mountName = ns_pieces[c-1]
}

err := client.WithNamespace(namespace).Sys().Mount(mount, &api.MountInput{
err := client.WithNamespace(namespace).Sys().Mount(mountName, &api.MountInput{
Type: "pki",
Config: api.MountConfigInput{
DefaultLeaseTTL: "16h",
Expand All @@ -515,7 +517,7 @@ func setupAcmeBackendOnClusterAtPath(t *testing.T, cluster *vault.TestCluster, c
require.NoError(t, err)

// Allow certain headers to pass through for ACME support
_, err = client.WithNamespace(namespace).Logical().WriteWithContext(context.Background(), "sys/mounts/"+mount+"/tune", map[string]interface{}{
_, err = client.WithNamespace(namespace).Logical().WriteWithContext(context.Background(), "sys/mounts/"+mountName+"/tune", map[string]interface{}{
"allowed_response_headers": []string{"Last-Modified", "Replay-Nonce", "Link", "Location"},
"max_lease_ttl": "920000h",
})
Expand Down

0 comments on commit 917ee5b

Please sign in to comment.