mocks

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditLoggerMock added in v0.18.0

type AuditLoggerMock struct {
	// LogAuditFunc mocks the LogAudit method.
	LogAuditFunc func(ctx context.Context, entry store.AuditEntry) error
	// contains filtered or unexported fields
}

AuditLoggerMock is a mock implementation of web.AuditLogger.

func TestSomethingThatUsesAuditLogger(t *testing.T) {

	// make and configure a mocked web.AuditLogger
	mockedAuditLogger := &AuditLoggerMock{
		LogAuditFunc: func(ctx context.Context, entry store.AuditEntry) error {
			panic("mock out the LogAudit method")
		},
	}

	// use mockedAuditLogger in code that requires web.AuditLogger
	// and then make assertions.

}

func (*AuditLoggerMock) LogAudit added in v0.18.0

func (mock *AuditLoggerMock) LogAudit(ctx context.Context, entry store.AuditEntry) error

LogAudit calls LogAuditFunc.

func (*AuditLoggerMock) LogAuditCalls added in v0.18.0

func (mock *AuditLoggerMock) LogAuditCalls() []struct {
	Ctx   context.Context
	Entry store.AuditEntry
}

LogAuditCalls gets all the calls that were made to LogAudit. Check the length with:

len(mockedAuditLogger.LogAuditCalls())

type AuditStoreMock added in v0.18.0

type AuditStoreMock struct {
	// QueryAuditFunc mocks the QueryAudit method.
	QueryAuditFunc func(ctx context.Context, q store.AuditQuery) ([]store.AuditEntry, int, error)
	// contains filtered or unexported fields
}

AuditStoreMock is a mock implementation of web.AuditStore.

func TestSomethingThatUsesAuditStore(t *testing.T) {

	// make and configure a mocked web.AuditStore
	mockedAuditStore := &AuditStoreMock{
		QueryAuditFunc: func(ctx context.Context, q store.AuditQuery) ([]store.AuditEntry, int, error) {
			panic("mock out the QueryAudit method")
		},
	}

	// use mockedAuditStore in code that requires web.AuditStore
	// and then make assertions.

}

func (*AuditStoreMock) QueryAudit added in v0.18.0

func (mock *AuditStoreMock) QueryAudit(ctx context.Context, q store.AuditQuery) ([]store.AuditEntry, int, error)

QueryAudit calls QueryAuditFunc.

func (*AuditStoreMock) QueryAuditCalls added in v0.18.0

func (mock *AuditStoreMock) QueryAuditCalls() []struct {
	Ctx context.Context
	Q   store.AuditQuery
}

QueryAuditCalls gets all the calls that were made to QueryAudit. Check the length with:

len(mockedAuditStore.QueryAuditCalls())

type AuthProviderMock

type AuthProviderMock struct {
	// CheckUserPermissionFunc mocks the CheckUserPermission method.
	CheckUserPermissionFunc func(username string, key string, write bool) bool

	// CreateSessionFunc mocks the CreateSession method.
	CreateSessionFunc func(ctx context.Context, username string) (string, error)

	// EnabledFunc mocks the Enabled method.
	EnabledFunc func() bool

	// FilterUserKeysFunc mocks the FilterUserKeys method.
	FilterUserKeysFunc func(username string, keys []string) []string

	// GetSessionUserFunc mocks the GetSessionUser method.
	GetSessionUserFunc func(ctx context.Context, token string) (string, bool)

	// InvalidateSessionFunc mocks the InvalidateSession method.
	InvalidateSessionFunc func(ctx context.Context, token string)

	// IsAdminFunc mocks the IsAdmin method.
	IsAdminFunc func(username string) bool

	// IsValidUserFunc mocks the IsValidUser method.
	IsValidUserFunc func(username string, password string) bool

	// LoginTTLFunc mocks the LoginTTL method.
	LoginTTLFunc func() time.Duration

	// UserCanWriteFunc mocks the UserCanWrite method.
	UserCanWriteFunc func(username string) bool
	// contains filtered or unexported fields
}

AuthProviderMock is a mock implementation of web.AuthProvider.

