Skip to content

Commit

Permalink
rename testing_util.go to testing_util_stubs_oss.go and move init Bui…
Browse files Browse the repository at this point in the history
…ldDate to new shared testing_util.go
  • Loading branch information
helenfufu committed Dec 4, 2024
1 parent ceb7506 commit 49f8ce4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
16 changes: 3 additions & 13 deletions vault/testing_util.go
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1

//go:build !enterprise

package vault

import (
"crypto/ed25519"
"testing"
"time"

"github.com/hashicorp/vault/version"
)

func init() {
// The BuildDate is set as part of the build process in CI so we need to
// initialize it for testing.
// initialize it for testing. By setting it to now minus one year we
// provide some headroom to ensure that test license expiration (for enterprise)
// does not exceed the BuildDate as that is invalid.
if version.BuildDate == "" {
version.BuildDate = time.Now().UTC().AddDate(-1, 0, 0).Format(time.RFC3339)
}
}

func GenerateTestLicenseKeys() (ed25519.PublicKey, ed25519.PrivateKey, error) { return nil, nil, nil }
func testGetLicensingConfig(key ed25519.PublicKey) *LicensingConfig { return &LicensingConfig{} }
func testExtraTestCoreSetup(testing.TB, ed25519.PrivateKey, *TestClusterCore) {}
func testAdjustUnderlyingStorage(tcc *TestClusterCore) {
tcc.UnderlyingStorage = tcc.physical
}
func testApplyEntBaseConfig(coreConfig, base *CoreConfig) {}
19 changes: 19 additions & 0 deletions vault/testing_util_stubs_oss.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1

//go:build !enterprise

package vault

import (
"crypto/ed25519"
"testing"
)

func GenerateTestLicenseKeys() (ed25519.PublicKey, ed25519.PrivateKey, error) { return nil, nil, nil }
func testGetLicensingConfig(key ed25519.PublicKey) *LicensingConfig { return &LicensingConfig{} }
func testExtraTestCoreSetup(testing.TB, ed25519.PrivateKey, *TestClusterCore) {}
func testAdjustUnderlyingStorage(tcc *TestClusterCore) {
tcc.UnderlyingStorage = tcc.physical
}
func testApplyEntBaseConfig(coreConfig, base *CoreConfig) {}

0 comments on commit 49f8ce4

Please sign in to comment.