This commit is contained in:
swayne275 2021-10-07 11:25:16 -06:00 committed by GitHub
parent 55e195f161
commit b9fde1dd6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 0 deletions

View File

@ -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'")
}
}

View File

@ -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))
}