Documentation
¶
Index ¶
- Variables
- func GetAccessTokenFromContext(ctx context.Context) string
- func IdentityHeaderName() 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) ClearAllTables()
- func (helper *Helper) Count(table string) int64
- func (helper *Helper) CreateJWTString(account *TestAccount) string
- func (helper *Helper) CreateJWTToken(account *TestAccount) *jwt.Token
- func (helper *Helper) Delete(obj interface{})
- func (helper *Helper) DeleteAll(table interface{})
- func (helper *Helper) Env() *environments.Env
- func (helper *Helper) HealthURL(path string) string
- func (helper *Helper) MetricsURL(path string) string
- func (helper *Helper) MigrateDB() error
- func (helper *Helper) MigrateDBTo(migrationID string)
- 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) NewUUID() string
- func (helper *Helper) OpenapiError(body []byte) openapi.Error
- func (helper *Helper) Reset()
- func (helper *Helper) ResetDB() error
- func (helper *Helper) RestURL(path string) string
- func (helper *Helper) RestartMetricsServer()
- func (helper *Helper) RestartServer()
- func (helper *Helper) SkipIfShort()
- func (helper *Helper) StartJWKCertServerMock() (teardown func() error)
- func (helper *Helper) Teardown()
- type TestAccount
- type TimeFunc
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 IdentityHeaderName ¶ added in v0.3.0
func IdentityHeaderName() string
IdentityHeaderName returns the configured identity header name for integration tests.
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
Ctx context.Context
DBFactory db.SessionFactory
APIServer server.Server
MetricsServer server.Server
HealthServer server.Server
AppConfig *config.ApplicationConfig
TimeFunc TimeFunc
JWTPrivateKey *rsa.PrivateKey
JWTCA *rsa.PublicKey
T *testing.T
// 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) ClearAllTables ¶
func (helper *Helper) ClearAllTables()
func (*Helper) CreateJWTString ¶
func (helper *Helper) CreateJWTString(account *TestAccount) string
func (*Helper) CreateJWTToken ¶
func (helper *Helper) CreateJWTToken(account *TestAccount) *jwt.Token
func (*Helper) Env ¶
func (helper *Helper) Env() *environments.Env
func (*Helper) MetricsURL ¶
func (*Helper) MigrateDBTo ¶
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
func (*Helper) NewUUID ¶
NewUUID creates a new unique UUID, which has different formatting than ksuid UUID is used by telemeter and we validate the format.
func (*Helper) OpenapiError ¶
OpenapiError Convert an error response body to an openapi error struct
func (*Helper) RestartMetricsServer ¶
func (helper *Helper) RestartMetricsServer()
func (*Helper) RestartServer ¶
func (helper *Helper) RestartServer()
func (*Helper) SkipIfShort ¶
func (helper *Helper) SkipIfShort()