Skip to content
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

Backport of Extra test for vault-33413 into release/1.18.x #29462

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading