-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vault 32676 add vault build date to system view plugin env #29082
Changes from all commits
022a2e2
57c5178
a918734
08edbaf
8df8a82
027513f
3d60701
f333edf
806cdb4
4447857
3ef19e9
de115fb
f96ea93
ceb7506
fe7bf90
637b813
a6f3ce7
6d0848f
c9982b5
7ba9cfc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:improvement | ||
sdk: Add Vault build date to system view plugin environment response | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +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 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 init() { | ||
// The BuildDate is set as part of the build process in CI so we need to | ||
// 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 testApplyEntBaseConfig(coreConfig, base *CoreConfig) {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
//go:build !enterprise | ||
|
||
package vault | ||
|
||
import ( | ||
"crypto/ed25519" | ||
"testing" | ||
) | ||
|
||
//go:generate go run github.com/hashicorp/vault/tools/stubmaker | ||
|
||
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) {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ package version | |
import ( | ||
"bytes" | ||
"fmt" | ||
"time" | ||
) | ||
|
||
type VersionInfo struct { | ||
|
@@ -33,6 +34,14 @@ func GetVersion() *VersionInfo { | |
} | ||
} | ||
|
||
func GetVaultBuildDate() (time.Time, error) { | ||
buildDate, err := time.Parse(time.RFC3339, BuildDate) | ||
if err != nil { | ||
return time.Time{}, fmt.Errorf("failed to parse build date based on RFC3339: %w", err) | ||
} | ||
return buildDate, nil | ||
} | ||
Comment on lines
+37
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per the PR description, this is a copy of the existing, ENT-only |
||
|
||
func (c *VersionInfo) VersionNumber() string { | ||
if Version == "unknown" && VersionPrerelease == "unknown" { | ||
return "(version unknown)" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two notes:
I followed the naming convention for separate success/failure tests from the above test (i.e.
TestDynamicSystemView_GeneratePasswordFromPolicy_successful
andTestDynamicSystemView_GeneratePasswordFromPolicy_failed
). Open to renaming if consistency is less important.I also omitted a failure case, because the only failure point in
PluginEnv
is failure to parse the result ofGetVaultBuildDate()
. I looked into overridingversion.BuildDate
as it's done in an existing testTestGetSealStatus_RedactionSettings
, but found that this is incompatible with the ENT repo whose licensing tests all rely on this date being set. Happy to work/pair on a failure case if anyone has ideas!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point