diff --git a/builtin/credential/aws/backend_e2e_test.go b/builtin/credential/aws/backend_e2e_test.go index e8939b9d67..3f95c8beed 100644 --- a/builtin/credential/aws/backend_e2e_test.go +++ b/builtin/credential/aws/backend_e2e_test.go @@ -8,10 +8,8 @@ import ( "testing" "time" - hclog "github.com/hashicorp/go-hclog" "github.com/hashicorp/vault/api" vaulthttp "github.com/hashicorp/vault/http" - "github.com/hashicorp/vault/sdk/helper/logging" "github.com/hashicorp/vault/sdk/logical" "github.com/hashicorp/vault/vault" ) @@ -104,9 +102,7 @@ func TestBackend_E2E_Initialize(t *testing.T) { func setupAwsTestCluster(t *testing.T, _ context.Context) *vault.TestCluster { // create a cluster with the aws auth backend built-in - logger := logging.NewVaultLogger(hclog.Trace) coreConfig := &vault.CoreConfig{ - Logger: logger, CredentialBackends: map[string]logical.Factory{ "aws": Factory, }, diff --git a/builtin/credential/cert/backend_test.go b/builtin/credential/cert/backend_test.go index aa2dd71ad1..e88b8a36be 100644 --- a/builtin/credential/cert/backend_test.go +++ b/builtin/credential/cert/backend_test.go @@ -27,25 +27,21 @@ import ( "testing" "time" - "github.com/hashicorp/go-sockaddr" - "github.com/go-test/deep" - "golang.org/x/net/http2" - cleanhttp "github.com/hashicorp/go-cleanhttp" - log "github.com/hashicorp/go-hclog" - "github.com/hashicorp/vault/api" - vaulthttp "github.com/hashicorp/vault/http" - rootcerts "github.com/hashicorp/go-rootcerts" + "github.com/hashicorp/go-sockaddr" + "github.com/hashicorp/vault/api" "github.com/hashicorp/vault/builtin/logical/pki" logicaltest "github.com/hashicorp/vault/helper/testhelpers/logical" + vaulthttp "github.com/hashicorp/vault/http" "github.com/hashicorp/vault/sdk/framework" "github.com/hashicorp/vault/sdk/helper/certutil" "github.com/hashicorp/vault/sdk/helper/tokenutil" "github.com/hashicorp/vault/sdk/logical" "github.com/hashicorp/vault/vault" "github.com/mitchellh/mapstructure" + "golang.org/x/net/http2" ) const ( @@ -253,9 +249,6 @@ func connectionState(serverCAPath, serverCertPath, serverKeyPath, clientCertPath func TestBackend_PermittedDNSDomainsIntermediateCA(t *testing.T) { // Enable PKI secret engine and Cert auth method coreConfig := &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: log.NewNullLogger(), CredentialBackends: map[string]logical.Factory{ "cert": Factory, }, @@ -479,9 +472,6 @@ func TestBackend_PermittedDNSDomainsIntermediateCA(t *testing.T) { func TestBackend_MetadataBasedACLPolicy(t *testing.T) { // Start cluster with cert auth method enabled coreConfig := &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: log.NewNullLogger(), CredentialBackends: map[string]logical.Factory{ "cert": Factory, }, diff --git a/command/agent/alicloud_end_to_end_test.go b/command/agent/alicloud_end_to_end_test.go index 0f5cdfbe4e..5202686620 100644 --- a/command/agent/alicloud_end_to_end_test.go +++ b/command/agent/alicloud_end_to_end_test.go @@ -15,7 +15,6 @@ import ( "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials" "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials/providers" "github.com/aliyun/alibaba-cloud-sdk-go/services/sts" - hclog "github.com/hashicorp/go-hclog" uuid "github.com/hashicorp/go-uuid" vaultalicloud "github.com/hashicorp/vault-plugin-auth-alicloud" "github.com/hashicorp/vault/api" @@ -25,7 +24,6 @@ import ( "github.com/hashicorp/vault/command/agentproxyshared/sink/file" "github.com/hashicorp/vault/helper/testhelpers" vaulthttp "github.com/hashicorp/vault/http" - "github.com/hashicorp/vault/sdk/helper/logging" "github.com/hashicorp/vault/sdk/logical" "github.com/hashicorp/vault/vault" ) @@ -49,9 +47,7 @@ func TestAliCloudEndToEnd(t *testing.T) { } testhelpers.SkipUnlessEnvVarsSet(t, credNames) - logger := logging.NewVaultLogger(hclog.Trace) coreConfig := &vault.CoreConfig{ - Logger: logger, CredentialBackends: map[string]logical.Factory{ "alicloud": vaultalicloud.Factory, }, @@ -91,7 +87,7 @@ func TestAliCloudEndToEnd(t *testing.T) { }() am, err := agentalicloud.NewAliCloudAuthMethod(&auth.AuthConfig{ - Logger: logger.Named("auth.alicloud"), + Logger: cluster.Logger.Named("auth.alicloud"), MountPath: "auth/alicloud", Config: map[string]interface{}{ "role": "test", @@ -104,7 +100,7 @@ func TestAliCloudEndToEnd(t *testing.T) { } ahConfig := &auth.AuthHandlerConfig{ - Logger: logger.Named("auth.handler"), + Logger: cluster.Logger.Named("auth.handler"), Client: client, } @@ -133,7 +129,7 @@ func TestAliCloudEndToEnd(t *testing.T) { t.Logf("output: %s", tokenSinkFileName) config := &sink.SinkConfig{ - Logger: logger.Named("sink.file"), + Logger: cluster.Logger.Named("sink.file"), Config: map[string]interface{}{ "path": tokenSinkFileName, }, @@ -147,7 +143,7 @@ func TestAliCloudEndToEnd(t *testing.T) { config.Sink = fs ss := sink.NewSinkServer(&sink.SinkServerConfig{ - Logger: logger.Named("sink.server"), + Logger: cluster.Logger.Named("sink.server"), Client: client, }) go func() { diff --git a/command/agent/approle_end_to_end_test.go b/command/agent/approle_end_to_end_test.go index 515a13ec52..7678de80ca 100644 --- a/command/agent/approle_end_to_end_test.go +++ b/command/agent/approle_end_to_end_test.go @@ -72,7 +72,6 @@ func testAppRoleEndToEnd(t *testing.T, removeSecretIDFile bool, bindSecretID boo coreConfig := &vault.CoreConfig{ DisableMlock: true, DisableCache: true, - Logger: log.NewNullLogger(), CredentialBackends: map[string]logical.Factory{ "approle": credAppRole.Factory, }, @@ -411,9 +410,6 @@ func TestAppRoleLongRoleName(t *testing.T) { approleName := strings.Repeat("a", 5000) coreConfig := &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: log.NewNullLogger(), CredentialBackends: map[string]logical.Factory{ "approle": credAppRole.Factory, }, @@ -477,9 +473,6 @@ func testAppRoleWithWrapping(t *testing.T, bindSecretID bool, secretIDLess bool, var err error logger := logging.NewVaultLogger(log.Trace) coreConfig := &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: log.NewNullLogger(), CredentialBackends: map[string]logical.Factory{ "approle": credAppRole.Factory, }, diff --git a/command/agent/auto_auth_preload_token_end_to_end_test.go b/command/agent/auto_auth_preload_token_end_to_end_test.go index 004e817dac..8c72928da1 100644 --- a/command/agent/auto_auth_preload_token_end_to_end_test.go +++ b/command/agent/auto_auth_preload_token_end_to_end_test.go @@ -26,7 +26,6 @@ import ( func TestTokenPreload_UsingAutoAuth(t *testing.T) { logger := logging.NewVaultLogger(hclog.Trace) coreConfig := &vault.CoreConfig{ - Logger: logger, LogicalBackends: map[string]logical.Factory{ "kv": vault.LeasedPassthroughBackendFactory, }, diff --git a/command/agent/aws_end_to_end_test.go b/command/agent/aws_end_to_end_test.go index 08644bdc1d..137b5c4721 100644 --- a/command/agent/aws_end_to_end_test.go +++ b/command/agent/aws_end_to_end_test.go @@ -61,7 +61,6 @@ func TestAWSEndToEnd(t *testing.T) { logger := logging.NewVaultLogger(hclog.Trace) coreConfig := &vault.CoreConfig{ - Logger: logger, CredentialBackends: map[string]logical.Factory{ "aws": vaultaws.Factory, }, diff --git a/command/agent/cache_end_to_end_test.go b/command/agent/cache_end_to_end_test.go index a2a359abc9..3bc403efe8 100644 --- a/command/agent/cache_end_to_end_test.go +++ b/command/agent/cache_end_to_end_test.go @@ -45,9 +45,6 @@ func TestCache_UsingAutoAuthToken(t *testing.T) { var err error logger := logging.NewVaultLogger(log.Trace) coreConfig := &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: log.NewNullLogger(), LogicalBackends: map[string]logical.Factory{ "kv": vault.LeasedPassthroughBackendFactory, }, diff --git a/command/agent/cert_end_to_end_test.go b/command/agent/cert_end_to_end_test.go index 12ea933ed6..4760417f7c 100644 --- a/command/agent/cert_end_to_end_test.go +++ b/command/agent/cert_end_to_end_test.go @@ -66,7 +66,6 @@ func TestCertEndToEnd(t *testing.T) { func testCertEndToEnd(t *testing.T, withCertRoleName, ahWrapping bool) { logger := logging.NewVaultLogger(hclog.Trace) coreConfig := &vault.CoreConfig{ - Logger: logger, CredentialBackends: map[string]logical.Factory{ "cert": vaultcert.Factory, }, @@ -306,7 +305,6 @@ func testCertEndToEnd(t *testing.T, withCertRoleName, ahWrapping bool) { func TestCertEndToEnd_CertsInConfig(t *testing.T) { logger := logging.NewVaultLogger(hclog.Trace) coreConfig := &vault.CoreConfig{ - Logger: logger, CredentialBackends: map[string]logical.Factory{ "cert": vaultcert.Factory, }, diff --git a/command/agent/cf_end_to_end_test.go b/command/agent/cf_end_to_end_test.go index e143223af1..f82fee1c4b 100644 --- a/command/agent/cf_end_to_end_test.go +++ b/command/agent/cf_end_to_end_test.go @@ -29,9 +29,6 @@ func TestCFEndToEnd(t *testing.T) { logger := logging.NewVaultLogger(hclog.Trace) coreConfig := &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: hclog.NewNullLogger(), CredentialBackends: map[string]logical.Factory{ "cf": credCF.Factory, }, diff --git a/command/agent/jwt_end_to_end_test.go b/command/agent/jwt_end_to_end_test.go index 4739a65c31..b4a62ad288 100644 --- a/command/agent/jwt_end_to_end_test.go +++ b/command/agent/jwt_end_to_end_test.go @@ -55,7 +55,6 @@ func TestJWTEndToEnd(t *testing.T) { func testJWTEndToEnd(t *testing.T, ahWrapping, useSymlink, removeJWTAfterReading bool) { logger := logging.NewVaultLogger(hclog.Trace) coreConfig := &vault.CoreConfig{ - Logger: logger, CredentialBackends: map[string]logical.Factory{ "jwt": vaultjwt.Factory, }, diff --git a/command/agent/oci_end_to_end_test.go b/command/agent/oci_end_to_end_test.go index 2349f09abe..3f2176302f 100644 --- a/command/agent/oci_end_to_end_test.go +++ b/command/agent/oci_end_to_end_test.go @@ -59,7 +59,6 @@ func TestOCIEndToEnd(t *testing.T) { logger := logging.NewVaultLogger(hclog.Trace) coreConfig := &vault.CoreConfig{ - Logger: logger, CredentialBackends: map[string]logical.Factory{ "oci": vaultoci.Factory, }, diff --git a/command/agent/token_file_end_to_end_test.go b/command/agent/token_file_end_to_end_test.go index dc7115cb18..f224587756 100644 --- a/command/agent/token_file_end_to_end_test.go +++ b/command/agent/token_file_end_to_end_test.go @@ -21,15 +21,8 @@ import ( ) func TestTokenFileEndToEnd(t *testing.T) { - var err error logger := logging.NewVaultLogger(log.Trace) - coreConfig := &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: log.NewNullLogger(), - } - - cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{ + cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{ HandlerFunc: vaulthttp.Handler, }) diff --git a/command/agent_test.go b/command/agent_test.go index 406bdf6ac0..51281de5b8 100644 --- a/command/agent_test.go +++ b/command/agent_test.go @@ -107,7 +107,6 @@ func TestAgent_ExitAfterAuth(t *testing.T) { func testAgentExitAfterAuth(t *testing.T, viaFlag bool) { logger := logging.NewVaultLogger(hclog.Trace) coreConfig := &vault.CoreConfig{ - Logger: logger, CredentialBackends: map[string]logical.Factory{ "jwt": vaultjwt.Factory, }, @@ -311,7 +310,6 @@ func TestAgent_RequireRequestHeader(t *testing.T) { logger := logging.NewVaultLogger(hclog.Trace) cluster := vault.NewTestCluster(t, &vault.CoreConfig{ - Logger: logger, CredentialBackends: map[string]logical.Factory{ "approle": credAppRole.Factory, }, @@ -528,7 +526,6 @@ func TestAgent_Template_UserAgent(t *testing.T) { var h userAgentHandler cluster := vault.NewTestCluster(t, &vault.CoreConfig{ - Logger: logger, CredentialBackends: map[string]logical.Factory{ "approle": credAppRole.Factory, }, @@ -776,7 +773,6 @@ func TestAgent_Template_Basic(t *testing.T) { logger := logging.NewVaultLogger(hclog.Trace) cluster := vault.NewTestCluster(t, &vault.CoreConfig{ - Logger: logger, CredentialBackends: map[string]logical.Factory{ "approle": credAppRole.Factory, }, @@ -1079,7 +1075,6 @@ func TestAgent_Template_ExitCounter(t *testing.T) { logger := logging.NewVaultLogger(hclog.Trace) cluster := vault.NewTestCluster(t, &vault.CoreConfig{ - Logger: logger, CredentialBackends: map[string]logical.Factory{ "approle": credAppRole.Factory, }, @@ -1436,7 +1431,6 @@ func TestAgent_Template_Retry(t *testing.T) { var h handler cluster := vault.NewTestCluster(t, &vault.CoreConfig{ - Logger: logger, CredentialBackends: map[string]logical.Factory{ "approle": credAppRole.Factory, }, @@ -1724,7 +1718,6 @@ func TestAgent_AutoAuth_UserAgent(t *testing.T) { logger := logging.NewVaultLogger(hclog.Trace) var h userAgentHandler cluster := vault.NewTestCluster(t, &vault.CoreConfig{ - Logger: logger, CredentialBackends: map[string]logical.Factory{ "approle": credAppRole.Factory, }, @@ -2168,7 +2161,6 @@ func TestAgent_ApiProxy_Retry(t *testing.T) { var h handler cluster := vault.NewTestCluster(t, &vault.CoreConfig{ - Logger: logger, CredentialBackends: map[string]logical.Factory{ "approle": credAppRole.Factory, }, @@ -2320,7 +2312,6 @@ func TestAgent_TemplateConfig_ExitOnRetryFailure(t *testing.T) { logger := logging.NewVaultLogger(hclog.Trace) cluster := vault.NewTestCluster(t, &vault.CoreConfig{ - // Logger: logger, CredentialBackends: map[string]logical.Factory{ "approle": credAppRole.Factory, }, @@ -2623,11 +2614,7 @@ func TestAgent_Metrics(t *testing.T) { //---------------------------------------------------- // Start a vault server - logger := logging.NewVaultLogger(hclog.Trace) - cluster := vault.NewTestCluster(t, - &vault.CoreConfig{ - Logger: logger, - }, + cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{ HandlerFunc: vaulthttp.Handler, }) @@ -2650,7 +2637,7 @@ listener "tcp" { defer os.Remove(configPath) // Start the agent - ui, cmd := testAgentCommand(t, logger) + ui, cmd := testAgentCommand(t, logging.NewVaultLogger(hclog.Trace)) cmd.client = serverClient cmd.startedCh = make(chan struct{}) diff --git a/command/agentproxyshared/auth/auth_test.go b/command/agentproxyshared/auth/auth_test.go index 5729435020..34194f76c7 100644 --- a/command/agentproxyshared/auth/auth_test.go +++ b/command/agentproxyshared/auth/auth_test.go @@ -58,9 +58,7 @@ func (u *userpassTestMethod) Shutdown() { } func TestAuthHandler(t *testing.T) { - logger := logging.NewVaultLogger(hclog.Trace) coreConfig := &vault.CoreConfig{ - Logger: logger, CredentialBackends: map[string]logical.Factory{ "userpass": userpass.Factory, }, @@ -77,7 +75,7 @@ func TestAuthHandler(t *testing.T) { ctx, cancelFunc := context.WithCancel(context.Background()) ah := NewAuthHandler(&AuthHandlerConfig{ - Logger: logger.Named("auth.handler"), + Logger: logging.NewVaultLogger(hclog.Trace).Named("auth.handler"), Client: client, }) diff --git a/command/agentproxyshared/cache/api_proxy_test.go b/command/agentproxyshared/cache/api_proxy_test.go index 6671b17fda..605adff1a6 100644 --- a/command/agentproxyshared/cache/api_proxy_test.go +++ b/command/agentproxyshared/cache/api_proxy_test.go @@ -12,18 +12,16 @@ import ( "testing" "time" - "github.com/hashicorp/vault/helper/useragent" - - "github.com/hashicorp/vault/builtin/credential/userpass" - vaulthttp "github.com/hashicorp/vault/http" - "github.com/hashicorp/vault/sdk/logical" - "github.com/hashicorp/vault/vault" - "github.com/hashicorp/go-hclog" "github.com/hashicorp/vault/api" + "github.com/hashicorp/vault/builtin/credential/userpass" "github.com/hashicorp/vault/helper/namespace" + "github.com/hashicorp/vault/helper/useragent" + vaulthttp "github.com/hashicorp/vault/http" "github.com/hashicorp/vault/sdk/helper/jsonutil" "github.com/hashicorp/vault/sdk/helper/logging" + "github.com/hashicorp/vault/sdk/logical" + "github.com/hashicorp/vault/vault" ) const policyAdmin = ` @@ -188,15 +186,9 @@ func setupClusterAndAgentCommon(ctx context.Context, t *testing.T, coreConfig *v ctx = context.Background() } - // Handle sane defaults if coreConfig == nil { - coreConfig = &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: logging.NewVaultLogger(hclog.Trace), - } + coreConfig = &vault.CoreConfig{} } - // Always set up the userpass backend since we use that to generate an admin // token for the client that will make proxied requests to through the agent. if coreConfig.CredentialBackends == nil || coreConfig.CredentialBackends["userpass"] == nil { @@ -257,7 +249,7 @@ func setupClusterAndAgentCommon(ctx context.Context, t *testing.T, coreConfig *v t.Fatal(err) } - apiProxyLogger := logging.NewVaultLogger(hclog.Trace).Named("apiproxy") + apiProxyLogger := cluster.Logger.Named("apiproxy") // Create the API proxier apiProxy, err := NewAPIProxy(&APIProxyConfig{ @@ -275,7 +267,7 @@ func setupClusterAndAgentCommon(ctx context.Context, t *testing.T, coreConfig *v var leaseCache *LeaseCache if useCache { - cacheLogger := logging.NewVaultLogger(hclog.Trace).Named("cache") + cacheLogger := cluster.Logger.Named("cache") // Create the lease cache proxier and set its underlying proxier to // the API proxier. diff --git a/command/agentproxyshared/cache/cache_test.go b/command/agentproxyshared/cache/cache_test.go index 4786950bd5..2666cd6397 100644 --- a/command/agentproxyshared/cache/cache_test.go +++ b/command/agentproxyshared/cache/cache_test.go @@ -202,9 +202,6 @@ func TestCache_AutoAuthClientTokenProxyStripping(t *testing.T) { func TestCache_ConcurrentRequests(t *testing.T) { coreConfig := &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: hclog.NewNullLogger(), LogicalBackends: map[string]logical.Factory{ "kv": vault.LeasedPassthroughBackendFactory, }, @@ -247,9 +244,6 @@ func TestCache_ConcurrentRequests(t *testing.T) { func TestCache_TokenRevocations_RevokeOrphan(t *testing.T) { coreConfig := &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: hclog.NewNullLogger(), LogicalBackends: map[string]logical.Factory{ "kv": vault.LeasedPassthroughBackendFactory, }, @@ -348,9 +342,6 @@ func TestCache_TokenRevocations_RevokeOrphan(t *testing.T) { func TestCache_TokenRevocations_LeafLevelToken(t *testing.T) { coreConfig := &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: hclog.NewNullLogger(), LogicalBackends: map[string]logical.Factory{ "kv": vault.LeasedPassthroughBackendFactory, }, @@ -448,9 +439,6 @@ func TestCache_TokenRevocations_LeafLevelToken(t *testing.T) { func TestCache_TokenRevocations_IntermediateLevelToken(t *testing.T) { coreConfig := &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: hclog.NewNullLogger(), LogicalBackends: map[string]logical.Factory{ "kv": vault.LeasedPassthroughBackendFactory, }, @@ -546,9 +534,6 @@ func TestCache_TokenRevocations_IntermediateLevelToken(t *testing.T) { func TestCache_TokenRevocations_TopLevelToken(t *testing.T) { coreConfig := &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: hclog.NewNullLogger(), LogicalBackends: map[string]logical.Factory{ "kv": vault.LeasedPassthroughBackendFactory, }, @@ -641,9 +626,6 @@ func TestCache_TokenRevocations_TopLevelToken(t *testing.T) { func TestCache_TokenRevocations_Shutdown(t *testing.T) { coreConfig := &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: hclog.NewNullLogger(), LogicalBackends: map[string]logical.Factory{ "kv": vault.LeasedPassthroughBackendFactory, }, @@ -731,9 +713,6 @@ func TestCache_TokenRevocations_Shutdown(t *testing.T) { func TestCache_TokenRevocations_BaseContextCancellation(t *testing.T) { coreConfig := &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: hclog.NewNullLogger(), LogicalBackends: map[string]logical.Factory{ "kv": vault.LeasedPassthroughBackendFactory, }, @@ -822,9 +801,6 @@ func TestCache_TokenRevocations_BaseContextCancellation(t *testing.T) { func TestCache_NonCacheable(t *testing.T) { coreConfig := &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: hclog.NewNullLogger(), LogicalBackends: map[string]logical.Factory{ "kv": kv.Factory, }, @@ -930,9 +906,6 @@ func TestCache_Caching_AuthResponse(t *testing.T) { func TestCache_Caching_LeaseResponse(t *testing.T) { coreConfig := &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: hclog.NewNullLogger(), LogicalBackends: map[string]logical.Factory{ "kv": vault.LeasedPassthroughBackendFactory, }, @@ -1032,9 +1005,6 @@ func TestCache_Caching_CacheClear(t *testing.T) { func testCachingCacheClearCommon(t *testing.T, clearType string) { coreConfig := &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: hclog.NewNullLogger(), LogicalBackends: map[string]logical.Factory{ "kv": vault.LeasedPassthroughBackendFactory, }, diff --git a/command/approle_concurrency_integ_test.go b/command/approle_concurrency_integ_test.go index 934f8b33fd..4857bd8eeb 100644 --- a/command/approle_concurrency_integ_test.go +++ b/command/approle_concurrency_integ_test.go @@ -8,7 +8,6 @@ import ( "sync" "testing" - log "github.com/hashicorp/go-hclog" "github.com/hashicorp/vault/api" auth "github.com/hashicorp/vault/api/auth/approle" credAppRole "github.com/hashicorp/vault/builtin/credential/approle" @@ -20,9 +19,6 @@ import ( func TestAppRole_Integ_ConcurrentLogins(t *testing.T) { var err error coreConfig := &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: log.NewNullLogger(), CredentialBackends: map[string]logical.Factory{ "approle": credAppRole.Factory, }, diff --git a/command/command_test.go b/command/command_test.go index f1a5269b9f..bd8f4299c9 100644 --- a/command/command_test.go +++ b/command/command_test.go @@ -21,7 +21,6 @@ import ( "github.com/hashicorp/vault/builtin/logical/transit" "github.com/hashicorp/vault/helper/benchhelpers" "github.com/hashicorp/vault/helper/builtinplugins" - "github.com/hashicorp/vault/sdk/helper/logging" "github.com/hashicorp/vault/sdk/logical" "github.com/hashicorp/vault/sdk/physical/inmem" "github.com/hashicorp/vault/vault" @@ -126,9 +125,6 @@ func testVaultServerAllBackends(tb testing.TB) (*api.Client, func()) { tb.Helper() client, _, closer := testVaultServerCoreConfig(tb, &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: defaultVaultLogger, CredentialBackends: credentialBackends, AuditBackends: auditBackends, LogicalBackends: logicalBackends, @@ -156,16 +152,8 @@ func testVaultServerUnseal(tb testing.TB) (*api.Client, []string, func()) { func testVaultServerUnsealWithKVVersionWithSeal(tb testing.TB, kvVersion string, seal vault.Seal) (*api.Client, []string, func()) { tb.Helper() - logger := log.NewInterceptLogger(&log.LoggerOptions{ - Output: log.DefaultOutput, - Level: log.Debug, - JSONFormat: logging.ParseEnvLogFormat() == logging.JSONFormat, - }) return testVaultServerCoreConfigWithOpts(tb, &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: logger, CredentialBackends: defaultVaultCredentialBackends, AuditBackends: defaultVaultAuditBackends, LogicalBackends: defaultVaultLogicalBackends, @@ -185,9 +173,6 @@ func testVaultServerPluginDir(tb testing.TB, pluginDir string) (*api.Client, []s tb.Helper() return testVaultServerCoreConfig(tb, &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: defaultVaultLogger, CredentialBackends: defaultVaultCredentialBackends, AuditBackends: defaultVaultAuditBackends, LogicalBackends: defaultVaultLogicalBackends, @@ -251,8 +236,6 @@ func testVaultServerUninit(tb testing.TB) (*api.Client, func()) { core, err := vault.NewCore(&vault.CoreConfig{ DisableMlock: true, - DisableCache: true, - Logger: defaultVaultLogger, Physical: inm, CredentialBackends: defaultVaultCredentialBackends, AuditBackends: defaultVaultAuditBackends, diff --git a/command/proxy_test.go b/command/proxy_test.go index 01aba59dbc..0127471f53 100644 --- a/command/proxy_test.go +++ b/command/proxy_test.go @@ -65,7 +65,6 @@ func TestProxy_ExitAfterAuth(t *testing.T) { func testProxyExitAfterAuth(t *testing.T, viaFlag bool) { logger := logging.NewVaultLogger(hclog.Trace) coreConfig := &vault.CoreConfig{ - Logger: logger, CredentialBackends: map[string]logical.Factory{ "jwt": vaultjwt.Factory, }, @@ -249,7 +248,6 @@ func TestProxy_AutoAuth_UserAgent(t *testing.T) { logger := logging.NewVaultLogger(hclog.Trace) var h userAgentHandler cluster := vault.NewTestCluster(t, &vault.CoreConfig{ - Logger: logger, CredentialBackends: map[string]logical.Factory{ "approle": credAppRole.Factory, }, @@ -696,7 +694,6 @@ func TestProxy_ApiProxy_Retry(t *testing.T) { var h handler cluster := vault.NewTestCluster(t, &vault.CoreConfig{ - Logger: logger, CredentialBackends: map[string]logical.Factory{ "approle": credAppRole.Factory, }, @@ -844,10 +841,7 @@ vault { func TestProxy_Metrics(t *testing.T) { // Start a vault server logger := logging.NewVaultLogger(hclog.Trace) - cluster := vault.NewTestCluster(t, - &vault.CoreConfig{ - Logger: logger, - }, + cluster := vault.NewTestCluster(t, nil, &vault.TestClusterOptions{ HandlerFunc: vaulthttp.Handler, }) diff --git a/helper/builtinplugins/builtinplugins_test.go b/helper/builtinplugins/builtinplugins_test.go index 92ab12ca23..0198acac5d 100644 --- a/helper/builtinplugins/builtinplugins_test.go +++ b/helper/builtinplugins/builtinplugins_test.go @@ -3,13 +3,11 @@ package builtinplugins import ( "testing" - "github.com/hashicorp/go-hclog" logicalKv "github.com/hashicorp/vault-plugin-secrets-kv" "github.com/hashicorp/vault/api" logicalDb "github.com/hashicorp/vault/builtin/logical/database" vaulthttp "github.com/hashicorp/vault/http" "github.com/hashicorp/vault/sdk/helper/consts" - "github.com/hashicorp/vault/sdk/helper/logging" "github.com/hashicorp/vault/sdk/logical" "github.com/hashicorp/vault/vault" ) @@ -41,7 +39,6 @@ func TestBuiltinPluginsWork(t *testing.T) { // builtinplugins.Registry, so we need to add it here to be able to test it! "database": logicalDb.Factory, }, - Logger: logging.NewVaultLogger(hclog.Trace), PendingRemovalMountsAllowed: true, }, &vault.TestClusterOptions{ diff --git a/helper/testhelpers/seal/sealhelper.go b/helper/testhelpers/seal/sealhelper.go index b05401f1cd..7433b81bbe 100644 --- a/helper/testhelpers/seal/sealhelper.go +++ b/helper/testhelpers/seal/sealhelper.go @@ -7,13 +7,12 @@ import ( "path" "strconv" - "github.com/hashicorp/go-hclog" "github.com/hashicorp/vault/api" "github.com/hashicorp/vault/builtin/logical/transit" + "github.com/hashicorp/vault/helper/testhelpers/corehelpers" "github.com/hashicorp/vault/helper/testhelpers/teststorage" "github.com/hashicorp/vault/http" "github.com/hashicorp/vault/internalshared/configutil" - "github.com/hashicorp/vault/sdk/helper/logging" "github.com/hashicorp/vault/sdk/logical" "github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault/seal" @@ -33,7 +32,7 @@ func NewTransitSealServer(t testing.T, idx int) *TransitSealServer { opts := &vault.TestClusterOptions{ NumCores: 1, HandlerFunc: http.Handler, - Logger: logging.NewVaultLogger(hclog.Trace).Named(t.Name()).Named("transit-seal" + strconv.Itoa(idx)), + Logger: corehelpers.NewTestLogger(t).Named("transit-seal" + strconv.Itoa(idx)), } teststorage.InmemBackendSetup(conf, opts) cluster := vault.NewTestCluster(t, conf, opts) diff --git a/http/plugin_test.go b/http/plugin_test.go index b0d85be6d1..01180e56a1 100644 --- a/http/plugin_test.go +++ b/http/plugin_test.go @@ -45,7 +45,6 @@ func getPluginClusterAndCore(t testing.TB, logger log.Logger) (*vault.TestCluste cluster := vault.NewTestCluster(benchhelpers.TBtoT(t), coreConfig, &vault.TestClusterOptions{ HandlerFunc: Handler, - Logger: logger.Named("testclusteroptions"), }) cluster.Start() diff --git a/http/sys_init_test.go b/http/sys_init_test.go index 79dd275824..c4207f3441 100644 --- a/http/sys_init_test.go +++ b/http/sys_init_test.go @@ -10,9 +10,8 @@ import ( "strconv" "testing" - "github.com/hashicorp/go-hclog" "github.com/hashicorp/vault/builtin/logical/transit" - "github.com/hashicorp/vault/sdk/helper/logging" + "github.com/hashicorp/vault/helper/testhelpers/corehelpers" "github.com/hashicorp/vault/sdk/logical" "github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault/seal" @@ -169,7 +168,7 @@ func TestSysInit_Put_ValidateParams_AutoUnseal(t *testing.T) { opts := &vault.TestClusterOptions{ NumCores: 1, HandlerFunc: Handler, - Logger: logging.NewVaultLogger(hclog.Trace).Named(t.Name()).Named("transit-seal" + strconv.Itoa(0)), + Logger: corehelpers.NewTestLogger(t).Named("transit-seal" + strconv.Itoa(0)), } cluster := vault.NewTestCluster(t, conf, opts) cluster.Start() diff --git a/vault/dynamic_system_view_test.go b/vault/dynamic_system_view_test.go index d7e252e295..a5fd9f44be 100644 --- a/vault/dynamic_system_view_test.go +++ b/vault/dynamic_system_view_test.go @@ -12,7 +12,6 @@ import ( "testing" "time" - log "github.com/hashicorp/go-hclog" ldapcred "github.com/hashicorp/vault/builtin/credential/ldap" "github.com/hashicorp/vault/helper/namespace" "github.com/hashicorp/vault/sdk/framework" @@ -38,11 +37,7 @@ rule "charset" { ) func TestIdentity_BackendTemplating(t *testing.T) { - var err error coreConfig := &CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: log.NewNullLogger(), CredentialBackends: map[string]logical.Factory{ "ldap": ldapcred.Factory, }, @@ -178,11 +173,7 @@ func TestIdentity_BackendTemplating(t *testing.T) { } func TestDynamicSystemView_GeneratePasswordFromPolicy_successful(t *testing.T) { - var err error coreConfig := &CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: log.NewNullLogger(), CredentialBackends: map[string]logical.Factory{}, } @@ -201,7 +192,7 @@ func TestDynamicSystemView_GeneratePasswordFromPolicy_successful(t *testing.T) { req.ClientToken = cluster.RootToken req.Data["policy"] = b64Policy - _, err = core.HandleRequest(namespace.RootContext(nil), req) + _, err := core.HandleRequest(namespace.RootContext(nil), req) if err != nil { t.Fatalf("err: %v", err) } diff --git a/vault/external_plugin_test.go b/vault/external_plugin_test.go index 756d99ac84..a57dda2b9b 100644 --- a/vault/external_plugin_test.go +++ b/vault/external_plugin_test.go @@ -14,7 +14,6 @@ import ( "strings" "testing" - log "github.com/hashicorp/go-hclog" "github.com/hashicorp/vault/helper/namespace" "github.com/hashicorp/vault/helper/testhelpers/corehelpers" "github.com/hashicorp/vault/helper/testhelpers/pluginhelpers" @@ -67,9 +66,6 @@ func TestCore_EnableExternalPlugin(t *testing.T) { } { t.Run(name, func(t *testing.T) { coreConfig := &CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: log.NewNullLogger(), CredentialBackends: map[string]logical.Factory{}, } diff --git a/vault/external_tests/api/api_integration_test.go b/vault/external_tests/api/api_integration_test.go index 4aaba28092..9db8787159 100644 --- a/vault/external_tests/api/api_integration_test.go +++ b/vault/external_tests/api/api_integration_test.go @@ -7,7 +7,6 @@ import ( "encoding/base64" "testing" - log "github.com/hashicorp/go-hclog" "github.com/hashicorp/vault/api" "github.com/hashicorp/vault/audit" auditFile "github.com/hashicorp/vault/builtin/audit/file" @@ -37,9 +36,6 @@ func testVaultServerUnseal(t testing.TB) (*api.Client, []string, func()) { t.Helper() return testVaultServerCoreConfig(t, &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: log.NewNullLogger(), CredentialBackends: map[string]logical.Factory{ "userpass": credUserpass.Factory, }, diff --git a/vault/external_tests/api/sudo_paths_test.go b/vault/external_tests/api/sudo_paths_test.go index f2590992a8..983d727176 100644 --- a/vault/external_tests/api/sudo_paths_test.go +++ b/vault/external_tests/api/sudo_paths_test.go @@ -8,7 +8,6 @@ import ( "strings" "testing" - log "github.com/hashicorp/go-hclog" "github.com/hashicorp/vault/api" "github.com/hashicorp/vault/helper/builtinplugins" "github.com/hashicorp/vault/sdk/helper/jsonutil" @@ -22,11 +21,8 @@ func TestSudoPaths(t *testing.T) { t.Parallel() coreConfig := &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, EnableRaw: true, EnableIntrospection: true, - Logger: log.NewNullLogger(), BuiltinRegistry: builtinplugins.Registry, } client, _, closer := testVaultServerCoreConfig(t, coreConfig) diff --git a/vault/external_tests/misc/recover_from_panic_test.go b/vault/external_tests/misc/recover_from_panic_test.go index ae3b82cb94..802f5d6ff8 100644 --- a/vault/external_tests/misc/recover_from_panic_test.go +++ b/vault/external_tests/misc/recover_from_panic_test.go @@ -6,7 +6,6 @@ package misc import ( "testing" - "github.com/hashicorp/go-hclog" "github.com/hashicorp/vault/api" vaulthttp "github.com/hashicorp/vault/http" "github.com/hashicorp/vault/sdk/logical" @@ -16,13 +15,11 @@ import ( // Tests the regression in // https://github.com/hashicorp/vault/pull/6920 func TestRecoverFromPanic(t *testing.T) { - logger := hclog.New(nil) coreConfig := &vault.CoreConfig{ LogicalBackends: map[string]logical.Factory{ "noop": vault.NoopBackendFactory, }, EnableRaw: true, - Logger: logger, } cluster := vault.NewTestCluster(t, coreConfig, &vault.TestClusterOptions{ HandlerFunc: vaulthttp.Handler, diff --git a/vault/external_tests/misc/recovery_test.go b/vault/external_tests/misc/recovery_test.go index 8aaa6df728..f350886595 100644 --- a/vault/external_tests/misc/recovery_test.go +++ b/vault/external_tests/misc/recovery_test.go @@ -8,18 +8,16 @@ import ( "testing" "github.com/go-test/deep" - "github.com/hashicorp/go-hclog" "github.com/hashicorp/vault/helper/testhelpers" + "github.com/hashicorp/vault/helper/testhelpers/corehelpers" "github.com/hashicorp/vault/http" - "github.com/hashicorp/vault/sdk/helper/logging" "github.com/hashicorp/vault/sdk/physical/inmem" "github.com/hashicorp/vault/vault" "go.uber.org/atomic" ) func TestRecovery(t *testing.T) { - logger := logging.NewVaultLogger(hclog.Debug).Named(t.Name()) - inm, err := inmem.NewTransactionalInmemHA(nil, logger) + inm, err := inmem.NewTransactionalInmemHA(nil, corehelpers.NewTestLogger(t)) if err != nil { t.Fatal(err) } @@ -30,7 +28,6 @@ func TestRecovery(t *testing.T) { { conf := vault.CoreConfig{ Physical: inm, - Logger: logger, } opts := vault.TestClusterOptions{ HandlerFunc: http.Handler, @@ -73,7 +70,6 @@ func TestRecovery(t *testing.T) { var tokenRef atomic.String conf := vault.CoreConfig{ Physical: inm, - Logger: logger, RecoveryMode: true, } opts := vault.TestClusterOptions{ @@ -117,7 +113,6 @@ func TestRecovery(t *testing.T) { // Now go back to regular mode and verify that our changes are present conf := vault.CoreConfig{ Physical: inm, - Logger: logger, } opts := vault.TestClusterOptions{ HandlerFunc: http.Handler, diff --git a/vault/external_tests/policy/policy_test.go b/vault/external_tests/policy/policy_test.go index fea085f6e3..901eb01c2c 100644 --- a/vault/external_tests/policy/policy_test.go +++ b/vault/external_tests/policy/policy_test.go @@ -7,15 +7,13 @@ import ( "testing" "time" - "github.com/hashicorp/vault/helper/testhelpers/minimal" - "github.com/go-test/deep" - "github.com/hashicorp/go-hclog" "github.com/hashicorp/go-secure-stdlib/strutil" "github.com/hashicorp/vault/api" "github.com/hashicorp/vault/builtin/credential/ldap" credUserpass "github.com/hashicorp/vault/builtin/credential/userpass" ldaphelper "github.com/hashicorp/vault/helper/testhelpers/ldap" + "github.com/hashicorp/vault/helper/testhelpers/minimal" vaulthttp "github.com/hashicorp/vault/http" "github.com/hashicorp/vault/sdk/logical" "github.com/hashicorp/vault/vault" @@ -24,9 +22,6 @@ import ( func TestPolicy_NoDefaultPolicy(t *testing.T) { var err error coreConfig := &vault.CoreConfig{ - DisableMlock: true, - DisableCache: true, - Logger: hclog.NewNullLogger(), CredentialBackends: map[string]logical.Factory{ "ldap": ldap.Factory, }, diff --git a/vault/external_tests/sealmigration/seal_migration_test.go b/vault/external_tests/sealmigration/seal_migration_test.go index a67b0351f3..739eae5b60 100644 --- a/vault/external_tests/sealmigration/seal_migration_test.go +++ b/vault/external_tests/sealmigration/seal_migration_test.go @@ -9,15 +9,15 @@ import ( "github.com/hashicorp/go-hclog" "github.com/hashicorp/vault/helper/testhelpers" + "github.com/hashicorp/vault/helper/testhelpers/corehelpers" "github.com/hashicorp/vault/helper/testhelpers/teststorage" - "github.com/hashicorp/vault/sdk/helper/logging" "github.com/hashicorp/vault/vault" ) type testFunc func(t *testing.T, logger hclog.Logger, storage teststorage.ReusableStorage, basePort int) func testVariousBackends(t *testing.T, tf testFunc, basePort int, includeRaft bool) { - logger := logging.NewVaultLogger(hclog.Trace).Named(t.Name()) + logger := corehelpers.NewTestLogger(t) t.Run("inmem", func(t *testing.T) { t.Parallel() diff --git a/vault/sealunwrapper_test.go b/vault/sealunwrapper_test.go index c57096f91d..c4cad3bf3c 100644 --- a/vault/sealunwrapper_test.go +++ b/vault/sealunwrapper_test.go @@ -8,20 +8,18 @@ package vault import ( "bytes" "context" - "sync" "testing" proto "github.com/golang/protobuf/proto" log "github.com/hashicorp/go-hclog" wrapping "github.com/hashicorp/go-kms-wrapping/v2" + "github.com/hashicorp/vault/helper/testhelpers/corehelpers" "github.com/hashicorp/vault/sdk/physical" "github.com/hashicorp/vault/sdk/physical/inmem" ) func TestSealUnwrapper(t *testing.T) { - logger := log.New(&log.LoggerOptions{ - Mutex: &sync.Mutex{}, - }) + logger := corehelpers.NewTestLogger(t) // Test without transactions phys, err := inmem.NewInmemHA(nil, logger)