Documentation
¶
Index ¶
- Variables
- func GetAccessTokenFromContext(ctx context.Context) string
- func WithAuthToken(ctx context.Context) openapi.RequestEditorFn
- func WithIdentityHeader(headerName, headerValue string) openapi.RequestEditorFn
- type Helper
- func (helper *Helper) CleanDB() error
- func (helper *Helper) CreateJWTString(account *TestAccount) string
- func (helper *Helper) IdentityHeaderName() string
- func (helper *Helper) MigrateDB() error
- func (helper *Helper) NewAPIClient() *openapi.ClientWithResponses
- func (helper *Helper) NewAccount(username, name, email string) *TestAccount
- func (helper *Helper) NewAuthenticatedContext(account *TestAccount) context.Context
- func (helper *Helper) NewID() string
- func (helper *Helper) NewRandAccount() *TestAccount
- func (helper *Helper) RebuildSchema() error
- func (helper *Helper) ResetDB() error
- func (helper *Helper) RestURL(path string) string
- func (helper *Helper) Teardown()
- type TestAccount
Constants ¶
This section is empty.
Variables ¶
var ContextAccessToken = contextKeyAccessToken{}
ContextAccessToken is the context key for access tokens (used by tests)
Functions ¶
func GetAccessTokenFromContext ¶
GetAccessTokenFromContext extracts the access token from the context
func WithAuthToken ¶
func WithAuthToken(ctx context.Context) openapi.RequestEditorFn
WithAuthToken returns a RequestEditorFn that adds the Authorization header from context
func WithIdentityHeader ¶ added in v0.3.0
func WithIdentityHeader(headerName, headerValue string) openapi.RequestEditorFn
WithIdentityHeader returns a RequestEditorFn that sets the caller identity header.
Types ¶
type Helper ¶
type Helper struct {
Factories factories.Factories
DBFactory db.SessionFactory
Container *container.Container
APIServer *server.APIServer
AppConfig *config.ApplicationConfig
JWTPrivateKey *rsa.PrivateKey
JWTCA *rsa.PublicKey
// contains filtered or unexported fields
}
func RegisterIntegration ¶
func RegisterIntegration(t *testing.T) (*Helper, *openapi.ClientWithResponses)
RegisterIntegration Register a test This should be run before every integration test
func (*Helper) CreateJWTString ¶
func (helper *Helper) CreateJWTString(account *TestAccount) string
func (*Helper) IdentityHeaderName ¶ added in v0.4.0
IdentityHeaderName returns the configured identity header name from the first JWT issuer config.
func (*Helper) NewAPIClient ¶ added in v0.2.0
func (helper *Helper) NewAPIClient() *openapi.ClientWithResponses
func (*Helper) NewAccount ¶
func (helper *Helper) NewAccount(username, name, email string) *TestAccount
func (*Helper) NewAuthenticatedContext ¶
func (helper *Helper) NewAuthenticatedContext(account *TestAccount) context.Context
func (*Helper) NewRandAccount ¶
func (helper *Helper) NewRandAccount() *TestAccount