test

package
v0.0.0-...-9b598c7 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Helper

type Helper struct {
	AuthHelper    *auth.AuthHelper
	JWTPrivateKey *rsa.PrivateKey
	JWTCA         *rsa.PublicKey
	T             *testing.T
	Env           *environments.Env
}

func NewHelper

func NewHelper(t *testing.T, httpServer *httptest.Server, options ...di.Option) (*Helper, func())

func NewHelperWithHooks

func NewHelperWithHooks(t *testing.T, httpServer *httptest.Server, configurationHook interface{}, envProviders ...di.Option) (*Helper, func())

NewHelperWithHooks will init the Helper and start the server, and it allows to customize the configurations of the server via the hook. The startHook will be invoked after the environments.Env is created but before the api server is started, which will allow caller to change configurations. The startHook can should be a function and can optionally have type arguments that can be injected from the configuration container.

func NewHelperWithHooksAndDBsetup

func NewHelperWithHooksAndDBsetup(t *testing.T, httpServer *httptest.Server, setupDBsqlStatements []string, configurationHook interface{}, envProviders ...di.Option) (*Helper, func())

NewHelperWithHooksAndDBsetup will also init the DB state executing the sql statement provided as setupDBsqlStatements after the DB has been reset.

func (*Helper) CleanDB

func (helper *Helper) CleanDB()

func (*Helper) Count

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

func (*Helper) CreateJWTString

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

func (*Helper) CreateJWTStringWithClaim

func (helper *Helper) CreateJWTStringWithClaim(account *amv1.Account, jwtClaims jwt.MapClaims) string

func (*Helper) CreateJWTToken

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

func (*Helper) DBFactory

func (helper *Helper) DBFactory() (connectionFactory *db.ConnectionFactory)

func (*Helper) Delete

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

func (*Helper) DeleteAll

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

func (*Helper) HealthCheckURL

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

func (*Helper) MetricsURL

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

func (*Helper) MigrateDB

func (helper *Helper) MigrateDB()

func (*Helper) Migrations

func (helper *Helper) Migrations() (m []*db.Migration)

func (*Helper) NewAccount

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

func (*Helper) NewAccountWithNameAndOrg

func (helper *Helper) NewAccountWithNameAndOrg(name string, orgId string) *amv1.Account

func (*Helper) NewAllowedServiceAccount

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

NewAllowedServiceAccount returns a new account that has the testuser1@example.com without an organization ID

func (*Helper) NewAuthenticatedContext

func (helper *Helper) NewAuthenticatedContext(account *amv1.Account, claims jwt.MapClaims) context.Context

Returns an authenticated context that can be used with openapi functions

func (*Helper) NewAuthenticatedContextForSSO

func (helper *Helper) NewAuthenticatedContextForSSO(keycloakConfig *keycloak.KeycloakConfig) context.Context

Returns an authenticated context that can be used to interact with SSO

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

NewRandAccount returns a random account that has the control plane team org id as its organisation id The org id value is taken from config/quota-management-list-configuration.yaml

func (*Helper) NewUUID

func (helper *Helper) NewUUID() string

NewUUID creates a new unique UUID, which has different formatting than xid UUID is used by telemeter and we validate the format.

func (*Helper) OpenapiError

func (helper *Helper) OpenapiError(err error) compat.Error

Convert an error response from the openapi client to an openapi error struct

func (*Helper) ResetDB

func (helper *Helper) ResetDB()

func (*Helper) RestURL

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

func (*Helper) SetupDB

func (helper *Helper) SetupDB(statements []string)

func (*Helper) SkipIfShort

func (helper *Helper) SkipIfShort()

func (*Helper) StartJWKCertServerMock

func (helper *Helper) StartJWKCertServerMock() (string, func())

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
Setting a path prefixed to subsequent http requests:
Setting a path prefixed to subsequent http requests:

Jump to

Keyboard shortcuts

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