func TestSomethingThatUsesAuthProvider(t *testing.T) {

	// make and configure a mocked web.AuthProvider
	mockedAuthProvider := &AuthProviderMock{
		CheckUserPermissionFunc: func(username string, key string, write bool) bool {
			panic("mock out the CheckUserPermission method")
		},
		CreateSessionFunc: func(ctx context.Context, username string) (string, error) {
			panic("mock out the CreateSession method")
		},
		EnabledFunc: func() bool {
			panic("mock out the Enabled method")
		},
		FilterUserKeysFunc: func(username string, keys []string) []string {
			panic("mock out the FilterUserKeys method")
		},
		GetSessionUserFunc: func(ctx context.Context, token string) (string, bool) {
			panic("mock out the GetSessionUser method")
		},
		InvalidateSessionFunc: func(ctx context.Context, token string)  {
			panic("mock out the InvalidateSession method")
		},
		IsAdminFunc: func(username string) bool {
			panic("mock out the IsAdmin method")
		},
		IsValidUserFunc: func(username string, password string) bool {
			panic("mock out the IsValidUser method")
		},
		LoginTTLFunc: func() time.Duration {
			panic("mock out the LoginTTL method")
		},
		UserCanWriteFunc: func(username string) bool {
			panic("mock out the UserCanWrite method")
		},
	}

	// use mockedAuthProvider in code that requires web.AuthProvider
	// and then make assertions.

}

func (*AuthProviderMock) CheckUserPermission

func (mock *AuthProviderMock) CheckUserPermission(username string, key string, write bool) bool

CheckUserPermission calls CheckUserPermissionFunc.

func (*AuthProviderMock) CheckUserPermissionCalls

func (mock *AuthProviderMock) CheckUserPermissionCalls() []struct {
	Username string
	Key      string
	Write    bool
}

CheckUserPermissionCalls gets all the calls that were made to CheckUserPermission. Check the length with:

len(mockedAuthProvider.CheckUserPermissionCalls())

func (*AuthProviderMock) CreateSession

func (mock *AuthProviderMock) CreateSession(ctx context.Context, username string) (string, error)

CreateSession calls CreateSessionFunc.

func (*AuthProviderMock) CreateSessionCalls

func (mock *AuthProviderMock) CreateSessionCalls() []struct {
	Ctx      context.Context
	Username string
}

CreateSessionCalls gets all the calls that were made to CreateSession. Check the length with:

len(mockedAuthProvider.CreateSessionCalls())

func (*AuthProviderMock) Enabled

func (mock *AuthProviderMock) Enabled() bool

Enabled calls EnabledFunc.

func (*AuthProviderMock) EnabledCalls

func (mock *AuthProviderMock) EnabledCalls() []struct {
}

EnabledCalls gets all the calls that were made to Enabled. Check the length with:

len(mockedAuthProvider.EnabledCalls())

func (*AuthProviderMock) FilterUserKeys

func (mock *AuthProviderMock) FilterUserKeys(username string, keys []string) []string

FilterUserKeys calls FilterUserKeysFunc.

func (*AuthProviderMock) FilterUserKeysCalls

func (mock *AuthProviderMock) FilterUserKeysCalls() []struct {
	Username string
	Keys     []string
}

FilterUserKeysCalls gets all the calls that were made to FilterUserKeys. Check the length with:

len(mockedAuthProvider.FilterUserKeysCalls())

func (*AuthProviderMock) GetSessionUser

func (mock *AuthProviderMock) GetSessionUser(ctx context.Context, token string) (string, bool)

GetSessionUser calls GetSessionUserFunc.

func (*AuthProviderMock) GetSessionUserCalls

func (mock *AuthProviderMock) GetSessionUserCalls() []struct {
	Ctx   context.Context
	Token string
}

GetSessionUserCalls gets all the calls that were made to GetSessionUser. Check the length with:

len(mockedAuthProvider.GetSessionUserCalls())

func (*AuthProviderMock) InvalidateSession

func (mock *AuthProviderMock) InvalidateSession(ctx context.Context, token string)

InvalidateSession calls InvalidateSessionFunc.

func (*AuthProviderMock) InvalidateSessionCalls

func (mock *AuthProviderMock) InvalidateSessionCalls() []struct {
	Ctx   context.Context
	Token string
}

InvalidateSessionCalls gets all the calls that were made to InvalidateSession. Check the length with:

len(mockedAuthProvider.InvalidateSessionCalls())

func (*AuthProviderMock) IsAdmin added in v0.18.0

func (mock *AuthProviderMock) IsAdmin(username string) bool

