mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 11:38:02 +00:00
reverting the tests to not use metrics when unnecessary (#10350)
This commit is contained in:
@@ -15,7 +15,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestAuth_ReadOnlyViewDuringMount(t *testing.T) {
|
func TestAuth_ReadOnlyViewDuringMount(t *testing.T) {
|
||||||
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, _, _ := TestCoreUnsealed(t)
|
||||||
c.credentialBackends["noop"] = func(ctx context.Context, config *logical.BackendConfig) (logical.Backend, error) {
|
c.credentialBackends["noop"] = func(ctx context.Context, config *logical.BackendConfig) (logical.Backend, error) {
|
||||||
err := config.StorageView.Put(ctx, &logical.StorageEntry{
|
err := config.StorageView.Put(ctx, &logical.StorageEntry{
|
||||||
Key: "bar",
|
Key: "bar",
|
||||||
@@ -108,7 +108,7 @@ func TestAuthMountMetrics(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCore_DefaultAuthTable(t *testing.T) {
|
func TestCore_DefaultAuthTable(t *testing.T) {
|
||||||
c, keys, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, keys, _ := TestCoreUnsealed(t)
|
||||||
verifyDefaultAuthTable(t, c.auth)
|
verifyDefaultAuthTable(t, c.auth)
|
||||||
|
|
||||||
// Start a second core with same physical
|
// Start a second core with same physical
|
||||||
@@ -141,7 +141,7 @@ func TestCore_DefaultAuthTable(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCore_EnableCredential(t *testing.T) {
|
func TestCore_EnableCredential(t *testing.T) {
|
||||||
c, keys, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, keys, _ := TestCoreUnsealed(t)
|
||||||
c.credentialBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
c.credentialBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
||||||
return &NoopBackend{
|
return &NoopBackend{
|
||||||
BackendType: logical.TypeCredential,
|
BackendType: logical.TypeCredential,
|
||||||
@@ -200,7 +200,7 @@ func TestCore_EnableCredential(t *testing.T) {
|
|||||||
// entries, and that upon reading the entries from both are recombined
|
// entries, and that upon reading the entries from both are recombined
|
||||||
// correctly
|
// correctly
|
||||||
func TestCore_EnableCredential_Local(t *testing.T) {
|
func TestCore_EnableCredential_Local(t *testing.T) {
|
||||||
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, _, _ := TestCoreUnsealed(t)
|
||||||
c.credentialBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
c.credentialBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
||||||
return &NoopBackend{
|
return &NoopBackend{
|
||||||
BackendType: logical.TypeCredential,
|
BackendType: logical.TypeCredential,
|
||||||
@@ -289,7 +289,7 @@ func TestCore_EnableCredential_Local(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCore_EnableCredential_twice_409(t *testing.T) {
|
func TestCore_EnableCredential_twice_409(t *testing.T) {
|
||||||
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, _, _ := TestCoreUnsealed(t)
|
||||||
c.credentialBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
c.credentialBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
||||||
return &NoopBackend{
|
return &NoopBackend{
|
||||||
BackendType: logical.TypeCredential,
|
BackendType: logical.TypeCredential,
|
||||||
@@ -319,7 +319,7 @@ func TestCore_EnableCredential_twice_409(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCore_EnableCredential_Token(t *testing.T) {
|
func TestCore_EnableCredential_Token(t *testing.T) {
|
||||||
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, _, _ := TestCoreUnsealed(t)
|
||||||
me := &MountEntry{
|
me := &MountEntry{
|
||||||
Table: credentialTableType,
|
Table: credentialTableType,
|
||||||
Path: "foo",
|
Path: "foo",
|
||||||
@@ -332,7 +332,7 @@ func TestCore_EnableCredential_Token(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCore_DisableCredential(t *testing.T) {
|
func TestCore_DisableCredential(t *testing.T) {
|
||||||
c, keys, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, keys, _ := TestCoreUnsealed(t)
|
||||||
c.credentialBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
c.credentialBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
||||||
return &NoopBackend{
|
return &NoopBackend{
|
||||||
BackendType: logical.TypeCredential,
|
BackendType: logical.TypeCredential,
|
||||||
@@ -393,7 +393,7 @@ func TestCore_DisableCredential(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCore_DisableCredential_Protected(t *testing.T) {
|
func TestCore_DisableCredential_Protected(t *testing.T) {
|
||||||
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, _, _ := TestCoreUnsealed(t)
|
||||||
err := c.disableCredential(namespace.RootContext(nil), "token")
|
err := c.disableCredential(namespace.RootContext(nil), "token")
|
||||||
if err.Error() != "token credential backend cannot be disabled" {
|
if err.Error() != "token credential backend cannot be disabled" {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
@@ -405,7 +405,7 @@ func TestCore_DisableCredential_Cleanup(t *testing.T) {
|
|||||||
Login: []string{"login"},
|
Login: []string{"login"},
|
||||||
BackendType: logical.TypeCredential,
|
BackendType: logical.TypeCredential,
|
||||||
}
|
}
|
||||||
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, _, _ := TestCoreUnsealed(t)
|
||||||
c.credentialBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
c.credentialBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
||||||
return noop, nil
|
return noop, nil
|
||||||
}
|
}
|
||||||
@@ -476,7 +476,7 @@ func TestCore_DisableCredential_Cleanup(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDefaultAuthTable(t *testing.T) {
|
func TestDefaultAuthTable(t *testing.T) {
|
||||||
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, _, _ := TestCoreUnsealed(t)
|
||||||
table := c.defaultAuthTable()
|
table := c.defaultAuthTable()
|
||||||
verifyDefaultAuthTable(t, table)
|
verifyDefaultAuthTable(t, table)
|
||||||
}
|
}
|
||||||
@@ -514,7 +514,7 @@ func TestCore_CredentialInitialize(t *testing.T) {
|
|||||||
BackendType: logical.TypeCredential,
|
BackendType: logical.TypeCredential,
|
||||||
}, false}
|
}, false}
|
||||||
|
|
||||||
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, _, _ := TestCoreUnsealed(t)
|
||||||
c.credentialBackends["initable"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
c.credentialBackends["initable"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
||||||
return backend, nil
|
return backend, nil
|
||||||
}
|
}
|
||||||
@@ -539,7 +539,7 @@ func TestCore_CredentialInitialize(t *testing.T) {
|
|||||||
BackendType: logical.TypeCredential,
|
BackendType: logical.TypeCredential,
|
||||||
}, false}
|
}, false}
|
||||||
|
|
||||||
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, _, _ := TestCoreUnsealed(t)
|
||||||
c.credentialBackends["initable"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
c.credentialBackends["initable"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
||||||
return backend, nil
|
return backend, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestMount_ReadOnlyViewDuringMount(t *testing.T) {
|
func TestMount_ReadOnlyViewDuringMount(t *testing.T) {
|
||||||
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, _, _ := TestCoreUnsealed(t)
|
||||||
c.logicalBackends["noop"] = func(ctx context.Context, config *logical.BackendConfig) (logical.Backend, error) {
|
c.logicalBackends["noop"] = func(ctx context.Context, config *logical.BackendConfig) (logical.Backend, error) {
|
||||||
err := config.StorageView.Put(ctx, &logical.StorageEntry{
|
err := config.StorageView.Put(ctx, &logical.StorageEntry{
|
||||||
Key: "bar",
|
Key: "bar",
|
||||||
@@ -110,7 +110,7 @@ func TestLogicalMountMetrics(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCore_DefaultMountTable(t *testing.T) {
|
func TestCore_DefaultMountTable(t *testing.T) {
|
||||||
c, keys, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, keys, _ := TestCoreUnsealed(t)
|
||||||
verifyDefaultTable(t, c.mounts, 4)
|
verifyDefaultTable(t, c.mounts, 4)
|
||||||
|
|
||||||
// Start a second core with same physical
|
// Start a second core with same physical
|
||||||
@@ -142,7 +142,7 @@ func TestCore_DefaultMountTable(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCore_Mount(t *testing.T) {
|
func TestCore_Mount(t *testing.T) {
|
||||||
c, keys, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, keys, _ := TestCoreUnsealed(t)
|
||||||
me := &MountEntry{
|
me := &MountEntry{
|
||||||
Table: mountTableType,
|
Table: mountTableType,
|
||||||
Path: "foo",
|
Path: "foo",
|
||||||
@@ -190,7 +190,7 @@ func TestCore_Mount(t *testing.T) {
|
|||||||
// entries, and that upon reading the entries from both are recombined
|
// entries, and that upon reading the entries from both are recombined
|
||||||
// correctly
|
// correctly
|
||||||
func TestCore_Mount_Local(t *testing.T) {
|
func TestCore_Mount_Local(t *testing.T) {
|
||||||
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, _, _ := TestCoreUnsealed(t)
|
||||||
|
|
||||||
c.mounts = &MountTable{
|
c.mounts = &MountTable{
|
||||||
Type: mountTableType,
|
Type: mountTableType,
|
||||||
@@ -289,7 +289,7 @@ func TestCore_Mount_Local(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCore_Unmount(t *testing.T) {
|
func TestCore_Unmount(t *testing.T) {
|
||||||
c, keys, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, keys, _ := TestCoreUnsealed(t)
|
||||||
err := c.unmount(namespace.RootContext(nil), "secret")
|
err := c.unmount(namespace.RootContext(nil), "secret")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
@@ -335,7 +335,7 @@ func TestCore_Unmount_Cleanup(t *testing.T) {
|
|||||||
|
|
||||||
func testCore_Unmount_Cleanup(t *testing.T, causeFailure bool) {
|
func testCore_Unmount_Cleanup(t *testing.T, causeFailure bool) {
|
||||||
noop := &NoopBackend{}
|
noop := &NoopBackend{}
|
||||||
c, _, root, _ := TestCoreUnsealedWithMetrics(t)
|
c, _, root := TestCoreUnsealed(t)
|
||||||
c.logicalBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
c.logicalBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
||||||
return noop, nil
|
return noop, nil
|
||||||
}
|
}
|
||||||
@@ -508,15 +508,15 @@ func TestCore_RemountConcurrent(t *testing.T) {
|
|||||||
|
|
||||||
c2MountMap := map[string]interface{}{}
|
c2MountMap := map[string]interface{}{}
|
||||||
for _, v := range c2.mounts.Entries {
|
for _, v := range c2.mounts.Entries {
|
||||||
|
|
||||||
if _, ok := c2MountMap[v.Path]; ok {
|
if _, ok := c2MountMap[v.Path]; ok {
|
||||||
t.Fatalf("duplicated mount path found at %s", v.Path)
|
t.Fatalf("duplicated mount path found at %s", v.Path)
|
||||||
}
|
}
|
||||||
c2MountMap[v.Path] = v
|
c2MountMap[v.Path] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func TestCore_Remount(t *testing.T) {
|
func TestCore_Remount(t *testing.T) {
|
||||||
c, keys, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, keys, _ := TestCoreUnsealed(t)
|
||||||
err := c.remount(namespace.RootContext(nil), "secret", "foo", true)
|
err := c.remount(namespace.RootContext(nil), "secret", "foo", true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
@@ -568,7 +568,7 @@ func TestCore_Remount(t *testing.T) {
|
|||||||
|
|
||||||
func TestCore_Remount_Cleanup(t *testing.T) {
|
func TestCore_Remount_Cleanup(t *testing.T) {
|
||||||
noop := &NoopBackend{}
|
noop := &NoopBackend{}
|
||||||
c, _, root, _ := TestCoreUnsealedWithMetrics(t)
|
c, _, root := TestCoreUnsealed(t)
|
||||||
c.logicalBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
c.logicalBackends["noop"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
||||||
return noop, nil
|
return noop, nil
|
||||||
}
|
}
|
||||||
@@ -652,7 +652,7 @@ func TestCore_Remount_Cleanup(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCore_Remount_Protected(t *testing.T) {
|
func TestCore_Remount_Protected(t *testing.T) {
|
||||||
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, _, _ := TestCoreUnsealed(t)
|
||||||
err := c.remount(namespace.RootContext(nil), "sys", "foo", true)
|
err := c.remount(namespace.RootContext(nil), "sys", "foo", true)
|
||||||
if err.Error() != `cannot remount "sys/"` {
|
if err.Error() != `cannot remount "sys/"` {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
@@ -660,13 +660,13 @@ func TestCore_Remount_Protected(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDefaultMountTable(t *testing.T) {
|
func TestDefaultMountTable(t *testing.T) {
|
||||||
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, _, _ := TestCoreUnsealed(t)
|
||||||
table := c.defaultMountTable()
|
table := c.defaultMountTable()
|
||||||
verifyDefaultTable(t, table, 3)
|
verifyDefaultTable(t, table, 3)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCore_MountTable_UpgradeToTyped(t *testing.T) {
|
func TestCore_MountTable_UpgradeToTyped(t *testing.T) {
|
||||||
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, _, _ := TestCoreUnsealed(t)
|
||||||
|
|
||||||
c.auditBackends["noop"] = func(ctx context.Context, config *audit.BackendConfig) (audit.Backend, error) {
|
c.auditBackends["noop"] = func(ctx context.Context, config *audit.BackendConfig) (audit.Backend, error) {
|
||||||
return &NoopAudit{
|
return &NoopAudit{
|
||||||
@@ -868,7 +868,7 @@ func verifyDefaultTable(t *testing.T, table *MountTable, expected int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSingletonMountTableFunc(t *testing.T) {
|
func TestSingletonMountTableFunc(t *testing.T) {
|
||||||
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, _, _ := TestCoreUnsealed(t)
|
||||||
|
|
||||||
mounts, auth := c.singletonMountTables()
|
mounts, auth := c.singletonMountTables()
|
||||||
|
|
||||||
@@ -901,7 +901,7 @@ func TestCore_MountInitialize(t *testing.T) {
|
|||||||
BackendType: logical.TypeLogical,
|
BackendType: logical.TypeLogical,
|
||||||
}, false}
|
}, false}
|
||||||
|
|
||||||
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, _, _ := TestCoreUnsealed(t)
|
||||||
c.logicalBackends["initable"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
c.logicalBackends["initable"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
||||||
return backend, nil
|
return backend, nil
|
||||||
}
|
}
|
||||||
@@ -926,7 +926,7 @@ func TestCore_MountInitialize(t *testing.T) {
|
|||||||
BackendType: logical.TypeLogical,
|
BackendType: logical.TypeLogical,
|
||||||
}, false}
|
}, false}
|
||||||
|
|
||||||
c, _, _, _ := TestCoreUnsealedWithMetrics(t)
|
c, _, _ := TestCoreUnsealed(t)
|
||||||
c.logicalBackends["initable"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
c.logicalBackends["initable"] = func(context.Context, *logical.BackendConfig) (logical.Backend, error) {
|
||||||
return backend, nil
|
return backend, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user