tests

package
v11.1.4-modfix Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupApiKey

func SetupApiKey(t *testing.T, store db.DB, cfg *setting.Cfg, testKey TestApiKey) *apikey.APIKey

func SetupUserServiceAccount

func SetupUserServiceAccount(t *testing.T, db db.DB, cfg *setting.Cfg, testUser TestUser) *user.User

func SetupUsersServiceAccounts

func SetupUsersServiceAccounts(t *testing.T, sqlStore db.DB, cfg *setting.Cfg, testUsers []TestUser) (orgID int64)

SetupUsersServiceAccounts creates in "test org" all users or service accounts passed in parameter To achieve this, it sets the AutoAssignOrg and AutoAssignOrgId settings.

Types

type FakeServiceAccountService

type FakeServiceAccountService struct {
	ExpectedAPIKey                         *apikey.APIKey
	ExpectedErr                            error
	ExpectedMigrationResult                *serviceaccounts.MigrationResult
	ExpectedSearchOrgServiceAccountsResult *serviceaccounts.SearchOrgServiceAccountsResult
	ExpectedServiceAccount                 *serviceaccounts.ServiceAccountDTO
	ExpectedServiceAccountID               int64
	ExpectedServiceAccountProfile          *serviceaccounts.ServiceAccountProfileDTO
	ExpectedServiceAccountTokens           []apikey.APIKey
}

func (*FakeServiceAccountService) AddServiceAccountToken

func (*FakeServiceAccountService) CreateServiceAccount

func (*FakeServiceAccountService) DeleteServiceAccount

func (f *FakeServiceAccountService) DeleteServiceAccount(ctx context.Context, orgID, id int64) error

func (*FakeServiceAccountService) DeleteServiceAccountToken

func (f *FakeServiceAccountService) DeleteServiceAccountToken(ctx context.Context, orgID, id, tokenID int64) error

func (*FakeServiceAccountService) EnableServiceAccount

func (f *FakeServiceAccountService) EnableServiceAccount(ctx context.Context, orgID int64, serviceAccountID int64, enable bool) error

func (*FakeServiceAccountService) ListTokens

func (*FakeServiceAccountService) MigrateApiKey

func (f *FakeServiceAccountService) MigrateApiKey(ctx context.Context, orgID, keyID int64) error

func (*FakeServiceAccountService) MigrateApiKeysToServiceAccounts

func (f *FakeServiceAccountService) MigrateApiKeysToServiceAccounts(ctx context.Context, orgID int64) (*serviceaccounts.MigrationResult, error)

func (*FakeServiceAccountService) RetrieveServiceAccount

func (f *FakeServiceAccountService) RetrieveServiceAccount(ctx context.Context, orgID, id int64) (*serviceaccounts.ServiceAccountProfileDTO, error)

func (*FakeServiceAccountService) RetrieveServiceAccountIdByName

func (f *FakeServiceAccountService) RetrieveServiceAccountIdByName(ctx context.Context, orgID int64, name string) (int64, error)

func (*FakeServiceAccountService) UpdateServiceAccount

type MockExtSvcAccountsService

type MockExtSvcAccountsService struct {
	mock.Mock
}

MockExtSvcAccountsService is an autogenerated mock type for the ExtSvcAccountsService type

func NewMockExtSvcAccountsService

func NewMockExtSvcAccountsService(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockExtSvcAccountsService

NewMockExtSvcAccountsService creates a new instance of MockExtSvcAccountsService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockExtSvcAccountsService) EnableExtSvcAccount

EnableExtSvcAccount provides a mock function with given fields: ctx, cmd

func (*MockExtSvcAccountsService) ManageExtSvcAccount

ManageExtSvcAccount provides a mock function with given fields: ctx, cmd

func (*MockExtSvcAccountsService) RemoveExtSvcAccount

func (_m *MockExtSvcAccountsService) RemoveExtSvcAccount(ctx context.Context, orgID int64, extSvcSlug string) error

RemoveExtSvcAccount provides a mock function with given fields: ctx, orgID, extSvcSlug

