Skip to content

Commit

Permalink
Merge 39e7fae into backport/vault-33413-extra-test/visually-gorgeous-…
Browse files Browse the repository at this point in the history
…foxhound
  • Loading branch information
hc-github-team-secure-vault-core authored Jan 30, 2025
2 parents c9e82a0 + 39e7fae commit 920076b
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions vault/activity_log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ import (
"github.com/go-test/deep"
"github.com/golang/protobuf/proto"
"github.com/hashicorp/go-uuid"
"github.com/hashicorp/vault/command/server"
"github.com/hashicorp/vault/helper/constants"
"github.com/hashicorp/vault/helper/namespace"
"github.com/hashicorp/vault/helper/timeutil"
"github.com/hashicorp/vault/internalshared/configutil"
"github.com/hashicorp/vault/sdk/logical"
"github.com/hashicorp/vault/vault/activity"
"github.com/mitchellh/mapstructure"
Expand Down Expand Up @@ -1922,9 +1924,19 @@ func (f *fakeResponseWriter) WriteHeader(statusCode int) {
// their parents.
func TestActivityLog_IncludeNamespace(t *testing.T) {
root := namespace.RootNamespace
core, _, _ := TestCoreUnsealed(t)
coreConfig := &CoreConfig{
RawConfig: &server.Config{
SharedConfig: &configutil.SharedConfig{AdministrativeNamespacePath: "admin/"},
},
AdministrativeNamespacePath: "admin/",
}
core, _, _ := TestCoreUnsealedWithConfig(t, coreConfig)
a := core.activityLog

adminNs := &namespace.Namespace{
ID: "adminID",
Path: "admin/",
}
nsA := &namespace.Namespace{
ID: "aaaaa",
Path: "a/",
Expand All @@ -1937,13 +1949,15 @@ func TestActivityLog_IncludeNamespace(t *testing.T) {
ID: "bbbbb",
Path: "a/b/",
}

testCases := []struct {
QueryNS *namespace.Namespace
RecordNS *namespace.Namespace
Expected bool
}{
// deleted namespace records must be included in root and admin namespaces
{root, nil, true},
{adminNs, nil, true},

{root, root, true},
{root, nsA, true},
{root, nsAB, true},
Expand All @@ -1959,7 +1973,6 @@ func TestActivityLog_IncludeNamespace(t *testing.T) {
{nsC, nsA, false},
{nsC, nsAB, false},
}

for _, tc := range testCases {
if a.includeInResponse(tc.QueryNS, tc.RecordNS) != tc.Expected {
t.Errorf("bad response for query %v record %v, expected %v",
Expand Down

0 comments on commit 920076b

Please sign in to comment.