test

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 32 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ContextAccessToken = contextKeyAccessToken{}

ContextAccessToken is the context key for access tokens (used by tests)

Functions

func GetAccessTokenFromContext

func GetAccessTokenFromContext(ctx context.Context) string

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 NewHelper

func NewHelper() *Helper

func RegisterIntegration

func RegisterIntegration(t *testing.T) (*Helper, *openapi.ClientWithResponses)

RegisterIntegration Register a test This should be run before every integration test

func (*Helper) CleanDB

func (helper *Helper) CleanDB() error

func (*Helper) CreateJWTString

func (helper *Helper) CreateJWTString(account *TestAccount) string

func (*Helper) IdentityHeaderName added in v0.4.0

func (helper *Helper) IdentityHeaderName() string

IdentityHeaderName returns the configured identity header name from the first JWT issuer config.

func (*Helper) MigrateDB

func (helper *Helper) MigrateDB() error

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) NewID

func (helper *Helper) NewID() string

NewID creates a new unique ID used internally

func (*Helper) NewRandAccount

func (helper *Helper) NewRandAccount() *TestAccount

func (*Helper) RebuildSchema added in v0.4.0

func (helper *Helper) RebuildSchema() error

func (*Helper) ResetDB

func (helper *Helper) ResetDB() error

func (*Helper) RestURL

func (helper *Helper) RestURL(path string) string

func (*Helper) Teardown

func (helper *Helper) Teardown()

type TestAccount added in v0.3.0

type TestAccount struct {
	Username  string
	FirstName string
	LastName  string
	Email     string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL