test

package
v0.0.0-...-2d73068 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: Apache-2.0 Imports: 42 Imported by: 6

Documentation

Overview

This file was generated by counterfeiter

Index

Constants

This section is empty.

Variables

View Source
var TestAdminConsoleIdentity = account.Identity{
	ID:       uuid.NewV4(),
	Username: "fabric8-admin",
	User:     TestUser,
}
View Source
var TestIdentity = account.Identity{
	ID:           uuid.NewV4(),
	Username:     "TestDeveloper" + uuid.NewV4().String(),
	User:         TestUser,
	ProviderType: account.DefaultIDP,
}

TestIdentity only creates in memory obj for testing purposes

View Source
var TestIdentity2 = account.Identity{
	ID:           uuid.NewV4(),
	Username:     "TestDeveloper2" + uuid.NewV4().String(),
	User:         TestUser2,
	ProviderType: account.DefaultIDP,
}

TestIdentity2 only creates in memory obj for testing purposes

View Source
var TestNotificationIdentity = account.Identity{
	ID:       uuid.NewV4(),
	Username: "fabric8-notification",
	User:     TestUser,
}
View Source
var TestObserverIdentity = account.Identity{
	ID:       uuid.NewV4(),
	Username: "TestObserver",
	User:     TestUser,
}

TestObserverIdentity only creates in memory obj for testing purposes

View Source
var TestOnlineRegistrationAppIdentity = account.Identity{
	ID:       uuid.NewV4(),
	Username: "online-registration",
	User:     TestUser,
}
View Source
var TestTenantIdentity = account.Identity{
	ID:       uuid.NewV4(),
	Username: "fabric8-tenant",
	User:     TestUser,
}
View Source
var TestUser = account.User{
	ID:       uuid.NewV4(),
	Email:    "testdeveloper@testalm.io" + uuid.NewV4().String(),
	FullName: "Test Developer",
	Cluster:  "https://api.starter-us-east-2.openshift.com",
}

TestUser only creates in memory obj for testing purposes

View Source
var TestUser2 = account.User{
	ID:       uuid.NewV4(),
	Email:    "testdeveloper2@testalm.io" + uuid.NewV4().String(),
	FullName: "Test Developer 2",
	Cluster:  "https://api.starter-us-east-2.openshift.com",
}

TestUser2 only creates in memory obj for testing purposes. This TestUser2 can be used to verify that some entity created by TestUser can be later updated or deleted (or not) by another user.

View Source
var TestUser3 = account.User{
	ID:       uuid.NewV4(),
	Email:    uuid.NewV4().String(),
	FullName: "Test Developer",
	Cluster:  "https://api.starter-us-east-2.openshift.com",
}

TestUser only creates in memory obj for testing purposes

View Source
var TestUserPrivate = account.User{
	ID:           uuid.NewV4(),
	Email:        uuid.NewV4().String(),
	FullName:     "Test Developer",
	Cluster:      "https://api.starter-us-east-2.openshift.com",
	EmailPrivate: true,
}

TestUserPrivate only creates in memory obj for testing purposes

Functions

func ActivateDummyClusterCacheFactory

func ActivateDummyClusterCacheFactory(w wrapper.Wrapper, cache cluster.ClusterCache)

func ActivateDummyIdentityProviderFactory

func ActivateDummyIdentityProviderFactory(w wrapper.Wrapper, provider provider.IdentityProvider)

func ActivateDummyLinkingProviderFactory

func ActivateDummyLinkingProviderFactory(w wrapper.Wrapper, config *configuration.ConfigurationData, token string, loadProfileFail bool, authCodeURL string)

TODO this is getting a little out of hand, look into other ways to initialize the factory ActivateDummyLinkingProviderFactory can be used to create a mock linking provider factory

func AssertError

func AssertError(t require.TestingT, actualError error, expectedType interface{}, expectedMsgAndArgs ...interface{})

func AssertIdentityEqual

func AssertIdentityEqual(t require.TestingT, expected, actual *account.Identity)

func AssertIdentityObfuscated

func AssertIdentityObfuscated(t require.TestingT, expected, actual *account.Identity)

AssertIdentityObfuscated verifies that the `actual` identity was obfuscated, ie, all the personal data were replaced with UUID values, except a few fields

func AssertIdentitySoftDeleted

func AssertIdentitySoftDeleted(t require.TestingT, actual *account.Identity)

AssertIdentitySoftDeleted verifies that the `actual` identity was soft-delete

func ClusterByURL

func ClusterByURL(url string) *cluster.Cluster

func CreateBannedTestIdentityAndUser

func CreateBannedTestIdentityAndUser(db *gorm.DB, username string) (account.Identity, error)

func CreateLonelyTestIdentity

func CreateLonelyTestIdentity(db *gorm.DB, username string) (account.Identity, error)

CreateLonelyTestIdentity creates an identity not associated with any user. For testing purpose only.

func CreateRandomIdentityRole

func CreateRandomIdentityRole(ctx context.Context, db *gorm.DB) (*role.IdentityRole, error)

func CreateRandomValidTestName

func CreateRandomValidTestName(name string) string

CreateRandomValidTestName functions creates a valid length name

func CreateTestIdentity

func CreateTestIdentity(db *gorm.DB, username, providerType string) (account.Identity, error)

CreateTestIdentity creates an identity with the given `username` in the database. For testing purpose only.

func CreateTestIdentityAndUser

func CreateTestIdentityAndUser(db *gorm.DB, username, providerType string) (account.Identity, error)

CreateTestIdentityAndUser creates an identity & user with the given `username` in the database. For testing purpose only.

func CreateTestIdentityAndUserInDB

func CreateTestIdentityAndUserInDB(db *gorm.DB, identity *account.Identity) error

CreateTestIdentityAndUserInDB creates an account.Identity and account.User in the database. For testing purpose only. Not re-using CreateTestIdentityForAccountIdentity because it is used in many places and will cause errors/failures. This function unlike CreateTestIdentity() allows to create an Identity with pre-defined ID.

func CreateTestIdentityAndUserWithDefaultProviderType

func CreateTestIdentityAndUserWithDefaultProviderType(db *gorm.DB, username string) (account.Identity, error)

CreateTestIdentityAndUserWithDefaultProviderType creates an identity & user with the given `username` in the database. For testing purpose only.

func CreateTestIdentityForAccountIdentity

func CreateTestIdentityForAccountIdentity(db *gorm.DB, identity *account.Identity) error

CreateTestIdentityForAccountIdentity creates an account.Identity in the database. For testing purpose only. This function unlike CreateTestIdentity() allows to create an Identity with pre-defined ID.

func CreateTestIdentityRole

func CreateTestIdentityRole(ctx context.Context, db *gorm.DB, resourceRef resource.Resource, roleRef role.Role) (*role.IdentityRole, error)

func CreateTestIdentityRoleForIdentity

func CreateTestIdentityRoleForIdentity(ctx context.Context, db *gorm.DB, identity account.Identity, resourceRef resource.Resource, roleRef role.Role) (*role.IdentityRole, error)

func CreateTestOrganization

func CreateTestOrganization(ctx context.Context, db *gorm.DB, app application.Application, creatorIdentityID uuid.UUID, name string) (account.Identity, error)

func CreateTestOrganizationIdentity

func CreateTestOrganizationIdentity(db *gorm.DB) (account.Identity, error)

CreateTestOrganizationIdentity creates an identity/resource pair in the database. For testing purposes only.

func CreateTestResource

func CreateTestResource(ctx context.Context, db *gorm.DB, resourceType resourcetype.ResourceType, name string, parentResourceID *string) (*resource.Resource, error)

func CreateTestResourceType

func CreateTestResourceType(ctx context.Context, db *gorm.DB, name string) (*resourcetype.ResourceType, error)

func CreateTestResourceWithDefaultType

func CreateTestResourceWithDefaultType(ctx context.Context, db *gorm.DB, name string) (*resource.Resource, error)

func CreateTestRole

func CreateTestRole(ctx context.Context, db *gorm.DB, resourceType resourcetype.ResourceType, name string) (*role.Role, error)

func CreateTestRoleMapping

func CreateTestRoleMapping(ctx context.Context, db *gorm.DB, app application.Application, resourceID string, fromRoleID uuid.UUID, toRoleID uuid.UUID) error

func CreateTestRoleScope

func CreateTestRoleScope(ctx context.Context, db *gorm.DB, s resourcetype.ResourceTypeScope, r role.Role) (*role.RoleScope, error)

func CreateTestRoleWithDefaultType

func CreateTestRoleWithDefaultType(ctx context.Context, db *gorm.DB, name string) (*role.Role, error)

func CreateTestRoleWithSpecifiedType

func CreateTestRoleWithSpecifiedType(ctx context.Context, db *gorm.DB, name string, resourceTypeName string) (*role.Role, error)

func CreateTestScope

func CreateTestScope(ctx context.Context, db *gorm.DB, resourceType resourcetype.ResourceType, name string) (*resourcetype.ResourceTypeScope, error)

func CreateTestScopeWithDefaultType

func CreateTestScopeWithDefaultType(ctx context.Context, db *gorm.DB, name string) (*resourcetype.ResourceTypeScope, error)

func CreateTestUser

func CreateTestUser(db *gorm.DB, user *account.User) (account.Identity, error)

CreateTestUser creates a new user from a given user object

func EmbedTestIdentityTokenInContext

func EmbedTestIdentityTokenInContext(db *gorm.DB, username string) (account.Identity, context.Context, error)

EmbedTestIdentityTokenInContext creates an identity & user with the given `username` in the database. Generates a token for that identity and embed the token in the context.

func EqualURLs

func EqualURLs(t *testing.T, expected string, actual string)

func NewDummyClusterCache

func NewDummyClusterCache() cluster.ClusterCache

func NewDummyClusterCacheWithClusters

func NewDummyClusterCacheWithClusters(value map[string]cluster.Cluster) cluster.ClusterCache

func Run

func Run(b *testing.B, suite BenchingSuite)

Run takes a testing suite and runs all of the benchmarks attached to it.

func ServiceAsServiceAccountUser

func ServiceAsServiceAccountUser(serviceName string, u account.Identity) *goa.Service

ServiceAsServiceAccountUser generates the minimal service needed to satisfy the condition of being a service account.

func ServiceAsUser

func ServiceAsUser(serviceName string, u account.Identity) *goa.Service

ServiceAsUser creates a new service and fill the context with input Identity

func ServiceAsUserWithIncompleteClaims

func ServiceAsUserWithIncompleteClaims(serviceName string, u account.Identity) *goa.Service

ServiceAsUserWithIncompleteClaims creates a new service and fill the context with input Identity

func UnsecuredService

func UnsecuredService(serviceName string) *goa.Service

UnsecuredService creates a new service with token manager injected by without any identity in context

func WithIdentity

func WithIdentity(ctx context.Context, ident account.Identity) context.Context

WithIdentity fills the context with token Token is filled using input Identity object

func WithIncompleteIdentity

func WithIncompleteIdentity(ctx context.Context, ident account.Identity) context.Context

WithIncompleteIdentity fills the context with token Token is filled using input Identity object but without the sub claim

func WithServiceAccountAuthz

func WithServiceAccountAuthz(ctx context.Context, tokenManager manager.TokenManager, ident account.Identity) context.Context

WithServiceAccountAuthz fills the context with token Token is filled using input Identity object and resource authorization information

Types

type AfterBenchmark

type AfterBenchmark interface {
	AfterBenchmark(suiteName, testName string)
}

AfterBenchmark has a function to be executed right after the benchmark finishes and receives the suite and benchmark names as input

type BeforeBenchmark

type BeforeBenchmark interface {
	BeforeBenchmark(suiteName, testName string)
}

BeforeBenchmark has a function to be executed right before the benchmark starts and receives the suite and benchmark names as input

type BenchingSuite

type BenchingSuite interface {
	B() *testing.B
	SetB(*testing.B)
}

BenchingSuite can store and return the current *testing.B context generated by 'go test -bench=.'.

type DummyHttpClient

type DummyHttpClient struct {
	Response      *http.Response
	Error         error
	AssertRequest func(req *http.Request)
}

func (*DummyHttpClient) Do

func (c *DummyHttpClient) Do(req *http.Request) (*http.Response, error)

type DummyHttpDoer

type DummyHttpDoer struct {
	*rest.HttpClientDoer
	Client *DummyHttpClient
}

func NewDummyHttpDoer

func NewDummyHttpDoer() *DummyHttpDoer

type DummyLinkingProvider

type DummyLinkingProvider struct {
	// contains filtered or unexported fields
}

func (*DummyLinkingProvider) AuthCodeURL

func (p *DummyLinkingProvider) AuthCodeURL(state string, opts ...oauth2.AuthCodeOption) string

func (*DummyLinkingProvider) Exchange

func (p *DummyLinkingProvider) Exchange(ctx netcontext.Context, code string) (*oauth2.Token, error)

func (*DummyLinkingProvider) ID

func (p *DummyLinkingProvider) ID() uuid.UUID

func (*DummyLinkingProvider) OSOCluster

func (provider *DummyLinkingProvider) OSOCluster() cluster.Cluster

func (*DummyLinkingProvider) Profile

func (*DummyLinkingProvider) Scopes

func (p *DummyLinkingProvider) Scopes() string

func (*DummyLinkingProvider) SetRedirectURL

func (p *DummyLinkingProvider) SetRedirectURL(redirectURL string)

func (*DummyLinkingProvider) SetScopes

func (p *DummyLinkingProvider) SetScopes(scopes []string)

func (*DummyLinkingProvider) TypeName

func (p *DummyLinkingProvider) TypeName() string

func (*DummyLinkingProvider) URL

func (p *DummyLinkingProvider) URL() string

type SetupAllSuite

type SetupAllSuite interface {
	SetupSuite()
}

SetupAllSuite has a SetupSuite method, which will run before the benchmarks in the suite are run.

type SetupBenchmarkSuite

type SetupBenchmarkSuite interface {
	SetupBenchmark()
}

SetupBenchmarkSuite has a SetupBenchmark method, which will run before each benchmark in the suite.

type Suite

type Suite struct {
	// contains filtered or unexported fields
}

Suite is a basic testing suite with methods for storing and retrieving the current *testing.B context.

func (*Suite) B

func (suite *Suite) B() *testing.B

B retrieves the current *testing.B context.

func (*Suite) SetB

func (suite *Suite) SetB(b *testing.B)

SetB sets the current *testing.B context.

type TearDownAllSuite

type TearDownAllSuite interface {
	TearDownSuite()
}

TearDownAllSuite has a TearDownSuite method, which will run after all the benchmarks in the suite have been run.

type TearDownBenchmarkSuite

type TearDownBenchmarkSuite interface {
	TearDownBenchmark()
}

TearDownBenchmarkSuite has a TearDownBenchmark method, which will run after each benchmark in the suite.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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