From b9fde1dd6f84c15ec8f86da7d5e4d7b7fb1c4cc6 Mon Sep 17 00:00:00 2001 From: swayne275 Date: Thu, 7 Oct 2021 11:25:16 -0600 Subject: [PATCH] oss port (#12755) --- sdk/helper/pathmanager/pathmanager_test.go | 37 ++++++++++++++++++++++ vault/core.go | 4 +++ 2 files changed, 41 insertions(+) diff --git a/sdk/helper/pathmanager/pathmanager_test.go b/sdk/helper/pathmanager/pathmanager_test.go index 0021b1d1e..6924a7cbd 100644 --- a/sdk/helper/pathmanager/pathmanager_test.go +++ b/sdk/helper/pathmanager/pathmanager_test.go @@ -141,3 +141,40 @@ func TestPathManager_HasExactPath(t *testing.T) { t.Fatalf("removing all paths did not clear manager: paths %v", m.Paths()) } } + +func TestPathManager_HasPath(t *testing.T) { + m := New() + + m.AddPaths([]string{"a/b/c/"}) + if m.HasPath("a/") { + t.Fatal("should not have path 'a/'") + } + if m.HasPath("a/b/") { + t.Fatal("should not have path 'a/b/'") + } + if !m.HasPath("a/b/c/") { + t.Fatal("should have path 'a/b/c'") + } + + m.AddPaths([]string{"a/"}) + if !m.HasPath("a/") { + t.Fatal("should have path 'a/'") + } + if !m.HasPath("a/b/") { + t.Fatal("should have path 'a/b/'") + } + if !m.HasPath("a/b/c/") { + t.Fatal("should have path 'a/b/c'") + } + + m.RemovePaths([]string{"a/"}) + if m.HasPath("a/") { + t.Fatal("should not have path 'a/'") + } + if m.HasPath("a/b/") { + t.Fatal("should not have path 'a/b/'") + } + if !m.HasPath("a/b/c/") { + t.Fatal("should have path 'a/b/c'") + } +} diff --git a/vault/core.go b/vault/core.go index 7b20447f0..16f735e3f 100644 --- a/vault/core.go +++ b/vault/core.go @@ -103,6 +103,7 @@ var ( enterprisePreSeal = enterprisePreSealImpl enterpriseSetupFilteredPaths = enterpriseSetupFilteredPathsImpl enterpriseSetupQuotas = enterpriseSetupQuotasImpl + enterpriseSetupAPILock = setupAPILockImpl startReplication = startReplicationImpl stopReplication = stopReplicationImpl LastWAL = lastWALImpl @@ -1967,6 +1968,7 @@ func (s standardUnsealStrategy) unseal(ctx context.Context, logger log.Logger, c if err := c.setupMounts(ctx); err != nil { return err } + enterpriseSetupAPILock(c) if err := c.setupPolicyStore(ctx); err != nil { return err } @@ -2209,6 +2211,8 @@ func stopReplicationImpl(c *Core) error { return nil } +func setupAPILockImpl(c *Core) {} + func (c *Core) ReplicationState() consts.ReplicationState { return consts.ReplicationState(atomic.LoadUint32(c.replicationState)) }