func (*MockExtSvcAccountsService) RetrieveExtSvcAccount

func (_m *MockExtSvcAccountsService) RetrieveExtSvcAccount(ctx context.Context, orgID int64, saID int64) (*serviceaccounts.ExtSvcAccount, error)

RetrieveExtSvcAccount provides a mock function with given fields: ctx, orgID, saID

type MockServiceAccountService

type MockServiceAccountService struct {
	mock.Mock
}

MockServiceAccountService is an autogenerated mock type for the Service type

func NewMockServiceAccountService

func NewMockServiceAccountService(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockServiceAccountService

NewMockServiceAccountService creates a new instance of MockServiceAccountService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockServiceAccountService) AddServiceAccountToken

func (_m *MockServiceAccountService) AddServiceAccountToken(ctx context.Context, serviceAccountID int64, cmd *serviceaccounts.AddServiceAccountTokenCommand) (*apikey.APIKey, error)

AddServiceAccountToken provides a mock function with given fields: ctx, serviceAccountID, cmd

func (*MockServiceAccountService) CreateServiceAccount

CreateServiceAccount provides a mock function with given fields: ctx, orgID, saForm

func (*MockServiceAccountService) DeleteServiceAccount

func (_m *MockServiceAccountService) DeleteServiceAccount(ctx context.Context, orgID int64, serviceAccountID int64) error

DeleteServiceAccount provides a mock function with given fields: ctx, orgID, serviceAccountID

func (*MockServiceAccountService) DeleteServiceAccountToken

func (_m *MockServiceAccountService) DeleteServiceAccountToken(ctx context.Context, orgID int64, serviceAccountID int64, tokenID int64) error

DeleteServiceAccountToken provides a mock function with given fields: ctx, orgID, serviceAccountID, tokenID

func (*MockServiceAccountService) EnableServiceAccount

func (_m *MockServiceAccountService) EnableServiceAccount(ctx context.Context, orgID int64, serviceAccountID int64, enable bool) error

EnableServiceAccount provides a mock function with given fields: ctx, orgID, serviceAccountID, enable

func (*MockServiceAccountService) ListTokens

ListTokens provides a mock function with given fields: ctx, query

func (*MockServiceAccountService) MigrateApiKey

func (_m *MockServiceAccountService) MigrateApiKey(ctx context.Context, orgID int64, keyId int64) error

MigrateApiKey provides a mock function with given fields: ctx, orgID, keyId

func (*MockServiceAccountService) MigrateApiKeysToServiceAccounts

func (_m *MockServiceAccountService) MigrateApiKeysToServiceAccounts(ctx context.Context, orgID int64) (*serviceaccounts.MigrationResult, error)

MigrateApiKeysToServiceAccounts provides a mock function with given fields: ctx, orgID

func (*MockServiceAccountService) RetrieveServiceAccount

func (_m *MockServiceAccountService) RetrieveServiceAccount(ctx context.Context, orgID int64, serviceAccountID int64) (*serviceaccounts.ServiceAccountProfileDTO, error)

RetrieveServiceAccount provides a mock function with given fields: ctx, orgID, serviceAccountID

func (*MockServiceAccountService) RetrieveServiceAccountIdByName

func (_m *MockServiceAccountService) RetrieveServiceAccountIdByName(ctx context.Context, orgID int64, name string) (int64, error)

RetrieveServiceAccountIdByName provides a mock function with given fields: ctx, orgID, name

func (*MockServiceAccountService) SearchOrgServiceAccounts

SearchOrgServiceAccounts provides a mock function with given fields: ctx, query

func (*MockServiceAccountService) UpdateServiceAccount

UpdateServiceAccount provides a mock function with given fields: ctx, orgID, serviceAccountID, saForm

type TestApiKey

type TestApiKey struct {
	Name             string
	Role             org.RoleType
	OrgId            int64
	Key              string
	IsExpired        bool
	ServiceAccountID *int64
}

type TestUser

type TestUser struct {
	Name             string
	Role             string
	Login            string
	IsServiceAccount bool
}

Jump to

Keyboard shortcuts

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