Documentation ¶
Index ¶
- type Helper
- func NewHelper(t *testing.T, httpServer *httptest.Server, options ...di.Option) (*Helper, func())
- func NewHelperWithHooks(t *testing.T, httpServer *httptest.Server, configurationHook interface{}, ...) (*Helper, func())
- func NewHelperWithHooksAndDBsetup(t *testing.T, httpServer *httptest.Server, setupDBsqlStatements []string, ...) (*Helper, func())
- func (helper *Helper) CleanDB()
- func (helper *Helper) Count(table string) int64
- func (helper *Helper) CreateJWTString(account *amv1.Account) string
- func (helper *Helper) CreateJWTStringWithClaim(account *amv1.Account, jwtClaims jwt.MapClaims) string
- func (helper *Helper) CreateJWTToken(account *amv1.Account, jwtClaims jwt.MapClaims) *jwt.Token
- func (helper *Helper) DBFactory() (connectionFactory *db.ConnectionFactory)
- func (helper *Helper) Delete(obj interface{})
- func (helper *Helper) DeleteAll(table interface{})
- func (helper *Helper) HealthCheckURL(path string) string
- func (helper *Helper) MetricsURL(path string) string
- func (helper *Helper) MigrateDB()
- func (helper *Helper) Migrations() (m []*db.Migration)
- func (helper *Helper) NewAccount(username, name, email string, orgId string) *amv1.Account
- func (helper *Helper) NewAccountWithNameAndOrg(name string, orgId string) *amv1.Account
- func (helper *Helper) NewAllowedServiceAccount() *amv1.Account
- func (helper *Helper) NewAuthenticatedContext(account *amv1.Account, claims jwt.MapClaims) context.Context
- func (helper *Helper) NewAuthenticatedContextForSSO(keycloakConfig *keycloak.KeycloakConfig) context.Context
- func (helper *Helper) NewID() string
- func (helper *Helper) NewRandAccount() *amv1.Account
- func (helper *Helper) NewUUID() string
- func (helper *Helper) OpenapiError(err error) compat.Error
- func (helper *Helper) ResetDB()
- func (helper *Helper) RestURL(path string) string
- func (helper *Helper) SetupDB(statements []string)
- func (helper *Helper) SkipIfShort()
- func (helper *Helper) StartJWKCertServerMock() (string, func())
- type TimeFunc
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 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) CreateJWTString ¶
func (*Helper) CreateJWTStringWithClaim ¶
func (*Helper) CreateJWTToken ¶
func (*Helper) DBFactory ¶
func (helper *Helper) DBFactory() (connectionFactory *db.ConnectionFactory)
func (*Helper) HealthCheckURL ¶
func (*Helper) MetricsURL ¶
func (*Helper) Migrations ¶
func (*Helper) NewAccount ¶
func (*Helper) NewAccountWithNameAndOrg ¶
func (*Helper) NewAllowedServiceAccount ¶
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) NewRandAccount ¶
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 ¶
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 ¶
Convert an error response from the openapi client to an openapi error struct
func (*Helper) SkipIfShort ¶
func (helper *Helper) SkipIfShort()