Files
threshold/internal/auth/testing.go
T
Jeff Mitchell 3c430678ae Fix test scope errors (#1029)
When using a disabled verifier context we were faking scope information. Due to other recent changes, this was now causing test errors. This adjusts that flow to actually query the DB, fixing tests and making them more like real code.
2021-03-25 03:15:43 -04:00

20 lines
663 B
Go

package auth
import (
"context"
"github.com/hashicorp/boundary/internal/servers/controller/common"
)
// DisabledAuthTestContext is meant for testing, and uses a context that has auth checking entirely disabled
func DisabledAuthTestContext(iamRepoFn common.IamRepoFactory, scopeId string, opt ...Option) context.Context {
reqInfo := RequestInfo{DisableAuthEntirely: true}
opts := getOpts(opt...)
reqInfo.scopeIdOverride = opts.withScopeId
if reqInfo.scopeIdOverride == "" {
reqInfo.scopeIdOverride = scopeId
}
reqInfo.userIdOverride = opts.withUserId
return NewVerifierContext(context.Background(), nil, iamRepoFn, nil, nil, opts.withKms, reqInfo)
}