test

package
v0.0.0-...-145cf54 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

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

Types

type Helper

type Helper struct {
	Ctx           context.Context
	DBFactory     db.SessionFactory
	AppConfig     *config.ApplicationConfig
	APIServer     server.Server
	MetricsServer server.Server
	HealthServer  server.Server
	TimeFunc      TimeFunc
	JWTPrivateKey *rsa.PrivateKey
	JWTCA         *rsa.PublicKey
	T             *testing.T

	Factories factories.Factories
	// contains filtered or unexported fields
}

func NewHelper

func NewHelper(t *testing.T) *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) ClearAllTables

func (helper *Helper) ClearAllTables()

func (*Helper) Count

func (helper *Helper) Count(table string) int64

func (*Helper) CreateJWTString

func (helper *Helper) CreateJWTString(account *amv1.Account) string

func (*Helper) CreateJWTToken

func (helper *Helper) CreateJWTToken(account *amv1.Account) *jwt.Token

func (*Helper) Delete

func (helper *Helper) Delete(obj interface{})

func (*Helper) DeleteAll

func (helper *Helper) DeleteAll(table interface{})

func (*Helper) Env

func (helper *Helper) Env() *environments.Env

func (*Helper) HealthURL

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

func (*Helper) MetricsURL

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

func (*Helper) MigrateDB

func (helper *Helper) MigrateDB() error

func (*Helper) MigrateDBTo

func (helper *Helper) MigrateDBTo(migrationID string)

func (*Helper) NewAccount

func (helper *Helper) NewAccount(username, name, email string) *amv1.Account

func (*Helper) NewApiClient

func (helper *Helper) NewApiClient() *openapi.ClientWithResponses

func (*Helper) NewAuthenticatedContext

func (helper *Helper) NewAuthenticatedContext(account *amv1.Account) context.Context

func (*Helper) NewID

func (helper *Helper) NewID() string

NewID creates a new unique ID used internally to CS

func (*Helper) NewRandAccount

func (helper *Helper) NewRandAccount() *amv1.Account

func (*Helper) NewUUID

func (helper *Helper) NewUUID() string

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

func (helper *Helper) OpenapiError(body []byte) openapi.Error

OpenapiError Convert an error response body to an openapi error struct

func (*Helper) Reset

func (helper *Helper) Reset()

func (*Helper) ResetDB

func (helper *Helper) ResetDB() error

func (*Helper) RestURL

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

func (*Helper) RestartMetricsServer

func (helper *Helper) RestartMetricsServer()

func (*Helper) RestartServer

func (helper *Helper) RestartServer()

func (*Helper) SkipIfShort

func (helper *Helper) SkipIfShort()

func (*Helper) StartJWKCertServerMock

func (helper *Helper) StartJWKCertServerMock() (teardown func() error)

func (*Helper) Teardown

func (helper *Helper) Teardown()

type TimeFunc

type TimeFunc func() time.Time

TimeFunc defines a way to get a new Time instance common to the entire test suite. Aria's environment has Virtual Time that may not be actual time. We compensate by synchronizing on a common time func attached to the test harness.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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