IsAdmin calls IsAdminFunc.

func (*AuthProviderMock) IsAdminCalls added in v0.18.0

func (mock *AuthProviderMock) IsAdminCalls() []struct {
	Username string
}

IsAdminCalls gets all the calls that were made to IsAdmin. Check the length with:

len(mockedAuthProvider.IsAdminCalls())

func (*AuthProviderMock) IsValidUser

func (mock *AuthProviderMock) IsValidUser(username string, password string) bool

IsValidUser calls IsValidUserFunc.

func (*AuthProviderMock) IsValidUserCalls

func (mock *AuthProviderMock) IsValidUserCalls() []struct {
	Username string
	Password string
}

IsValidUserCalls gets all the calls that were made to IsValidUser. Check the length with:

len(mockedAuthProvider.IsValidUserCalls())

func (*AuthProviderMock) LoginTTL

func (mock *AuthProviderMock) LoginTTL() time.Duration

LoginTTL calls LoginTTLFunc.

func (*AuthProviderMock) LoginTTLCalls

func (mock *AuthProviderMock) LoginTTLCalls() []struct {
}

LoginTTLCalls gets all the calls that were made to LoginTTL. Check the length with:

len(mockedAuthProvider.LoginTTLCalls())

func (*AuthProviderMock) UserCanWrite

func (mock *AuthProviderMock) UserCanWrite(username string) bool

UserCanWrite calls UserCanWriteFunc.

func (*AuthProviderMock) UserCanWriteCalls

func (mock *AuthProviderMock) UserCanWriteCalls() []struct {
	Username string
}

UserCanWriteCalls gets all the calls that were made to UserCanWrite. Check the length with:

len(mockedAuthProvider.UserCanWriteCalls())

type GitServiceMock

type GitServiceMock struct {
	// CommitFunc mocks the Commit method.
	CommitFunc func(req git.CommitRequest) error

	// DeleteFunc mocks the Delete method.
	DeleteFunc func(key string, author git.Author) error

	// GetRevisionFunc mocks the GetRevision method.
	GetRevisionFunc func(key string, rev string) ([]byte, string, error)

	// HistoryFunc mocks the History method.
	HistoryFunc func(key string, limit int) ([]git.HistoryEntry, error)
	// contains filtered or unexported fields
}

GitServiceMock is a mock implementation of web.GitService.

func TestSomethingThatUsesGitService(t *testing.T) {

	// make and configure a mocked web.GitService
	mockedGitService := &GitServiceMock{
		CommitFunc: func(req git.CommitRequest) error {
			panic("mock out the Commit method")
		},
		DeleteFunc: func(key string, author git.Author) error {
			panic("mock out the Delete method")
		},
		GetRevisionFunc: func(key string, rev string) ([]byte, string, error) {
			panic("mock out the GetRevision method")
		},
		HistoryFunc: func(key string, limit int) ([]git.HistoryEntry, error) {
			panic("mock out the History method")
		},
	}

	// use mockedGitService in code that requires web.GitService
	// and then make assertions.

}

func (*GitServiceMock) Commit

func (mock *GitServiceMock) Commit(req git.CommitRequest) error

Commit calls CommitFunc.

func (*GitServiceMock) CommitCalls

func (mock *GitServiceMock) CommitCalls() []struct {
	Req git.CommitRequest
}

CommitCalls gets all the calls that were made to Commit. Check the length with:

len(mockedGitService.CommitCalls())

func (*GitServiceMock) Delete

func (mock *GitServiceMock) Delete(key string, author git.Author) error

Delete calls DeleteFunc.

func (*GitServiceMock) DeleteCalls

func (mock *GitServiceMock) DeleteCalls() []struct {
	Key    string
	Author git.Author
}

DeleteCalls gets all the calls that were made to Delete. Check the length with:

len(mockedGitService.DeleteCalls())

func (*GitServiceMock) GetRevision added in v0.12.0

func (mock *GitServiceMock) GetRevision(key string, rev string) ([]byte, string, error)

GetRevision calls GetRevisionFunc.

func (*GitServiceMock) GetRevisionCalls added in v0.12.0

func (mock *GitServiceMock) GetRevisionCalls() []struct {
	Key string
	Rev string
}

GetRevisionCalls gets all the calls that were made to GetRevision. Check the length with:

len(mockedGitService.GetRevisionCalls())

