Remove namespace.TestContext and namespace.TestNamespace (#5682)

This commit is contained in:
Vishal Nayak 2018-11-05 11:11:32 -05:00 committed by GitHub
parent 227954983c
commit 332e32294a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 698 additions and 706 deletions

View File

@ -59,7 +59,7 @@ func preparePostgresTestContainer(t *testing.T, s logical.Storage, b logical.Bac
// exponential backoff-retry
if err = pool.Retry(func() error {
// This will cause a validation to run
resp, err := b.HandleRequest(namespace.TestContext(), &logical.Request{
resp, err := b.HandleRequest(namespace.RootContext(nil), &logical.Request{
Storage: s,
Operation: logical.UpdateOperation,
Path: "config/postgresql",
@ -228,7 +228,7 @@ func TestBackend_config_connection(t *testing.T) {
t.Fatal("expected not exists")
}
resp, err = b.HandleRequest(namespace.TestContext(), configReq)
resp, err = b.HandleRequest(namespace.RootContext(nil), configReq)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%v resp:%#v\n", err, resp)
}
@ -243,7 +243,7 @@ func TestBackend_config_connection(t *testing.T) {
"root_credentials_rotate_statements": []string{},
}
configReq.Operation = logical.ReadOperation
resp, err = b.HandleRequest(namespace.TestContext(), configReq)
resp, err = b.HandleRequest(namespace.RootContext(nil), configReq)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -280,7 +280,7 @@ func TestBackend_config_connection(t *testing.T) {
t.Fatal("expected exists")
}
resp, err = b.HandleRequest(namespace.TestContext(), configReq)
resp, err = b.HandleRequest(namespace.RootContext(nil), configReq)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%v resp:%#v\n", err, resp)
}
@ -295,7 +295,7 @@ func TestBackend_config_connection(t *testing.T) {
"root_credentials_rotate_statements": []string{},
}
configReq.Operation = logical.ReadOperation
resp, err = b.HandleRequest(namespace.TestContext(), configReq)
resp, err = b.HandleRequest(namespace.RootContext(nil), configReq)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -321,7 +321,7 @@ func TestBackend_config_connection(t *testing.T) {
Data: configData,
}
resp, err = b.HandleRequest(namespace.TestContext(), configReq)
resp, err = b.HandleRequest(namespace.RootContext(nil), configReq)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%v resp:%#v\n", err, resp)
}
@ -336,7 +336,7 @@ func TestBackend_config_connection(t *testing.T) {
"root_credentials_rotate_statements": []string{},
}
configReq.Operation = logical.ReadOperation
resp, err = b.HandleRequest(namespace.TestContext(), configReq)
resp, err = b.HandleRequest(namespace.RootContext(nil), configReq)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -352,7 +352,7 @@ func TestBackend_config_connection(t *testing.T) {
Storage: config.StorageView,
Path: "config/",
}
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil {
t.Fatal(err)
}
@ -382,7 +382,7 @@ func TestBackend_BadConnectionString(t *testing.T) {
respCheck := func(req *logical.Request) {
t.Helper()
resp, err := b.HandleRequest(namespace.TestContext(), req)
resp, err := b.HandleRequest(namespace.RootContext(nil), req)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -441,7 +441,7 @@ func TestBackend_basic(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err := b.HandleRequest(namespace.TestContext(), req)
resp, err := b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -458,7 +458,7 @@ func TestBackend_basic(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -470,7 +470,7 @@ func TestBackend_basic(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
credsResp, err := b.HandleRequest(namespace.TestContext(), req)
credsResp, err := b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (credsResp != nil && credsResp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, credsResp)
}
@ -487,7 +487,7 @@ func TestBackend_basic(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -499,7 +499,7 @@ func TestBackend_basic(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
credsResp, err = b.HandleRequest(namespace.TestContext(), req)
credsResp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (credsResp != nil && credsResp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, credsResp)
}
@ -520,7 +520,7 @@ func TestBackend_basic(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -534,7 +534,7 @@ func TestBackend_basic(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
credsResp, err = b.HandleRequest(namespace.TestContext(), req)
credsResp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (credsResp != nil && credsResp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, credsResp)
}
@ -547,7 +547,7 @@ func TestBackend_basic(t *testing.T) {
}
// Revoke creds
resp, err = b.HandleRequest(namespace.TestContext(), &logical.Request{
resp, err = b.HandleRequest(namespace.RootContext(nil), &logical.Request{
Operation: logical.RevokeOperation,
Storage: config.StorageView,
Secret: &logical.Secret{
@ -576,7 +576,7 @@ func TestBackend_basic(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
credsResp, err = b.HandleRequest(namespace.TestContext(), req)
credsResp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (credsResp != nil && credsResp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, credsResp)
}
@ -590,13 +590,13 @@ func TestBackend_basic(t *testing.T) {
Path: "roles/plugin-role-test",
Storage: config.StorageView,
}
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
// Revoke creds
resp, err = b.HandleRequest(namespace.TestContext(), &logical.Request{
resp, err = b.HandleRequest(namespace.RootContext(nil), &logical.Request{
Operation: logical.RevokeOperation,
Storage: config.StorageView,
Secret: &logical.Secret{
@ -648,7 +648,7 @@ func TestBackend_connectionCrud(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err := b.HandleRequest(namespace.TestContext(), req)
resp, err := b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -667,7 +667,7 @@ func TestBackend_connectionCrud(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -686,7 +686,7 @@ func TestBackend_connectionCrud(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -695,7 +695,7 @@ func TestBackend_connectionCrud(t *testing.T) {
}
req.Operation = logical.ReadOperation
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -707,7 +707,7 @@ func TestBackend_connectionCrud(t *testing.T) {
req.Operation = logical.UpdateOperation
connURL = strings.Replace(connURL, "postgres:secret", "{{username}}:{{password}}", -1)
data["connection_url"] = connURL
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -723,7 +723,7 @@ func TestBackend_connectionCrud(t *testing.T) {
"root_credentials_rotate_statements": []string(nil),
}
req.Operation = logical.ReadOperation
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -741,7 +741,7 @@ func TestBackend_connectionCrud(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -754,7 +754,7 @@ func TestBackend_connectionCrud(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
credsResp, err := b.HandleRequest(namespace.TestContext(), req)
credsResp, err := b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (credsResp != nil && credsResp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, credsResp)
}
@ -775,14 +775,14 @@ func TestBackend_connectionCrud(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
// Read connection
req.Operation = logical.ReadOperation
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -825,7 +825,7 @@ func TestBackend_roleCrud(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err := b.HandleRequest(namespace.TestContext(), req)
resp, err := b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -845,7 +845,7 @@ func TestBackend_roleCrud(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -869,7 +869,7 @@ func TestBackend_roleCrud(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -913,7 +913,7 @@ func TestBackend_roleCrud(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%v resp:%#v\n", err, resp)
}
@ -937,7 +937,7 @@ func TestBackend_roleCrud(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -1051,7 +1051,7 @@ func TestBackend_roleCrud(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -1064,7 +1064,7 @@ func TestBackend_roleCrud(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -1102,7 +1102,7 @@ func TestBackend_allowedRoles(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err := b.HandleRequest(namespace.TestContext(), req)
resp, err := b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -1120,7 +1120,7 @@ func TestBackend_allowedRoles(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -1137,7 +1137,7 @@ func TestBackend_allowedRoles(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -1150,7 +1150,7 @@ func TestBackend_allowedRoles(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
credsResp, err := b.HandleRequest(namespace.TestContext(), req)
credsResp, err := b.HandleRequest(namespace.RootContext(nil), req)
if err != logical.ErrPermissionDenied {
t.Fatalf("expected error to be:%s got:%#v\n", logical.ErrPermissionDenied, err)
}
@ -1167,7 +1167,7 @@ func TestBackend_allowedRoles(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -1180,7 +1180,7 @@ func TestBackend_allowedRoles(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
credsResp, err = b.HandleRequest(namespace.TestContext(), req)
credsResp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (credsResp != nil && credsResp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, credsResp)
}
@ -1201,7 +1201,7 @@ func TestBackend_allowedRoles(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -1214,7 +1214,7 @@ func TestBackend_allowedRoles(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
credsResp, err = b.HandleRequest(namespace.TestContext(), req)
credsResp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (credsResp != nil && credsResp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, credsResp)
}
@ -1235,7 +1235,7 @@ func TestBackend_allowedRoles(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -1248,7 +1248,7 @@ func TestBackend_allowedRoles(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
credsResp, err = b.HandleRequest(namespace.TestContext(), req)
credsResp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != logical.ErrPermissionDenied {
t.Fatalf("expected error to be:%s got:%#v\n", logical.ErrPermissionDenied, err)
}
@ -1261,7 +1261,7 @@ func TestBackend_allowedRoles(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
credsResp, err = b.HandleRequest(namespace.TestContext(), req)
credsResp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (credsResp != nil && credsResp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, credsResp)
}
@ -1304,7 +1304,7 @@ func TestBackend_RotateRootCredentials(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err := b.HandleRequest(namespace.TestContext(), req)
resp, err := b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -1321,7 +1321,7 @@ func TestBackend_RotateRootCredentials(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (resp != nil && resp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, resp)
}
@ -1333,7 +1333,7 @@ func TestBackend_RotateRootCredentials(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
credsResp, err := b.HandleRequest(namespace.TestContext(), req)
credsResp, err := b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (credsResp != nil && credsResp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, credsResp)
}
@ -1345,7 +1345,7 @@ func TestBackend_RotateRootCredentials(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
resp, err = b.HandleRequest(namespace.TestContext(), req)
resp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (credsResp != nil && credsResp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, credsResp)
}
@ -1366,7 +1366,7 @@ func TestBackend_RotateRootCredentials(t *testing.T) {
Storage: config.StorageView,
Data: data,
}
credsResp, err = b.HandleRequest(namespace.TestContext(), req)
credsResp, err = b.HandleRequest(namespace.RootContext(nil), req)
if err != nil || (credsResp != nil && credsResp.IsError()) {
t.Fatalf("err:%s resp:%#v\n", err, credsResp)
}

View File

@ -149,7 +149,7 @@ func TestPlugin_Init(t *testing.T) {
cluster, sys := getCluster(t)
defer cluster.Cleanup()
dbRaw, err := dbplugin.PluginFactory(namespace.TestContext(), "test-plugin", sys, log.NewNullLogger())
dbRaw, err := dbplugin.PluginFactory(namespace.RootContext(nil), "test-plugin", sys, log.NewNullLogger())
if err != nil {
t.Fatalf("err: %s", err)
}
@ -173,7 +173,7 @@ func TestPlugin_CreateUser(t *testing.T) {
cluster, sys := getCluster(t)
defer cluster.Cleanup()
db, err := dbplugin.PluginFactory(namespace.TestContext(), "test-plugin", sys, log.NewNullLogger())
db, err := dbplugin.PluginFactory(namespace.RootContext(nil), "test-plugin", sys, log.NewNullLogger())
if err != nil {
t.Fatalf("err: %s", err)
}
@ -213,7 +213,7 @@ func TestPlugin_RenewUser(t *testing.T) {
cluster, sys := getCluster(t)
defer cluster.Cleanup()
db, err := dbplugin.PluginFactory(namespace.TestContext(), "test-plugin", sys, log.NewNullLogger())
db, err := dbplugin.PluginFactory(namespace.RootContext(nil), "test-plugin", sys, log.NewNullLogger())
if err != nil {
t.Fatalf("err: %s", err)
}
@ -247,7 +247,7 @@ func TestPlugin_RevokeUser(t *testing.T) {
cluster, sys := getCluster(t)
defer cluster.Cleanup()
db, err := dbplugin.PluginFactory(namespace.TestContext(), "test-plugin", sys, log.NewNullLogger())
db, err := dbplugin.PluginFactory(namespace.RootContext(nil), "test-plugin", sys, log.NewNullLogger())
if err != nil {
t.Fatalf("err: %s", err)
}
@ -289,7 +289,7 @@ func TestPlugin_NetRPC_Init(t *testing.T) {
cluster, sys := getCluster(t)
defer cluster.Cleanup()
dbRaw, err := dbplugin.PluginFactory(namespace.TestContext(), "test-plugin-netRPC", sys, log.NewNullLogger())
dbRaw, err := dbplugin.PluginFactory(namespace.RootContext(nil), "test-plugin-netRPC", sys, log.NewNullLogger())
if err != nil {
t.Fatalf("err: %s", err)
}
@ -313,7 +313,7 @@ func TestPlugin_NetRPC_CreateUser(t *testing.T) {
cluster, sys := getCluster(t)
defer cluster.Cleanup()
db, err := dbplugin.PluginFactory(namespace.TestContext(), "test-plugin-netRPC", sys, log.NewNullLogger())
db, err := dbplugin.PluginFactory(namespace.RootContext(nil), "test-plugin-netRPC", sys, log.NewNullLogger())
if err != nil {
t.Fatalf("err: %s", err)
}
@ -353,7 +353,7 @@ func TestPlugin_NetRPC_RenewUser(t *testing.T) {
cluster, sys := getCluster(t)
defer cluster.Cleanup()
db, err := dbplugin.PluginFactory(namespace.TestContext(), "test-plugin-netRPC", sys, log.NewNullLogger())
db, err := dbplugin.PluginFactory(namespace.RootContext(nil), "test-plugin-netRPC", sys, log.NewNullLogger())
if err != nil {
t.Fatalf("err: %s", err)
}
@ -387,7 +387,7 @@ func TestPlugin_NetRPC_RevokeUser(t *testing.T) {
cluster, sys := getCluster(t)
defer cluster.Cleanup()
db, err := dbplugin.PluginFactory(namespace.TestContext(), "test-plugin-netRPC", sys, log.NewNullLogger())
db, err := dbplugin.PluginFactory(namespace.RootContext(nil), "test-plugin-netRPC", sys, log.NewNullLogger())
if err != nil {
t.Fatalf("err: %s", err)
}

View File

@ -75,14 +75,6 @@ func FromContext(ctx context.Context) (*Namespace, error) {
return ns, nil
}
func TestContext() context.Context {
return ContextWithNamespace(context.Background(), TestNamespace())
}
func TestNamespace() *Namespace {
return RootNamespace
}
// Canonicalize trims any prefix '/' and adds a trailing '/' to the
// provided string
func Canonicalize(nsPath string) string {

View File

@ -270,7 +270,7 @@ func Test(tt TestT, c TestCase) {
req.Path = fmt.Sprintf("%s/%s", prefix, req.Path)
// Make the request
resp, err := core.HandleRequest(namespace.TestContext(), req)
resp, err := core.HandleRequest(namespace.RootContext(nil), req)
if resp != nil && resp.Secret != nil {
// Revoke this secret later
revoke = append(revoke, &logical.Request{
@ -324,7 +324,7 @@ func Test(tt TestT, c TestCase) {
logger.Warn("Revoking secret", "secret", fmt.Sprintf("%#v", req))
}
req.ClientToken = client.Token()
resp, err := core.HandleRequest(namespace.TestContext(), req)
resp, err := core.HandleRequest(namespace.RootContext(nil), req)
if err == nil && resp.IsError() {
err = fmt.Errorf("erroneous response:\n\n%#v", resp)
}
@ -341,7 +341,7 @@ func Test(tt TestT, c TestCase) {
req := logical.RollbackRequest(prefix + "/")
req.Data["immediate"] = true
req.ClientToken = client.Token()
resp, err := core.HandleRequest(namespace.TestContext(), req)
resp, err := core.HandleRequest(namespace.RootContext(nil), req)
if err == nil && resp.IsError() {
err = fmt.Errorf("erroneous response:\n\n%#v", resp)
}

View File

@ -159,7 +159,7 @@ func testACLRoot(t *testing.T, ns *namespace.Namespace) {
// Create the root policy ACL. Always create on root namespace regardless of
// which namespace to ACL check on.
policy := []*Policy{&Policy{Name: "root"}}
acl, err := NewACL(namespace.TestContext(), policy)
acl, err := NewACL(namespace.RootContext(nil), policy)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -598,7 +598,7 @@ func TestACL_CreationRace(t *testing.T) {
if time.Now().After(stopTime) {
return
}
_, err := NewACL(namespace.TestContext(), []*Policy{policy})
_, err := NewACL(namespace.RootContext(nil), []*Policy{policy})
if err != nil {
t.Fatalf("err: %v", err)
}

View File

@ -123,7 +123,7 @@ func TestAudit_ReadOnlyViewDuringMount(t *testing.T) {
Path: "foo",
Type: "noop",
}
err := c.enableAudit(namespace.TestContext(), me, true)
err := c.enableAudit(namespace.RootContext(nil), me, true)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -142,7 +142,7 @@ func TestCore_EnableAudit(t *testing.T) {
Path: "foo",
Type: "noop",
}
err := c.enableAudit(namespace.TestContext(), me, true)
err := c.enableAudit(namespace.RootContext(nil), me, true)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -262,7 +262,7 @@ func TestCore_EnableAudit_Local(t *testing.T) {
UUID: "abcd",
Accessor: "noop-abcd",
NamespaceID: namespace.RootNamespaceID,
namespace: namespace.TestNamespace(),
namespace: namespace.RootNamespace,
},
&MountEntry{
Table: auditTableType,
@ -271,7 +271,7 @@ func TestCore_EnableAudit_Local(t *testing.T) {
UUID: "bcde",
Accessor: "noop-bcde",
NamespaceID: namespace.RootNamespaceID,
namespace: namespace.TestNamespace(),
namespace: namespace.RootNamespace,
},
},
}
@ -339,7 +339,7 @@ func TestCore_DisableAudit(t *testing.T) {
}, nil
}
existed, err := c.disableAudit(namespace.TestContext(), "foo", true)
existed, err := c.disableAudit(namespace.RootContext(nil), "foo", true)
if existed && err != nil {
t.Fatalf("existed: %v; err: %v", existed, err)
}
@ -349,12 +349,12 @@ func TestCore_DisableAudit(t *testing.T) {
Path: "foo",
Type: "noop",
}
err = c.enableAudit(namespace.TestContext(), me, true)
err = c.enableAudit(namespace.RootContext(nil), me, true)
if err != nil {
t.Fatalf("err: %v", err)
}
existed, err = c.disableAudit(namespace.TestContext(), "foo", true)
existed, err = c.disableAudit(namespace.RootContext(nil), "foo", true)
if !existed || err != nil {
t.Fatalf("existed: %v; err: %v", existed, err)
}

View File

@ -29,7 +29,7 @@ func TestAuth_ReadOnlyViewDuringMount(t *testing.T) {
Path: "foo",
Type: "noop",
}
err := c.enableCredential(namespace.TestContext(), me)
err := c.enableCredential(namespace.RootContext(nil), me)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -75,12 +75,12 @@ func TestCore_EnableCredential(t *testing.T) {
Path: "foo",
Type: "noop",
}
err := c.enableCredential(namespace.TestContext(), me)
err := c.enableCredential(namespace.RootContext(nil), me)
if err != nil {
t.Fatalf("err: %v", err)
}
match := c.router.MatchingMount(namespace.TestContext(), "auth/foo/bar")
match := c.router.MatchingMount(namespace.RootContext(nil), "auth/foo/bar")
if match != "auth/foo/" {
t.Fatalf("missing mount, match: %q", match)
}
@ -132,7 +132,7 @@ func TestCore_EnableCredential_Local(t *testing.T) {
Accessor: "noop-abcd",
BackendAwareUUID: "abcde",
NamespaceID: namespace.RootNamespaceID,
namespace: namespace.TestNamespace(),
namespace: namespace.RootNamespace,
},
&MountEntry{
Table: credentialTableType,
@ -142,7 +142,7 @@ func TestCore_EnableCredential_Local(t *testing.T) {
Accessor: "noop-bcde",
BackendAwareUUID: "bcdea",
NamespaceID: namespace.RootNamespaceID,
namespace: namespace.TestNamespace(),
namespace: namespace.RootNamespace,
},
},
}
@ -213,13 +213,13 @@ func TestCore_EnableCredential_twice_409(t *testing.T) {
Path: "foo",
Type: "noop",
}
err := c.enableCredential(namespace.TestContext(), me)
err := c.enableCredential(namespace.RootContext(nil), me)
if err != nil {
t.Fatalf("err: %v", err)
}
// 2nd should be a 409 error
err2 := c.enableCredential(namespace.TestContext(), me)
err2 := c.enableCredential(namespace.RootContext(nil), me)
switch err2.(type) {
case logical.HTTPCodedError:
if err2.(logical.HTTPCodedError).Code() != 409 {
@ -237,7 +237,7 @@ func TestCore_EnableCredential_Token(t *testing.T) {
Path: "foo",
Type: "token",
}
err := c.enableCredential(namespace.TestContext(), me)
err := c.enableCredential(namespace.RootContext(nil), me)
if err.Error() != "token credential backend cannot be instantiated" {
t.Fatalf("err: %v", err)
}
@ -249,7 +249,7 @@ func TestCore_DisableCredential(t *testing.T) {
return &NoopBackend{}, nil
}
err := c.disableCredential(namespace.TestContext(), "foo")
err := c.disableCredential(namespace.RootContext(nil), "foo")
if err != nil && !strings.HasPrefix(err.Error(), "no matching mount") {
t.Fatal(err)
}
@ -259,17 +259,17 @@ func TestCore_DisableCredential(t *testing.T) {
Path: "foo",
Type: "noop",
}
err = c.enableCredential(namespace.TestContext(), me)
err = c.enableCredential(namespace.RootContext(nil), me)
if err != nil {
t.Fatalf("err: %v", err)
}
err = c.disableCredential(namespace.TestContext(), "foo")
err = c.disableCredential(namespace.RootContext(nil), "foo")
if err != nil {
t.Fatalf("err: %v", err)
}
match := c.router.MatchingMount(namespace.TestContext(), "auth/foo/bar")
match := c.router.MatchingMount(namespace.RootContext(nil), "auth/foo/bar")
if match != "" {
t.Fatalf("backend present")
}
@ -300,7 +300,7 @@ func TestCore_DisableCredential(t *testing.T) {
func TestCore_DisableCredential_Protected(t *testing.T) {
c, _, _ := TestCoreUnsealed(t)
err := c.disableCredential(namespace.TestContext(), "token")
err := c.disableCredential(namespace.RootContext(nil), "token")
if err.Error() != "token credential backend cannot be disabled" {
t.Fatalf("err: %v", err)
}
@ -320,13 +320,13 @@ func TestCore_DisableCredential_Cleanup(t *testing.T) {
Path: "foo",
Type: "noop",
}
err := c.enableCredential(namespace.TestContext(), me)
err := c.enableCredential(namespace.RootContext(nil), me)
if err != nil {
t.Fatalf("err: %v", err)
}
// Store the view
view := c.router.MatchingStorageByAPIPath(namespace.TestContext(), "auth/foo/")
view := c.router.MatchingStorageByAPIPath(namespace.RootContext(nil), "auth/foo/")
// Inject data
se := &logical.StorageEntry{
@ -347,7 +347,7 @@ func TestCore_DisableCredential_Cleanup(t *testing.T) {
Operation: logical.ReadOperation,
Path: "auth/foo/login",
}
resp, err := c.HandleRequest(namespace.TestContext(), r)
resp, err := c.HandleRequest(namespace.RootContext(nil), r)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -356,13 +356,13 @@ func TestCore_DisableCredential_Cleanup(t *testing.T) {
}
// Disable should cleanup
err = c.disableCredential(namespace.TestContext(), "foo")
err = c.disableCredential(namespace.RootContext(nil), "foo")
if err != nil {
t.Fatalf("err: %v", err)
}
// Token should be revoked
te, err := c.tokenStore.Lookup(namespace.TestContext(), resp.Auth.ClientToken)
te, err := c.tokenStore.Lookup(namespace.RootContext(nil), resp.Auth.ClientToken)
if err != nil {
t.Fatalf("err: %v", err)
}

View File

@ -65,7 +65,7 @@ func TestExpiration_Tidy(t *testing.T) {
}
// Scan the storage with the count func set
if err = logical.ScanView(namespace.TestContext(), exp.idView, countFunc); err != nil {
if err = logical.ScanView(namespace.RootContext(nil), exp.idView, countFunc); err != nil {
t.Fatal(err)
}
@ -78,11 +78,11 @@ func TestExpiration_Tidy(t *testing.T) {
le := &leaseEntry{
LeaseID: "lease/with/no/client/token",
Path: "foo/bar",
namespace: namespace.TestNamespace(),
namespace: namespace.RootNamespace,
}
// Persist the invalid lease entry
if err = exp.persistEntry(namespace.TestContext(), le); err != nil {
if err = exp.persistEntry(namespace.RootContext(nil), le); err != nil {
t.Fatalf("error persisting entry: %v", err)
}
@ -98,7 +98,7 @@ func TestExpiration_Tidy(t *testing.T) {
}
// Run the tidy operation
err = exp.Tidy(namespace.TestContext())
err = exp.Tidy(namespace.RootContext(nil))
if err != nil {
t.Fatal(err)
}
@ -117,7 +117,7 @@ func TestExpiration_Tidy(t *testing.T) {
le.ClientToken = "invalidtoken"
// Persist the invalid lease entry
if err = exp.persistEntry(namespace.TestContext(), le); err != nil {
if err = exp.persistEntry(namespace.RootContext(nil), le); err != nil {
t.Fatalf("error persisting entry: %v", err)
}
@ -133,7 +133,7 @@ func TestExpiration_Tidy(t *testing.T) {
}
// Run the tidy operation
err = exp.Tidy(namespace.TestContext())
err = exp.Tidy(namespace.RootContext(nil))
if err != nil {
t.Fatal(err)
}
@ -149,7 +149,7 @@ func TestExpiration_Tidy(t *testing.T) {
}
// Attach an invalid token with 2 leases
if err = exp.persistEntry(namespace.TestContext(), le); err != nil {
if err = exp.persistEntry(namespace.RootContext(nil), le); err != nil {
t.Fatalf("error persisting entry: %v", err)
}
@ -159,7 +159,7 @@ func TestExpiration_Tidy(t *testing.T) {
}
// Run the tidy operation
err = exp.Tidy(namespace.TestContext())
err = exp.Tidy(namespace.RootContext(nil))
if err != nil {
t.Fatal(err)
}
@ -191,7 +191,7 @@ func TestExpiration_Tidy(t *testing.T) {
"test_key": "test_value",
},
}
_, err := exp.Register(namespace.TestContext(), req, resp)
_, err := exp.Register(namespace.RootContext(nil), req, resp)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -214,11 +214,11 @@ func TestExpiration_Tidy(t *testing.T) {
// one tidy operation can be in flight at any time. One of these requests
// should error out.
go func() {
errCh1 <- exp.Tidy(namespace.TestContext())
errCh1 <- exp.Tidy(namespace.RootContext(nil))
}()
go func() {
errCh2 <- exp.Tidy(namespace.TestContext())
errCh2 <- exp.Tidy(namespace.RootContext(nil))
}()
var err1, err2 error
@ -244,12 +244,12 @@ func TestExpiration_Tidy(t *testing.T) {
le.ClientToken = root.ID
// Attach a valid token with the leases
if err = exp.persistEntry(namespace.TestContext(), le); err != nil {
if err = exp.persistEntry(namespace.RootContext(nil), le); err != nil {
t.Fatalf("error persisting entry: %v", err)
}
// Run the tidy operation
err = exp.Tidy(namespace.TestContext())
err = exp.Tidy(namespace.RootContext(nil))
if err != nil {
t.Fatal(err)
}
@ -321,7 +321,7 @@ func benchmarkExpirationBackend(b *testing.B, physicalBackend physical.Backend,
if err != nil {
b.Fatal(err)
}
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.TestNamespace()}, view)
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.RootNamespace}, view)
if err != nil {
b.Fatal(err)
}
@ -381,7 +381,7 @@ func TestExpiration_Restore(t *testing.T) {
if err != nil {
t.Fatal(err)
}
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.TestNamespace()}, view)
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.RootNamespace}, view)
if err != nil {
t.Fatal(err)
}
@ -409,7 +409,7 @@ func TestExpiration_Restore(t *testing.T) {
"secret_key": "abcd",
},
}
_, err := exp.Register(namespace.TestContext(), req, resp)
_, err := exp.Register(namespace.RootContext(nil), req, resp)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -467,7 +467,7 @@ func TestExpiration_Register(t *testing.T) {
},
}
id, err := exp.Register(namespace.TestContext(), req, resp)
id, err := exp.Register(namespace.RootContext(nil), req, resp)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -499,7 +499,7 @@ func TestExpiration_RegisterAuth(t *testing.T) {
Path: "auth/github/login",
NamespaceID: namespace.RootNamespaceID,
}
err = exp.RegisterAuth(namespace.TestContext(), te, auth)
err = exp.RegisterAuth(namespace.RootContext(nil), te, auth)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -508,7 +508,7 @@ func TestExpiration_RegisterAuth(t *testing.T) {
Path: "auth/github/../login",
NamespaceID: namespace.RootNamespaceID,
}
err = exp.RegisterAuth(namespace.TestContext(), te, auth)
err = exp.RegisterAuth(namespace.RootContext(nil), te, auth)
if err == nil {
t.Fatal("expected error")
}
@ -530,7 +530,7 @@ func TestExpiration_RegisterAuth_NoLease(t *testing.T) {
Path: "auth/github/login",
NamespaceID: namespace.RootNamespaceID,
}
err = exp.RegisterAuth(namespace.TestContext(), te, auth)
err = exp.RegisterAuth(namespace.RootContext(nil), te, auth)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -541,7 +541,7 @@ func TestExpiration_RegisterAuth_NoLease(t *testing.T) {
Path: "auth/github/login",
NamespaceID: namespace.RootNamespaceID,
}
resp, err := exp.RenewToken(namespace.TestContext(), &logical.Request{}, te, 0)
resp, err := exp.RenewToken(namespace.RootContext(nil), &logical.Request{}, te, 0)
if err != nil && (err != logical.ErrInvalidRequest || (resp != nil && resp.IsError() && resp.Error().Error() != "lease is not renewable")) {
t.Fatalf("bad: err:%v resp:%#v", err, resp)
}
@ -553,7 +553,7 @@ func TestExpiration_RegisterAuth_NoLease(t *testing.T) {
time.Sleep(20 * time.Millisecond)
// Verify token does not get revoked
out, err := exp.tokenStore.Lookup(namespace.TestContext(), root.ID)
out, err := exp.tokenStore.Lookup(namespace.RootContext(nil), root.ID)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -571,7 +571,7 @@ func TestExpiration_Revoke(t *testing.T) {
if err != nil {
t.Fatal(err)
}
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.TestNamespace()}, view)
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.RootNamespace}, view)
if err != nil {
t.Fatal(err)
}
@ -594,12 +594,12 @@ func TestExpiration_Revoke(t *testing.T) {
},
}
id, err := exp.Register(namespace.TestContext(), req, resp)
id, err := exp.Register(namespace.RootContext(nil), req, resp)
if err != nil {
t.Fatalf("err: %v", err)
}
if err := exp.Revoke(namespace.TestContext(), id); err != nil {
if err := exp.Revoke(namespace.RootContext(nil), id); err != nil {
t.Fatalf("err: %v", err)
}
@ -618,7 +618,7 @@ func TestExpiration_RevokeOnExpire(t *testing.T) {
if err != nil {
t.Fatal(err)
}
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.TestNamespace()}, view)
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.RootNamespace}, view)
if err != nil {
t.Fatal(err)
}
@ -641,7 +641,7 @@ func TestExpiration_RevokeOnExpire(t *testing.T) {
},
}
_, err = exp.Register(namespace.TestContext(), req, resp)
_, err = exp.Register(namespace.RootContext(nil), req, resp)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -676,7 +676,7 @@ func TestExpiration_RevokePrefix(t *testing.T) {
if err != nil {
t.Fatal(err)
}
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.TestNamespace()}, view)
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.RootNamespace}, view)
if err != nil {
t.Fatal(err)
}
@ -704,14 +704,14 @@ func TestExpiration_RevokePrefix(t *testing.T) {
"secret_key": "abcd",
},
}
_, err := exp.Register(namespace.TestContext(), req, resp)
_, err := exp.Register(namespace.RootContext(nil), req, resp)
if err != nil {
t.Fatalf("err: %v", err)
}
}
// Should nuke all the keys
if err := exp.RevokePrefix(namespace.TestContext(), "prod/aws/", true); err != nil {
if err := exp.RevokePrefix(namespace.RootContext(nil), "prod/aws/", true); err != nil {
t.Fatalf("err: %v", err)
}
@ -745,7 +745,7 @@ func TestExpiration_RevokeByToken(t *testing.T) {
if err != nil {
t.Fatal(err)
}
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.TestNamespace()}, view)
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.RootNamespace}, view)
if err != nil {
t.Fatal(err)
}
@ -773,7 +773,7 @@ func TestExpiration_RevokeByToken(t *testing.T) {
"secret_key": "abcd",
},
}
_, err := exp.Register(namespace.TestContext(), req, resp)
_, err := exp.Register(namespace.RootContext(nil), req, resp)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -784,7 +784,7 @@ func TestExpiration_RevokeByToken(t *testing.T) {
ID: "foobarbaz",
NamespaceID: namespace.RootNamespaceID,
}
if err := exp.RevokeByToken(namespace.TestContext(), te); err != nil {
if err := exp.RevokeByToken(namespace.RootContext(nil), te); err != nil {
t.Fatalf("err: %v", err)
}
@ -834,7 +834,7 @@ func TestExpiration_RevokeByToken_Blocking(t *testing.T) {
if err != nil {
t.Fatal(err)
}
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.TestNamespace()}, view)
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.RootNamespace}, view)
if err != nil {
t.Fatal(err)
}
@ -862,7 +862,7 @@ func TestExpiration_RevokeByToken_Blocking(t *testing.T) {
"secret_key": "abcd",
},
}
_, err := exp.Register(namespace.TestContext(), req, resp)
_, err := exp.Register(namespace.RootContext(nil), req, resp)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -873,7 +873,7 @@ func TestExpiration_RevokeByToken_Blocking(t *testing.T) {
ID: "foobarbaz",
NamespaceID: namespace.RootNamespaceID,
}
if err := exp.RevokeByToken(namespace.TestContext(), te); err != nil {
if err := exp.RevokeByToken(namespace.RootContext(nil), te); err != nil {
t.Fatalf("err: %v", err)
}
@ -934,7 +934,7 @@ func TestExpiration_RenewToken(t *testing.T) {
Path: "auth/token/login",
NamespaceID: namespace.RootNamespaceID,
}
err = exp.RegisterAuth(namespace.TestContext(), te, auth)
err = exp.RegisterAuth(namespace.RootContext(nil), te, auth)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -945,7 +945,7 @@ func TestExpiration_RenewToken(t *testing.T) {
Path: "auth/token/login",
NamespaceID: namespace.RootNamespaceID,
}
out, err := exp.RenewToken(namespace.TestContext(), &logical.Request{}, te, 0)
out, err := exp.RenewToken(namespace.RootContext(nil), &logical.Request{}, te, 0)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -965,7 +965,7 @@ func TestExpiration_RenewToken_period(t *testing.T) {
Period: time.Minute,
NamespaceID: namespace.RootNamespaceID,
}
if err := exp.tokenStore.create(namespace.TestContext(), root); err != nil {
if err := exp.tokenStore.create(namespace.RootContext(nil), root); err != nil {
t.Fatalf("err: %v", err)
}
@ -983,7 +983,7 @@ func TestExpiration_RenewToken_period(t *testing.T) {
Path: "auth/token/login",
NamespaceID: namespace.RootNamespaceID,
}
err := exp.RegisterAuth(namespace.TestContext(), te, auth)
err := exp.RegisterAuth(namespace.RootContext(nil), te, auth)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -994,7 +994,7 @@ func TestExpiration_RenewToken_period(t *testing.T) {
Path: "auth/token/login",
NamespaceID: namespace.RootNamespaceID,
}
out, err := exp.RenewToken(namespace.TestContext(), &logical.Request{}, te, 0)
out, err := exp.RenewToken(namespace.RootContext(nil), &logical.Request{}, te, 0)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -1036,7 +1036,7 @@ func TestExpiration_RenewToken_period_backend(t *testing.T) {
if err != nil {
t.Fatal(err)
}
err = exp.router.Mount(noop, "auth/foo/", &MountEntry{Path: "auth/foo/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.TestNamespace()}, view)
err = exp.router.Mount(noop, "auth/foo/", &MountEntry{Path: "auth/foo/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.RootNamespace}, view)
if err != nil {
t.Fatal(err)
}
@ -1056,7 +1056,7 @@ func TestExpiration_RenewToken_period_backend(t *testing.T) {
NamespaceID: namespace.RootNamespaceID,
}
err = exp.RegisterAuth(namespace.TestContext(), te, auth)
err = exp.RegisterAuth(namespace.RootContext(nil), te, auth)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -1068,7 +1068,7 @@ func TestExpiration_RenewToken_period_backend(t *testing.T) {
Path: "auth/foo/login",
NamespaceID: namespace.RootNamespaceID,
}
resp, err := exp.RenewToken(namespace.TestContext(), &logical.Request{}, te, 0)
resp, err := exp.RenewToken(namespace.RootContext(nil), &logical.Request{}, te, 0)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -1081,7 +1081,7 @@ func TestExpiration_RenewToken_period_backend(t *testing.T) {
// Wait another 3 seconds. If period works correctly, this should not fail
time.Sleep(3 * time.Second)
resp, err = exp.RenewToken(namespace.TestContext(), &logical.Request{}, te, 0)
resp, err = exp.RenewToken(namespace.RootContext(nil), &logical.Request{}, te, 0)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -1113,7 +1113,7 @@ func TestExpiration_RenewToken_NotRenewable(t *testing.T) {
Path: "auth/foo/login",
NamespaceID: namespace.RootNamespaceID,
}
err = exp.RegisterAuth(namespace.TestContext(), te, auth)
err = exp.RegisterAuth(namespace.RootContext(nil), te, auth)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -1124,7 +1124,7 @@ func TestExpiration_RenewToken_NotRenewable(t *testing.T) {
Path: "auth/github/login",
NamespaceID: namespace.RootNamespaceID,
}
resp, err := exp.RenewToken(namespace.TestContext(), &logical.Request{}, te, 0)
resp, err := exp.RenewToken(namespace.RootContext(nil), &logical.Request{}, te, 0)
if err != nil && (err != logical.ErrInvalidRequest || (resp != nil && resp.IsError() && resp.Error().Error() != "invalid lease ID")) {
t.Fatalf("bad: err:%v resp:%#v", err, resp)
}
@ -1143,7 +1143,7 @@ func TestExpiration_Renew(t *testing.T) {
if err != nil {
t.Fatal(err)
}
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.TestNamespace()}, view)
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.RootNamespace}, view)
if err != nil {
t.Fatal(err)
}
@ -1167,7 +1167,7 @@ func TestExpiration_Renew(t *testing.T) {
},
}
id, err := exp.Register(namespace.TestContext(), req, resp)
id, err := exp.Register(namespace.RootContext(nil), req, resp)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -1184,7 +1184,7 @@ func TestExpiration_Renew(t *testing.T) {
},
}
out, err := exp.Renew(namespace.TestContext(), id, 0)
out, err := exp.Renew(namespace.RootContext(nil), id, 0)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -1214,7 +1214,7 @@ func TestExpiration_Renew_NotRenewable(t *testing.T) {
if err != nil {
t.Fatal(err)
}
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.TestNamespace()}, view)
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.RootNamespace}, view)
if err != nil {
t.Fatal(err)
}
@ -1238,12 +1238,12 @@ func TestExpiration_Renew_NotRenewable(t *testing.T) {
},
}
id, err := exp.Register(namespace.TestContext(), req, resp)
id, err := exp.Register(namespace.RootContext(nil), req, resp)
if err != nil {
t.Fatalf("err: %v", err)
}
_, err = exp.Renew(namespace.TestContext(), id, 0)
_, err = exp.Renew(namespace.RootContext(nil), id, 0)
if err.Error() != "lease is not renewable" {
t.Fatalf("err: %v", err)
}
@ -1265,7 +1265,7 @@ func TestExpiration_Renew_RevokeOnExpire(t *testing.T) {
if err != nil {
t.Fatal(err)
}
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.TestNamespace()}, view)
err = exp.router.Mount(noop, "prod/aws/", &MountEntry{Path: "prod/aws/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.RootNamespace}, view)
if err != nil {
t.Fatal(err)
}
@ -1289,7 +1289,7 @@ func TestExpiration_Renew_RevokeOnExpire(t *testing.T) {
},
}
id, err := exp.Register(namespace.TestContext(), req, resp)
id, err := exp.Register(namespace.RootContext(nil), req, resp)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -1306,7 +1306,7 @@ func TestExpiration_Renew_RevokeOnExpire(t *testing.T) {
},
}
_, err = exp.Renew(namespace.TestContext(), id, 0)
_, err = exp.Renew(namespace.RootContext(nil), id, 0)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -1342,7 +1342,7 @@ func TestExpiration_revokeEntry(t *testing.T) {
if err != nil {
t.Fatal(err)
}
err = exp.router.Mount(noop, "foo/bar/", &MountEntry{Path: "foo/bar/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.TestNamespace()}, view)
err = exp.router.Mount(noop, "foo/bar/", &MountEntry{Path: "foo/bar/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.RootNamespace}, view)
if err != nil {
t.Fatal(err)
}
@ -1360,10 +1360,10 @@ func TestExpiration_revokeEntry(t *testing.T) {
},
IssueTime: time.Now(),
ExpireTime: time.Now(),
namespace: namespace.TestNamespace(),
namespace: namespace.RootNamespace,
}
err = exp.revokeEntry(namespace.TestContext(), le)
err = exp.revokeEntry(namespace.RootContext(nil), le)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -1412,18 +1412,18 @@ func TestExpiration_revokeEntry_token(t *testing.T) {
Path: "foo/bar",
IssueTime: time.Now(),
ExpireTime: time.Now(),
namespace: namespace.TestNamespace(),
namespace: namespace.RootNamespace,
}
if err := exp.persistEntry(namespace.TestContext(), le); err != nil {
if err := exp.persistEntry(namespace.RootContext(nil), le); err != nil {
t.Fatalf("error persisting entry: %v", err)
}
if err := exp.createIndexByToken(namespace.TestContext(), le, le.ClientToken); err != nil {
if err := exp.createIndexByToken(namespace.RootContext(nil), le, le.ClientToken); err != nil {
t.Fatalf("error creating secondary index: %v", err)
}
exp.updatePending(le, le.Secret.LeaseTotal())
indexEntry, err := exp.indexByToken(namespace.TestContext(), le)
indexEntry, err := exp.indexByToken(namespace.RootContext(nil), le)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -1431,14 +1431,14 @@ func TestExpiration_revokeEntry_token(t *testing.T) {
t.Fatalf("err: should have found a secondary index entry")
}
err = exp.revokeEntry(namespace.TestContext(), le)
err = exp.revokeEntry(namespace.RootContext(nil), le)
if err != nil {
t.Fatalf("err: %v", err)
}
time.Sleep(300 * time.Millisecond)
out, err := exp.tokenStore.Lookup(namespace.TestContext(), le.ClientToken)
out, err := exp.tokenStore.Lookup(namespace.RootContext(nil), le.ClientToken)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -1446,7 +1446,7 @@ func TestExpiration_revokeEntry_token(t *testing.T) {
t.Fatalf("bad: %v", out)
}
indexEntry, err = exp.indexByToken(namespace.TestContext(), le)
indexEntry, err = exp.indexByToken(namespace.RootContext(nil), le)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -1477,7 +1477,7 @@ func TestExpiration_renewEntry(t *testing.T) {
if err != nil {
t.Fatal(err)
}
err = exp.router.Mount(noop, "foo/bar/", &MountEntry{Path: "foo/bar/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.TestNamespace()}, view)
err = exp.router.Mount(noop, "foo/bar/", &MountEntry{Path: "foo/bar/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.RootNamespace}, view)
if err != nil {
t.Fatal(err)
}
@ -1495,10 +1495,10 @@ func TestExpiration_renewEntry(t *testing.T) {
},
IssueTime: time.Now(),
ExpireTime: time.Now(),
namespace: namespace.TestNamespace(),
namespace: namespace.RootNamespace,
}
resp, err := exp.renewEntry(namespace.TestContext(), le, 0)
resp, err := exp.renewEntry(namespace.RootContext(nil), le, 0)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -1543,7 +1543,7 @@ func TestExpiration_revokeEntry_rejected(t *testing.T) {
if err != nil {
t.Fatal(err)
}
err = exp.router.Mount(noop, "foo/bar/", &MountEntry{Path: "foo/bar/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.TestNamespace()}, view)
err = exp.router.Mount(noop, "foo/bar/", &MountEntry{Path: "foo/bar/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.RootNamespace}, view)
if err != nil {
t.Fatal(err)
}
@ -1561,15 +1561,15 @@ func TestExpiration_revokeEntry_rejected(t *testing.T) {
},
IssueTime: time.Now(),
ExpireTime: time.Now().Add(time.Minute),
namespace: namespace.TestNamespace(),
namespace: namespace.RootNamespace,
}
err = exp.persistEntry(namespace.TestContext(), le)
err = exp.persistEntry(namespace.RootContext(nil), le)
if err != nil {
t.Fatal(err)
}
err = exp.LazyRevoke(namespace.TestContext(), le.LeaseID)
err = exp.LazyRevoke(namespace.RootContext(nil), le.LeaseID)
if err != nil {
t.Fatal(err)
}
@ -1602,7 +1602,7 @@ func TestExpiration_revokeEntry_rejected(t *testing.T) {
// Now let the revocation actually process
time.Sleep(1 * time.Second)
le, err = exp.FetchLeaseTimes(namespace.TestContext(), le.LeaseID)
le, err = exp.FetchLeaseTimes(namespace.RootContext(nil), le.LeaseID)
if err != nil {
t.Fatal(err)
}
@ -1630,7 +1630,7 @@ func TestExpiration_renewAuthEntry(t *testing.T) {
if err != nil {
t.Fatal(err)
}
err = exp.router.Mount(noop, "auth/foo/", &MountEntry{Path: "auth/foo/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.TestNamespace()}, view)
err = exp.router.Mount(noop, "auth/foo/", &MountEntry{Path: "auth/foo/", Type: "noop", UUID: meUUID, Accessor: "noop-accessor", namespace: namespace.RootNamespace}, view)
if err != nil {
t.Fatal(err)
}
@ -1649,10 +1649,10 @@ func TestExpiration_renewAuthEntry(t *testing.T) {
},
IssueTime: time.Now(),
ExpireTime: time.Now().Add(time.Minute),
namespace: namespace.TestNamespace(),
namespace: namespace.RootNamespace,
}
resp, err := exp.renewAuthEntry(namespace.TestContext(), &logical.Request{}, le, 0)
resp, err := exp.renewAuthEntry(namespace.RootContext(nil), &logical.Request{}, le, 0)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -1693,13 +1693,13 @@ func TestExpiration_PersistLoadDelete(t *testing.T) {
IssueTime: lastTime,
ExpireTime: lastTime,
LastRenewalTime: lastTime,
namespace: namespace.TestNamespace(),
namespace: namespace.RootNamespace,
}
if err := exp.persistEntry(namespace.TestContext(), le); err != nil {
if err := exp.persistEntry(namespace.RootContext(nil), le); err != nil {
t.Fatalf("err: %v", err)
}
out, err := exp.loadEntry(namespace.TestContext(), "foo/bar/1234")
out, err := exp.loadEntry(namespace.RootContext(nil), "foo/bar/1234")
if err != nil {
t.Fatalf("err: %v", err)
}
@ -1715,12 +1715,12 @@ func TestExpiration_PersistLoadDelete(t *testing.T) {
t.Fatalf("bad: expected:\n%#v\nactual:\n%#v", le, out)
}
err = exp.deleteEntry(namespace.TestContext(), le)
err = exp.deleteEntry(namespace.RootContext(nil), le)
if err != nil {
t.Fatalf("err: %v", err)
}
out, err = exp.loadEntry(namespace.TestContext(), "foo/bar/1234")
out, err = exp.loadEntry(namespace.RootContext(nil), "foo/bar/1234")
if err != nil {
t.Fatalf("err: %v", err)
}
@ -1803,7 +1803,7 @@ func TestExpiration_RevokeForce(t *testing.T) {
Accessor: "badrenewaccessor",
}
err := core.mount(namespace.TestContext(), me)
err := core.mount(namespace.RootContext(nil), me)
if err != nil {
t.Fatal(err)
}
@ -1815,7 +1815,7 @@ func TestExpiration_RevokeForce(t *testing.T) {
}
req.SetTokenEntry(&logical.TokenEntry{ID: root, NamespaceID: "root", Policies: []string{"root"}})
resp, err := core.HandleRequest(namespace.TestContext(), req)
resp, err := core.HandleRequest(namespace.RootContext(nil), req)
if err != nil {
t.Fatal(err)
}
@ -1829,13 +1829,13 @@ func TestExpiration_RevokeForce(t *testing.T) {
req.Operation = logical.UpdateOperation
req.Path = "sys/revoke-prefix/badrenew/creds"
resp, err = core.HandleRequest(namespace.TestContext(), req)
resp, err = core.HandleRequest(namespace.RootContext(nil), req)
if err == nil {
t.Fatal("expected error")
}
req.Path = "sys/revoke-force/badrenew/creds"
resp, err = core.HandleRequest(namespace.TestContext(), req)
resp, err = core.HandleRequest(namespace.RootContext(nil), req)
if err != nil {
t.Fatalf("got error: %s", err)
}
@ -1852,7 +1852,7 @@ func TestExpiration_RevokeForceSingle(t *testing.T) {
Accessor: "badrenewaccessor",
}
err := core.mount(namespace.TestContext(), me)
err := core.mount(namespace.RootContext(nil), me)
if err != nil {
t.Fatal(err)
}
@ -1864,7 +1864,7 @@ func TestExpiration_RevokeForceSingle(t *testing.T) {
}
req.SetTokenEntry(&logical.TokenEntry{ID: root, NamespaceID: "root", Policies: []string{"root"}})
resp, err := core.HandleRequest(namespace.TestContext(), req)
resp, err := core.HandleRequest(namespace.RootContext(nil), req)
if err != nil {
t.Fatal(err)
}
@ -1879,7 +1879,7 @@ func TestExpiration_RevokeForceSingle(t *testing.T) {
req.Operation = logical.UpdateOperation
req.Path = "sys/leases/lookup"
req.Data = map[string]interface{}{"lease_id": leaseID}
resp, err = core.HandleRequest(namespace.TestContext(), req)
resp, err = core.HandleRequest(namespace.RootContext(nil), req)
if err != nil {
t.Fatal(err)
}
@ -1892,20 +1892,20 @@ func TestExpiration_RevokeForceSingle(t *testing.T) {
req.Path = "sys/revoke-prefix/" + leaseID
resp, err = core.HandleRequest(namespace.TestContext(), req)
resp, err = core.HandleRequest(namespace.RootContext(nil), req)
if err == nil {
t.Fatal("expected error")
}
req.Path = "sys/revoke-force/" + leaseID
resp, err = core.HandleRequest(namespace.TestContext(), req)
resp, err = core.HandleRequest(namespace.RootContext(nil), req)
if err != nil {
t.Fatalf("got error: %s", err)
}
req.Path = "sys/leases/lookup"
req.Data = map[string]interface{}{"lease_id": leaseID}
resp, err = core.HandleRequest(namespace.TestContext(), req)
resp, err = core.HandleRequest(namespace.RootContext(nil), req)
if err == nil {
t.Fatal("expected error")
}
@ -1945,7 +1945,7 @@ func badRenewFactory(ctx context.Context, conf *logical.BackendConfig) (logical.
},
}
err := be.Setup(namespace.TestContext(), conf)
err := be.Setup(namespace.RootContext(nil), conf)
if err != nil {
return nil, err
}

View File

@ -342,8 +342,8 @@ func TestIdentityStore_EntityCreateUpdate(t *testing.T) {
func TestIdentityStore_CloneImmutability(t *testing.T) {
alias := &identity.Alias{
ID: "testaliasid",
Name: "testaliasname",
ID: "testaliasid",
Name: "testaliasname",
MergedFromCanonicalIDs: []string{"entityid1"},
}
@ -544,7 +544,7 @@ func TestIdentityStore_LoadingEntities(t *testing.T) {
}
// Identity store will be mounted by now, just fetch it from router
identitystore := c.router.MatchingBackend(namespace.TestContext(), "identity/")
identitystore := c.router.MatchingBackend(namespace.RootContext(nil), "identity/")
if identitystore == nil {
t.Fatalf("failed to fetch identity store from router")
}

View File

@ -17,7 +17,7 @@ import (
func TestIdentityStore_EntityIDPassthrough(t *testing.T) {
// Enable GitHub auth and initialize
ctx := namespace.TestContext()
ctx := namespace.RootContext(nil)
is, ghAccessor, core := testIdentityStoreWithGithubAuth(ctx, t)
alias := &logical.Alias{
MountType: "github",
@ -322,7 +322,7 @@ func TestIdentityStore_MergeConflictingAliases(t *testing.T) {
Description: "github auth",
}
err = c.enableCredential(namespace.TestContext(), meGH)
err = c.enableCredential(namespace.RootContext(nil), meGH)
if err != nil {
t.Fatal(err)
}
@ -391,7 +391,7 @@ func TestIdentityStore_MergeConflictingAliases(t *testing.T) {
t.Fatal("still sealed")
}
newEntity, err := c.identityStore.CreateOrFetchEntity(namespace.TestContext(), &logical.Alias{
newEntity, err := c.identityStore.CreateOrFetchEntity(namespace.RootContext(nil), &logical.Alias{
MountAccessor: meGH.Accessor,
MountType: "github",
Name: "githubuser",

File diff suppressed because it is too large Load Diff

View File

@ -33,7 +33,7 @@ func TestMount_ReadOnlyViewDuringMount(t *testing.T) {
Path: "foo",
Type: "noop",
}
err := c.mount(namespace.TestContext(), me)
err := c.mount(namespace.RootContext(nil), me)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -75,12 +75,12 @@ func TestCore_Mount(t *testing.T) {
Path: "foo",
Type: "kv",
}
err := c.mount(namespace.TestContext(), me)
err := c.mount(namespace.RootContext(nil), me)
if err != nil {
t.Fatalf("err: %v", err)
}
match := c.router.MatchingMount(namespace.TestContext(), "foo/bar")
match := c.router.MatchingMount(namespace.RootContext(nil), "foo/bar")
if match != "foo/" {
t.Fatalf("missing mount")
}
@ -142,7 +142,7 @@ func TestCore_Mount_Local(t *testing.T) {
}
// Both should set up successfully
err := c.setupMounts(namespace.TestContext())
err := c.setupMounts(namespace.RootContext(nil))
if err != nil {
t.Fatal(err)
}
@ -213,12 +213,12 @@ func TestCore_Mount_Local(t *testing.T) {
func TestCore_Unmount(t *testing.T) {
c, keys, _ := TestCoreUnsealed(t)
err := c.unmount(namespace.TestContext(), "secret")
err := c.unmount(namespace.RootContext(nil), "secret")
if err != nil {
t.Fatalf("err: %v", err)
}
match := c.router.MatchingMount(namespace.TestContext(), "secret/foo")
match := c.router.MatchingMount(namespace.RootContext(nil), "secret/foo")
if match != "" {
t.Fatalf("backend present")
}
@ -260,12 +260,12 @@ func TestCore_Unmount_Cleanup(t *testing.T) {
Path: "test/",
Type: "noop",
}
if err := c.mount(namespace.TestContext(), me); err != nil {
if err := c.mount(namespace.RootContext(nil), me); err != nil {
t.Fatalf("err: %v", err)
}
// Store the view
view := c.router.MatchingStorageByAPIPath(namespace.TestContext(), "test/")
view := c.router.MatchingStorageByAPIPath(namespace.RootContext(nil), "test/")
// Inject data
se := &logical.StorageEntry{
@ -296,7 +296,7 @@ func TestCore_Unmount_Cleanup(t *testing.T) {
ClientToken: root,
}
r.SetTokenEntry(&logical.TokenEntry{ID: root, NamespaceID: "root", Policies: []string{"root"}})
resp, err := c.HandleRequest(namespace.TestContext(), r)
resp, err := c.HandleRequest(namespace.RootContext(nil), r)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -305,7 +305,7 @@ func TestCore_Unmount_Cleanup(t *testing.T) {
}
// Unmount, this should cleanup
if err := c.unmount(namespace.TestContext(), "test/"); err != nil {
if err := c.unmount(namespace.RootContext(nil), "test/"); err != nil {
t.Fatalf("err: %v", err)
}
@ -334,12 +334,12 @@ func TestCore_Unmount_Cleanup(t *testing.T) {
func TestCore_Remount(t *testing.T) {
c, keys, _ := TestCoreUnsealed(t)
err := c.remount(namespace.TestContext(), "secret", "foo")
err := c.remount(namespace.RootContext(nil), "secret", "foo")
if err != nil {
t.Fatalf("err: %v", err)
}
match := c.router.MatchingMount(namespace.TestContext(), "foo/bar")
match := c.router.MatchingMount(namespace.RootContext(nil), "foo/bar")
if match != "foo/" {
t.Fatalf("failed remount")
}
@ -381,12 +381,12 @@ func TestCore_Remount_Cleanup(t *testing.T) {
Path: "test/",
Type: "noop",
}
if err := c.mount(namespace.TestContext(), me); err != nil {
if err := c.mount(namespace.RootContext(nil), me); err != nil {
t.Fatalf("err: %v", err)
}
// Store the view
view := c.router.MatchingStorageByAPIPath(namespace.TestContext(), "test/")
view := c.router.MatchingStorageByAPIPath(namespace.RootContext(nil), "test/")
// Inject data
se := &logical.StorageEntry{
@ -417,7 +417,7 @@ func TestCore_Remount_Cleanup(t *testing.T) {
ClientToken: root,
}
r.SetTokenEntry(&logical.TokenEntry{ID: root, NamespaceID: "root", Policies: []string{"root"}})
resp, err := c.HandleRequest(namespace.TestContext(), r)
resp, err := c.HandleRequest(namespace.RootContext(nil), r)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -426,7 +426,7 @@ func TestCore_Remount_Cleanup(t *testing.T) {
}
// Remount, this should cleanup
if err := c.remount(namespace.TestContext(), "test/", "new/"); err != nil {
if err := c.remount(namespace.RootContext(nil), "test/", "new/"); err != nil {
t.Fatalf("err: %v", err)
}
@ -455,7 +455,7 @@ func TestCore_Remount_Cleanup(t *testing.T) {
func TestCore_Remount_Protected(t *testing.T) {
c, _, _ := TestCoreUnsealed(t)
err := c.remount(namespace.TestContext(), "sys", "foo")
err := c.remount(namespace.RootContext(nil), "sys", "foo")
if err.Error() != `cannot remount "sys/"` {
t.Fatalf("err: %v", err)
}
@ -481,7 +481,7 @@ func TestCore_MountTable_UpgradeToTyped(t *testing.T) {
Path: "foo",
Type: "noop",
}
err := c.enableAudit(namespace.TestContext(), me, true)
err := c.enableAudit(namespace.RootContext(nil), me, true)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -495,7 +495,7 @@ func TestCore_MountTable_UpgradeToTyped(t *testing.T) {
Path: "foo",
Type: "noop",
}
err = c.enableCredential(namespace.TestContext(), me)
err = c.enableCredential(namespace.RootContext(nil), me)
if err != nil {
t.Fatalf("err: %v", err)
}

View File

@ -27,7 +27,7 @@ func mockRollback(t *testing.T) (*RollbackManager, *NoopBackend) {
&MountEntry{
Path: "foo",
NamespaceID: namespace.RootNamespaceID,
namespace: namespace.TestNamespace(),
namespace: namespace.RootNamespace,
},
}
meUUID, err := uuid.GenerateUUID()
@ -35,7 +35,7 @@ func mockRollback(t *testing.T) (*RollbackManager, *NoopBackend) {
t.Fatal(err)
}
if err := router.Mount(backend, "foo", &MountEntry{UUID: meUUID, Accessor: "noopaccessor", NamespaceID: namespace.RootNamespaceID, namespace: namespace.TestNamespace()}, view); err != nil {
if err := router.Mount(backend, "foo", &MountEntry{UUID: meUUID, Accessor: "noopaccessor", NamespaceID: namespace.RootNamespaceID, namespace: namespace.RootNamespace}, view); err != nil {
t.Fatalf("err: %s", err)
}
@ -90,7 +90,7 @@ func TestRollbackManager_Join(t *testing.T) {
errCh := make(chan error, 3)
go func() {
defer wg.Done()
err := m.Rollback(namespace.TestContext(), "foo")
err := m.Rollback(namespace.RootContext(nil), "foo")
if err != nil {
errCh <- err
}
@ -98,7 +98,7 @@ func TestRollbackManager_Join(t *testing.T) {
go func() {
defer wg.Done()
err := m.Rollback(namespace.TestContext(), "foo")
err := m.Rollback(namespace.RootContext(nil), "foo")
if err != nil {
errCh <- err
}
@ -106,7 +106,7 @@ func TestRollbackManager_Join(t *testing.T) {
go func() {
defer wg.Done()
err := m.Rollback(namespace.TestContext(), "foo")
err := m.Rollback(namespace.RootContext(nil), "foo")
if err != nil {
errCh <- err
}

View File

@ -122,7 +122,7 @@ func TestRouter_Mount(t *testing.T) {
UUID: meUUID,
Accessor: "awsaccessor",
NamespaceID: namespace.RootNamespaceID,
namespace: namespace.TestNamespace(),
namespace: namespace.RootNamespace,
}
n := &NoopBackend{}
@ -136,7 +136,7 @@ func TestRouter_Mount(t *testing.T) {
t.Fatal(err)
}
err = r.Mount(n, "prod/aws/", &MountEntry{UUID: meUUID, NamespaceID: namespace.RootNamespaceID, namespace: namespace.TestNamespace()}, view)
err = r.Mount(n, "prod/aws/", &MountEntry{UUID: meUUID, NamespaceID: namespace.RootNamespaceID, namespace: namespace.RootNamespace}, view)
if !strings.Contains(err.Error(), "cannot mount under existing mount") {
t.Fatalf("err: %v", err)
}
@ -146,19 +146,19 @@ func TestRouter_Mount(t *testing.T) {
t.Fatal(err)
}
if path := r.MatchingMount(namespace.TestContext(), "prod/aws/foo"); path != "prod/aws/" {
if path := r.MatchingMount(namespace.RootContext(nil), "prod/aws/foo"); path != "prod/aws/" {
t.Fatalf("bad: %s", path)
}
if v := r.MatchingStorageByAPIPath(namespace.TestContext(), "prod/aws/foo"); v.(*BarrierView) != view {
if v := r.MatchingStorageByAPIPath(namespace.RootContext(nil), "prod/aws/foo"); v.(*BarrierView) != view {
t.Fatalf("bad: %v", v)
}
if path := r.MatchingMount(namespace.TestContext(), "stage/aws/foo"); path != "" {
if path := r.MatchingMount(namespace.RootContext(nil), "stage/aws/foo"); path != "" {
t.Fatalf("bad: %s", path)
}
if v := r.MatchingStorageByAPIPath(namespace.TestContext(), "stage/aws/foo"); v != nil {
if v := r.MatchingStorageByAPIPath(namespace.RootContext(nil), "stage/aws/foo"); v != nil {
t.Fatalf("bad: %v", v)
}
@ -167,7 +167,7 @@ func TestRouter_Mount(t *testing.T) {
t.Fatalf("failed to fetch mount entry using its ID; expected: %#v\n actual: %#v\n", mountEntry, mountEntryFetched)
}
_, mount, prefix, ok := r.MatchingAPIPrefixByStoragePath(namespace.TestContext(), "logical/foo")
_, mount, prefix, ok := r.MatchingAPIPrefixByStoragePath(namespace.RootContext(nil), "logical/foo")
if !ok {
t.Fatalf("missing storage prefix")
}
@ -181,7 +181,7 @@ func TestRouter_Mount(t *testing.T) {
req.SetTokenEntry(&logical.TokenEntry{
ID: "foo",
})
resp, err := r.Route(namespace.TestContext(), req)
resp, err := r.Route(namespace.RootContext(nil), req)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -202,10 +202,10 @@ func TestRouter_Mount(t *testing.T) {
UUID: meUUID,
Accessor: "prodaccessor",
NamespaceID: namespace.RootNamespaceID,
namespace: namespace.TestNamespace(),
namespace: namespace.RootNamespace,
}
if r.MountConflict(namespace.TestContext(), "prod/aws/") == "" {
if r.MountConflict(namespace.RootContext(nil), "prod/aws/") == "" {
t.Fatalf("bad: prod/aws/")
}
@ -214,7 +214,7 @@ func TestRouter_Mount(t *testing.T) {
if err != nil {
t.Fatalf("err: %v", err)
}
if r.MountConflict(namespace.TestContext(), "prod/test") == "" {
if r.MountConflict(namespace.RootContext(nil), "prod/test") == "" {
t.Fatalf("bad: prod/test/")
}
}
@ -234,7 +234,7 @@ func TestRouter_MountCredential(t *testing.T) {
UUID: meUUID,
Accessor: "awsaccessor",
NamespaceID: namespace.RootNamespaceID,
namespace: namespace.TestNamespace(),
namespace: namespace.RootNamespace,
}
n := &NoopBackend{}
@ -248,24 +248,24 @@ func TestRouter_MountCredential(t *testing.T) {
t.Fatal(err)
}
err = r.Mount(n, "auth/aws/", &MountEntry{UUID: meUUID, NamespaceID: namespace.RootNamespaceID, namespace: namespace.TestNamespace()}, view)
err = r.Mount(n, "auth/aws/", &MountEntry{UUID: meUUID, NamespaceID: namespace.RootNamespaceID, namespace: namespace.RootNamespace}, view)
if !strings.Contains(err.Error(), "cannot mount under existing mount") {
t.Fatalf("err: %v", err)
}
if path := r.MatchingMount(namespace.TestContext(), "auth/aws/foo"); path != "auth/aws/" {
if path := r.MatchingMount(namespace.RootContext(nil), "auth/aws/foo"); path != "auth/aws/" {
t.Fatalf("bad: %s", path)
}
if v := r.MatchingStorageByAPIPath(namespace.TestContext(), "auth/aws/foo"); v.(*BarrierView) != view {
if v := r.MatchingStorageByAPIPath(namespace.RootContext(nil), "auth/aws/foo"); v.(*BarrierView) != view {
t.Fatalf("bad: %v", v)
}
if path := r.MatchingMount(namespace.TestContext(), "auth/stage/aws/foo"); path != "" {
if path := r.MatchingMount(namespace.RootContext(nil), "auth/stage/aws/foo"); path != "" {
t.Fatalf("bad: %s", path)
}
if v := r.MatchingStorageByAPIPath(namespace.TestContext(), "auth/stage/aws/foo"); v != nil {
if v := r.MatchingStorageByAPIPath(namespace.RootContext(nil), "auth/stage/aws/foo"); v != nil {
t.Fatalf("bad: %v", v)
}
@ -274,7 +274,7 @@ func TestRouter_MountCredential(t *testing.T) {
t.Fatalf("failed to fetch mount entry using its ID; expected: %#v\n actual: %#v\n", mountEntry, mountEntryFetched)
}
_, mount, prefix, ok := r.MatchingAPIPrefixByStoragePath(namespace.TestContext(), "auth/foo")
_, mount, prefix, ok := r.MatchingAPIPrefixByStoragePath(namespace.RootContext(nil), "auth/foo")
if !ok {
t.Fatalf("missing storage prefix")
}
@ -285,7 +285,7 @@ func TestRouter_MountCredential(t *testing.T) {
req := &logical.Request{
Path: "auth/aws/foo",
}
resp, err := r.Route(namespace.TestContext(), req)
resp, err := r.Route(namespace.RootContext(nil), req)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -309,12 +309,12 @@ func TestRouter_Unmount(t *testing.T) {
t.Fatal(err)
}
n := &NoopBackend{}
err = r.Mount(n, "prod/aws/", &MountEntry{Path: "prod/aws/", UUID: meUUID, Accessor: "awsaccessor", NamespaceID: namespace.RootNamespaceID, namespace: namespace.TestNamespace()}, view)
err = r.Mount(n, "prod/aws/", &MountEntry{Path: "prod/aws/", UUID: meUUID, Accessor: "awsaccessor", NamespaceID: namespace.RootNamespaceID, namespace: namespace.RootNamespace}, view)
if err != nil {
t.Fatalf("err: %v", err)
}
err = r.Unmount(namespace.TestContext(), "prod/aws/")
err = r.Unmount(namespace.RootContext(nil), "prod/aws/")
if err != nil {
t.Fatalf("err: %v", err)
}
@ -322,12 +322,12 @@ func TestRouter_Unmount(t *testing.T) {
req := &logical.Request{
Path: "prod/aws/foo",
}
_, err = r.Route(namespace.TestContext(), req)
_, err = r.Route(namespace.RootContext(nil), req)
if !strings.Contains(err.Error(), "unsupported path") {
t.Fatalf("err: %v", err)
}
if _, _, _, ok := r.MatchingAPIPrefixByStoragePath(namespace.TestContext(), "logical/foo"); ok {
if _, _, _, ok := r.MatchingAPIPrefixByStoragePath(namespace.RootContext(nil), "logical/foo"); ok {
t.Fatalf("should not have matching storage prefix")
}
}
@ -342,19 +342,19 @@ func TestRouter_Remount(t *testing.T) {
t.Fatal(err)
}
n := &NoopBackend{}
me := &MountEntry{Path: "prod/aws/", UUID: meUUID, Accessor: "awsaccessor", NamespaceID: namespace.RootNamespaceID, namespace: namespace.TestNamespace()}
me := &MountEntry{Path: "prod/aws/", UUID: meUUID, Accessor: "awsaccessor", NamespaceID: namespace.RootNamespaceID, namespace: namespace.RootNamespace}
err = r.Mount(n, "prod/aws/", me, view)
if err != nil {
t.Fatalf("err: %v", err)
}
me.Path = "stage/aws/"
err = r.Remount(namespace.TestContext(), "prod/aws/", "stage/aws/")
err = r.Remount(namespace.RootContext(nil), "prod/aws/", "stage/aws/")
if err != nil {
t.Fatalf("err: %v", err)
}
err = r.Remount(namespace.TestContext(), "prod/aws/", "stage/aws/")
err = r.Remount(namespace.RootContext(nil), "prod/aws/", "stage/aws/")
if !strings.Contains(err.Error(), "no mount at") {
t.Fatalf("err: %v", err)
}
@ -362,7 +362,7 @@ func TestRouter_Remount(t *testing.T) {
req := &logical.Request{
Path: "prod/aws/foo",
}
_, err = r.Route(namespace.TestContext(), req)
_, err = r.Route(namespace.RootContext(nil), req)
if !strings.Contains(err.Error(), "unsupported path") {
t.Fatalf("err: %v", err)
}
@ -370,7 +370,7 @@ func TestRouter_Remount(t *testing.T) {
req = &logical.Request{
Path: "stage/aws/foo",
}
_, err = r.Route(namespace.TestContext(), req)
_, err = r.Route(namespace.RootContext(nil), req)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -381,7 +381,7 @@ func TestRouter_Remount(t *testing.T) {
}
// Check the resolve from storage still works
_, mount, prefix, _ := r.MatchingAPIPrefixByStoragePath(namespace.TestContext(), "logical/foobar")
_, mount, prefix, _ := r.MatchingAPIPrefixByStoragePath(namespace.RootContext(nil), "logical/foobar")
if mount != "stage/aws/" {
t.Fatalf("bad mount: %s", mount)
}
@ -405,7 +405,7 @@ func TestRouter_RootPath(t *testing.T) {
"policy/*",
},
}
err = r.Mount(n, "prod/aws/", &MountEntry{UUID: meUUID, Accessor: "awsaccessor", NamespaceID: namespace.RootNamespaceID, namespace: namespace.TestNamespace()}, view)
err = r.Mount(n, "prod/aws/", &MountEntry{UUID: meUUID, Accessor: "awsaccessor", NamespaceID: namespace.RootNamespaceID, namespace: namespace.RootNamespace}, view)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -425,7 +425,7 @@ func TestRouter_RootPath(t *testing.T) {
}
for _, tc := range tcases {
out := r.RootPath(namespace.TestContext(), tc.path)
out := r.RootPath(namespace.RootContext(nil), tc.path)
if out != tc.expect {
t.Fatalf("bad: path: %s expect: %v got %v", tc.path, tc.expect, out)
}
@ -447,7 +447,7 @@ func TestRouter_LoginPath(t *testing.T) {
"oauth/*",
},
}
err = r.Mount(n, "auth/foo/", &MountEntry{UUID: meUUID, Accessor: "authfooaccessor", NamespaceID: namespace.RootNamespaceID, namespace: namespace.TestNamespace()}, view)
err = r.Mount(n, "auth/foo/", &MountEntry{UUID: meUUID, Accessor: "authfooaccessor", NamespaceID: namespace.RootNamespaceID, namespace: namespace.RootNamespace}, view)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -465,7 +465,7 @@ func TestRouter_LoginPath(t *testing.T) {
}
for _, tc := range tcases {
out := r.LoginPath(namespace.TestContext(), tc.path)
out := r.LoginPath(namespace.RootContext(nil), tc.path)
if out != tc.expect {
t.Fatalf("bad: path: %s expect: %v got %v", tc.path, tc.expect, out)
}
@ -482,12 +482,12 @@ func TestRouter_Taint(t *testing.T) {
t.Fatal(err)
}
n := &NoopBackend{}
err = r.Mount(n, "prod/aws/", &MountEntry{UUID: meUUID, Accessor: "awsaccessor", NamespaceID: namespace.RootNamespaceID, namespace: namespace.TestNamespace()}, view)
err = r.Mount(n, "prod/aws/", &MountEntry{UUID: meUUID, Accessor: "awsaccessor", NamespaceID: namespace.RootNamespaceID, namespace: namespace.RootNamespace}, view)
if err != nil {
t.Fatalf("err: %v", err)
}
err = r.Taint(namespace.TestContext(), "prod/aws/")
err = r.Taint(namespace.RootContext(nil), "prod/aws/")
if err != nil {
t.Fatalf("err: %v", err)
}
@ -496,20 +496,20 @@ func TestRouter_Taint(t *testing.T) {
Operation: logical.ReadOperation,
Path: "prod/aws/foo",
}
_, err = r.Route(namespace.TestContext(), req)
_, err = r.Route(namespace.RootContext(nil), req)
if err.Error() != "unsupported path" {
t.Fatalf("err: %v", err)
}
// Rollback and Revoke should work
req.Operation = logical.RollbackOperation
_, err = r.Route(namespace.TestContext(), req)
_, err = r.Route(namespace.RootContext(nil), req)
if err != nil {
t.Fatalf("err: %v", err)
}
req.Operation = logical.RevokeOperation
_, err = r.Route(namespace.TestContext(), req)
_, err = r.Route(namespace.RootContext(nil), req)
if err != nil {
t.Fatalf("err: %v", err)
}
@ -525,17 +525,17 @@ func TestRouter_Untaint(t *testing.T) {
t.Fatal(err)
}
n := &NoopBackend{}
err = r.Mount(n, "prod/aws/", &MountEntry{UUID: meUUID, Accessor: "awsaccessor", NamespaceID: namespace.RootNamespaceID, namespace: namespace.TestNamespace()}, view)
err = r.Mount(n, "prod/aws/", &MountEntry{UUID: meUUID, Accessor: "awsaccessor", NamespaceID: namespace.RootNamespaceID, namespace: namespace.RootNamespace}, view)
if err != nil {
t.Fatalf("err: %v", err)
}
err = r.Taint(namespace.TestContext(), "prod/aws/")
err = r.Taint(namespace.RootContext(nil), "prod/aws/")
if err != nil {
t.Fatalf("err: %v", err)
}
err = r.Untaint(namespace.TestContext(), "prod/aws/")
err = r.Untaint(namespace.RootContext(nil), "prod/aws/")
if err != nil {
t.Fatalf("err: %v", err)
}
@ -544,7 +544,7 @@ func TestRouter_Untaint(t *testing.T) {
Operation: logical.ReadOperation,
Path: "prod/aws/foo",
}
_, err = r.Route(namespace.TestContext(), req)
_, err = r.Route(namespace.RootContext(nil), req)
if err != nil {
t.Fatalf("err: %v", err)
}

File diff suppressed because it is too large Load Diff