func (*GitServiceMock) History added in v0.12.0

func (mock *GitServiceMock) History(key string, limit int) ([]git.HistoryEntry, error)

History calls HistoryFunc.

func (*GitServiceMock) HistoryCalls added in v0.12.0

func (mock *GitServiceMock) HistoryCalls() []struct {
	Key   string
	Limit int
}

HistoryCalls gets all the calls that were made to History. Check the length with:

len(mockedGitService.HistoryCalls())

type KVStoreMock

type KVStoreMock struct {
	// DeleteFunc mocks the Delete method.
	DeleteFunc func(ctx context.Context, key string) error

	// GetInfoFunc mocks the GetInfo method.
	GetInfoFunc func(ctx context.Context, key string) (store.KeyInfo, error)

	// GetWithFormatFunc mocks the GetWithFormat method.
	GetWithFormatFunc func(ctx context.Context, key string) ([]byte, string, error)

	// ListFunc mocks the List method.
	ListFunc func(ctx context.Context, filter enum.SecretsFilter) ([]store.KeyInfo, error)

	// SecretsEnabledFunc mocks the SecretsEnabled method.
	SecretsEnabledFunc func() bool

	// SetFunc mocks the Set method.
	SetFunc func(ctx context.Context, key string, value []byte, format string) (bool, error)

	// SetWithVersionFunc mocks the SetWithVersion method.
	SetWithVersionFunc func(ctx context.Context, key string, value []byte, format string, expectedVersion time.Time) error
	// contains filtered or unexported fields
}

KVStoreMock is a mock implementation of web.KVStore.

func TestSomethingThatUsesKVStore(t *testing.T) {

	// make and configure a mocked web.KVStore
	mockedKVStore := &KVStoreMock{
		DeleteFunc: func(ctx context.Context, key string) error {
			panic("mock out the Delete method")
		},
		GetInfoFunc: func(ctx context.Context, key string) (store.KeyInfo, error) {
			panic("mock out the GetInfo method")
		},
		GetWithFormatFunc: func(ctx context.Context, key string) ([]byte, string, error) {
			panic("mock out the GetWithFormat method")
		},
		ListFunc: func(ctx context.Context, filter enum.SecretsFilter) ([]store.KeyInfo, error) {
			panic("mock out the List method")
		},
		SecretsEnabledFunc: func() bool {
			panic("mock out the SecretsEnabled method")
		},
		SetFunc: func(ctx context.Context, key string, value []byte, format string) (bool, error) {
			panic("mock out the Set method")
		},
		SetWithVersionFunc: func(ctx context.Context, key string, value []byte, format string, expectedVersion time.Time) error {
			panic("mock out the SetWithVersion method")
		},
	}

	// use mockedKVStore in code that requires web.KVStore
	// and then make assertions.

}

func (*KVStoreMock) Delete

func (mock *KVStoreMock) Delete(ctx context.Context, key string) error

Delete calls DeleteFunc.

func (*KVStoreMock) DeleteCalls

func (mock *KVStoreMock) DeleteCalls() []struct {
	Ctx context.Context
	Key string
}

DeleteCalls gets all the calls that were made to Delete. Check the length with:

len(mockedKVStore.DeleteCalls())

func (*KVStoreMock) GetInfo

func (mock *KVStoreMock) GetInfo(ctx context.Context, key string) (store.KeyInfo, error)

GetInfo calls GetInfoFunc.

func (*KVStoreMock) GetInfoCalls

func (mock *KVStoreMock) GetInfoCalls() []struct {
	Ctx context.Context
	Key string
}

GetInfoCalls gets all the calls that were made to GetInfo. Check the length with:

len(mockedKVStore.GetInfoCalls())

func (*KVStoreMock) GetWithFormat

func (mock *KVStoreMock) GetWithFormat(ctx context.Context, key string) ([]byte, string, error)

GetWithFormat calls GetWithFormatFunc.

func (*KVStoreMock) GetWithFormatCalls

func (mock *KVStoreMock) GetWithFormatCalls() []struct {
	Ctx context.Context
	Key string
}

GetWithFormatCalls gets all the calls that were made to GetWithFormat. Check the length with:

len(mockedKVStore.GetWithFormatCalls())

func (*KVStoreMock) List

func (mock *KVStoreMock) List(ctx context.Context, filter enum.SecretsFilter) ([]store.KeyInfo, error)

List calls ListFunc.

func (*KVStoreMock) ListCalls

func (mock *KVStoreMock) ListCalls() []struct {
	Ctx    context.Context
	Filter enum.SecretsFilter
}

ListCalls gets all the calls that were made to List. Check the length with:

len(mockedKVStore.ListCalls())

func (*KVStoreMock) SecretsEnabled added in v0.15.0

func (mock *KVStoreMock) SecretsEnabled() bool

SecretsEnabled calls SecretsEnabledFunc.

func (*KVStoreMock) SecretsEnabledCalls added in v0.15.0

func (mock *KVStoreMock) SecretsEnabledCalls() []struct {
}

SecretsEnabledCalls gets all the calls that were made to SecretsEnabled. Check the length with:

len(mockedKVStore.SecretsEnabledCalls())

func (*KVStoreMock) Set

func (mock *KVStoreMock) Set(ctx context.Context, key string, value []byte, format string) (bool, error)

Set calls SetFunc.

func (*KVStoreMock) SetCalls

func (mock *KVStoreMock) SetCalls() []struct {
	Ctx    context.Context
	Key    string
	Value  []byte
	Format string
}

SetCalls gets all the calls that were made to Set. Check the length with:

len(mockedKVStore.SetCalls())

func (*KVStoreMock) SetWithVersion added in v0.10.1

func (mock *KVStoreMock) SetWithVersion(ctx context.Context, key string, value []byte, format string, expectedVersion time.Time) error

SetWithVersion calls SetWithVersionFunc.

func (*KVStoreMock) SetWithVersionCalls added in v0.10.1

func (mock *KVStoreMock) SetWithVersionCalls() []struct {
	Ctx             context.Context
	Key             string
	Value           []byte
	Format          string
	ExpectedVersion time.Time
}

SetWithVersionCalls gets all the calls that were made to SetWithVersion. Check the length with:

len(mockedKVStore.SetWithVersionCalls())

type ValidatorMock

type ValidatorMock struct {
	// IsValidFormatFunc mocks the IsValidFormat method.
	IsValidFormatFunc func(format string) bool

	// SupportedFormatsFunc mocks the SupportedFormats method.
	SupportedFormatsFunc func() []string

	// ValidateFunc mocks the Validate method.
	ValidateFunc func(format string, value []byte) error
	// contains filtered or unexported fields
}

ValidatorMock is a mock implementation of web.Validator.

func TestSomethingThatUsesValidator(t *testing.T) {

	// make and configure a mocked web.Validator
	mockedValidator := &ValidatorMock{
		IsValidFormatFunc: func(format string) bool {
			panic("mock out the IsValidFormat method")
		},
		SupportedFormatsFunc: func() []string {
			panic("mock out the SupportedFormats method")
		},
		ValidateFunc: func(format string, value []byte) error {
			panic("mock out the Validate method")
		},
	}

	// use mockedValidator in code that requires web.Validator
	// and then make assertions.

}

func (*ValidatorMock) IsValidFormat

func (mock *ValidatorMock) IsValidFormat(format string) bool

IsValidFormat calls IsValidFormatFunc.

func (*ValidatorMock) IsValidFormatCalls

func (mock *ValidatorMock) IsValidFormatCalls() []struct {
	Format string
}

IsValidFormatCalls gets all the calls that were made to IsValidFormat. Check the length with:

len(mockedValidator.IsValidFormatCalls())

func (*ValidatorMock) SupportedFormats

func (mock *ValidatorMock) SupportedFormats() []string

SupportedFormats calls SupportedFormatsFunc.

func (*ValidatorMock) SupportedFormatsCalls

func (mock *ValidatorMock) SupportedFormatsCalls() []struct {
}

SupportedFormatsCalls gets all the calls that were made to SupportedFormats. Check the length with:

len(mockedValidator.SupportedFormatsCalls())

func (*ValidatorMock) Validate

func (mock *ValidatorMock) Validate(format string, value []byte) error

Validate calls ValidateFunc.

func (*ValidatorMock) ValidateCalls

func (mock *ValidatorMock) ValidateCalls() []struct {
	Format string
	Value  []byte
}

ValidateCalls gets all the calls that were made to Validate. Check the length with:

len(mockedValidator.ValidateCalls())

Jump to

Keyboard shortcuts

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