fakeclient

package
v0.32.2-0...-071f0ac Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package fakeclient provides mock implementations of the client to be used for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessRuleService

type AccessRuleService struct {
	DeleteFunc        func(path string, accountName string) error
	GetFunc           func(path string, accountName string) (*api.AccessRule, error)
	ListLevelsFunc    func(path string) ([]*api.AccessLevel, error)
	ListFunc          func(path string, depth int, ancestors bool) ([]*api.AccessRule, error)
	SetFunc           func(path string, permission string, accountName string) (*api.AccessRule, error)
	IteratorFunc      func() secrethub.AccessRuleIterator
	LevelIteratorFunc func() secrethub.AccessLevelIterator
}

AccessRuleService is a mock of the AccessRuleService interface.

func (*AccessRuleService) Delete

func (s *AccessRuleService) Delete(path string, accountName string) error

Delete implements the AccessRuleService interface Delete function.

func (*AccessRuleService) Get

func (s *AccessRuleService) Get(path string, accountName string) (*api.AccessRule, error)

Get implements the AccessRuleService interface Get function.

func (*AccessRuleService) Iterator

func (*AccessRuleService) LevelIterator

func (*AccessRuleService) List

func (s *AccessRuleService) List(path string, depth int, ancestors bool) ([]*api.AccessRule, error)

List implements the AccessRuleService interface List function.

func (*AccessRuleService) ListLevels

func (s *AccessRuleService) ListLevels(path string) ([]*api.AccessLevel, error)

ListLevels implements the AccessRuleService interface ListLevels function.

func (*AccessRuleService) Set

func (s *AccessRuleService) Set(path string, permission string, accountName string) (*api.AccessRule, error)

Set implements the AccessRuleService interface Set function.

type AccountService

type AccountService struct {
	MeFunc            func() (*api.Account, error)
	GetFunc           func(name string) (*api.Account, error)
	AccountKeyService secrethub.AccountKeyService
}

AccountService is a mock of the AccountService interface.

func (*AccountService) Get

func (s *AccountService) Get(name string) (*api.Account, error)

Get implements the AccountService interface Get function.

func (*AccountService) Keys

func (*AccountService) Me

func (s *AccountService) Me() (*api.Account, error)

Me implements the AccountService interface Me function.

type AuditEventIterator

type AuditEventIterator struct {
	Events []api.Audit
	Err    error
	// contains filtered or unexported fields
}

func (*AuditEventIterator) Next

func (iter *AuditEventIterator) Next() (api.Audit, error)

type Client

type Client struct {
	AccessRuleService *AccessRuleService
	AccountService    *AccountService
	CredentialService *CredentialService
	DirService        *DirService
	IDPLinkService    *IDPLinkService
	MeService         *MeService
	OrgService        *OrgService
	RepoService       *RepoService
	SecretService     *SecretService
	ServiceService    *ServiceService
	UserService       *UserService
}

Client implements the secrethub.Client interface.

func (Client) AccessRules

func (c Client) AccessRules() secrethub.AccessRuleService

AccessRules implements the secrethub.Client interface.

func (Client) Accounts

func (c Client) Accounts() secrethub.AccountService

Accounts implements the secrethub.Client interface.

func (Client) Credentials

func (c Client) Credentials() secrethub.CredentialService

func (Client) Dirs

func (c Client) Dirs() secrethub.DirService

Dirs implements the secrethub.Client interface.

func (c Client) IDPLinks() secrethub.IDPLinkService

func (Client) Me

func (c Client) Me() secrethub.MeService

Me implements the secrethub.Client interface.

func (Client) Orgs

func (c Client) Orgs() secrethub.OrgService

Orgs implements the secrethub.Client interface.

func (Client) Repos

func (c Client) Repos() secrethub.RepoService

Repos implements the secrethub.Client interface.

func (Client) Secrets

func (c Client) Secrets() secrethub.SecretService

Secrets implements the secrethub.Client interface.

func (Client) Services

func (c Client) Services() secrethub.ServiceService

Services implements the secrethub.Client interface.

func (Client) Users

func (c Client) Users() secrethub.UserService

Users implements the secrethub.Client interface.

type CredentialIterator

type CredentialIterator struct {
	Credentials  []*api.Credential
	CurrentIndex int
	Err          error
}

func (*CredentialIterator) Next

func (c *CredentialIterator) Next() (api.Credential, error)

type CredentialService

type CredentialService struct {
	CreateFunc  func(credentials.Creator, string) (*api.Credential, error)
	DisableFunc func(fingerprint string) error
	ListFunc    func(_ *secrethub.CredentialListParams) secrethub.CredentialIterator
}

func (*CredentialService) Create

func (c *CredentialService) Create(creator credentials.Creator, description string) (*api.Credential, error)

func (*CredentialService) Disable

func (c *CredentialService) Disable(fingerprint string) error

func (*CredentialService) List

type DirService

type DirService struct {
	CreateFunc  func(path string) (*api.Dir, error)
	ExistsFunc  func(path string) (bool, error)
	DeleteFunc  func(path string) error
	GetTreeFunc func(path string, depth int, ancestors bool) (*api.Tree, error)
	secrethub.DirService
}

DirService is a mock of the DirService interface.

func (*DirService) Create

func (s *DirService) Create(path string) (*api.Dir, error)

Create implements the DirService interface Create function.

func (*DirService) Delete

func (s *DirService) Delete(path string) error

Delete implements the DirService interface Delete function.

func (*DirService) Exists

func (s *DirService) Exists(path string) (bool, error)

Exists implements the DirService interface Exists function.

func (*DirService) GetTree

func (s *DirService) GetTree(path string, depth int, ancestors bool) (*api.Tree, error)

GetTree implements the DirService interface GetTree function.

type IDPLinkGCPService

type IDPLinkGCPService struct {
	CreateFunc                    func(namespace string, projectID string, authorizationCode string, redirectURI string) (*api.IdentityProviderLink, error)
	ListFunc                      func(namespace string, params *secrethub.IdpLinkIteratorParams) secrethub.IdpLinkIterator
	GetFunc                       func(namespace string, projectID string) (*api.IdentityProviderLink, error)
	ExistsFunc                    func(namespace string, projectID string) (bool, error)
	DeleteFunc                    func(namespace string, projectID string) error
	AuthorizationCodeListenerFunc func(namespace string, projectID string) (oauthorizer.CallbackHandler, error)
}

func (IDPLinkGCPService) AuthorizationCodeListener

func (i IDPLinkGCPService) AuthorizationCodeListener(namespace string, projectID string) (oauthorizer.CallbackHandler, error)

func (IDPLinkGCPService) Create

func (i IDPLinkGCPService) Create(namespace string, projectID string, authorizationCode, redirectURI string) (*api.IdentityProviderLink, error)

func (IDPLinkGCPService) Delete

func (i IDPLinkGCPService) Delete(namespace string, projectID string) error

func (IDPLinkGCPService) Exists

func (i IDPLinkGCPService) Exists(namespace string, projectID string) (bool, error)

func (IDPLinkGCPService) Get

func (i IDPLinkGCPService) Get(namespace string, projectID string) (*api.IdentityProviderLink, error)

func (IDPLinkGCPService) List

type IDPLinkIterator

type IDPLinkIterator struct {
	IDPLinks     []*api.IdentityProviderLink
	CurrentIndex int
	Err          error
}

func (*IDPLinkIterator) Next

type IDPLinkService

type IDPLinkService struct {
	GCPService secrethub.IDPLinkGCPService
}

func (IDPLinkService) GCP

type MeService

type MeService struct {
	GetUserFunc               func() (*api.User, error)
	SendVerificationEmailFunc func() error
	ListReposFunc             func() ([]*api.Repo, error)
	RepoIteratorFunc          func(_ *secrethub.RepoIteratorParams) secrethub.RepoIterator
}

func (*MeService) GetUser

func (m *MeService) GetUser() (*api.User, error)

func (*MeService) ListRepos

func (m *MeService) ListRepos() ([]*api.Repo, error)

func (*MeService) RepoIterator

func (m *MeService) RepoIterator(repoIteratorParams *secrethub.RepoIteratorParams) secrethub.RepoIterator

func (*MeService) SendVerificationEmail

func (m *MeService) SendVerificationEmail() error

type OrgMemberService

type OrgMemberService struct {
	InviteFunc   func(org string, username string, role string) (*api.OrgMember, error)
	GetFunc      func(org string, username string) (*api.OrgMember, error)
	UpdateFunc   func(org string, username string, role string) (*api.OrgMember, error)
	RevokeFunc   func(org string, username string, opts *api.RevokeOpts) (*api.RevokeOrgResponse, error)
	ListFunc     func(org string) ([]*api.OrgMember, error)
	IteratorFunc func(org string, params *secrethub.OrgMemberIteratorParams) secrethub.OrgMemberIterator
}

OrgMemberService is a mock of the OrgMemberService interface.

func (*OrgMemberService) Get

func (s *OrgMemberService) Get(org string, username string) (*api.OrgMember, error)

func (*OrgMemberService) Invite

func (s *OrgMemberService) Invite(org string, username string, role string) (*api.OrgMember, error)

func (*OrgMemberService) Iterator

func (*OrgMemberService) List

func (s *OrgMemberService) List(org string) ([]*api.OrgMember, error)

func (*OrgMemberService) Revoke

func (s *OrgMemberService) Revoke(org string, username string, opts *api.RevokeOpts) (*api.RevokeOrgResponse, error)

func (*OrgMemberService) Update

func (s *OrgMemberService) Update(org string, username string, role string) (*api.OrgMember, error)

type OrgService

type OrgService struct {
	CreateFunc     func(name string, description string) (*api.Org, error)
	DeleteFunc     func(name string) error
	GetFunc        func(name string) (*api.Org, error)
	MembersService secrethub.OrgMemberService
	ListMineFunc   func() ([]*api.Org, error)
	IteratorFunc   func(params *secrethub.OrgIteratorParams) secrethub.OrgIterator
}

OrgService is a mock of the RepoService interface.

func (*OrgService) Create

func (s *OrgService) Create(name string, description string) (*api.Org, error)

Create implements the RepoService interface Create function.

func (*OrgService) Delete

func (s *OrgService) Delete(name string) error

Delete implements the RepoService interface Delete function.

func (*OrgService) Get

func (s *OrgService) Get(name string) (*api.Org, error)

Get implements the RepoService interface Get function.

func (*OrgService) Iterator

func (*OrgService) ListMine

func (s *OrgService) ListMine() ([]*api.Org, error)

ListMine implements the RepoService interface ListMine function.

func (*OrgService) Members

func (s *OrgService) Members() secrethub.OrgMemberService

Members returns a mock of the OrgMemberService interface.

type RepoService

type RepoService struct {
	ListFunc           func(namespace string) ([]*api.Repo, error)
	ListAccountsFunc   func(path string) ([]*api.Account, error)
	ListEventsFunc     func(path string, subjectTypes api.AuditSubjectTypeList) ([]*api.Audit, error)
	ListMineFunc       func() ([]*api.Repo, error)
	CreateFunc         func(path string) (*api.Repo, error)
	DeleteFunc         func(path string) error
	GetFunc            func(path string) (*api.Repo, error)
	UserService        secrethub.RepoUserService
	RepoServiceService secrethub.RepoServiceService
	AuditEventIterator *AuditEventIterator
	secrethub.RepoService
}

RepoService is a mock of the RepoService interface.

func (*RepoService) Create

func (s *RepoService) Create(path string) (*api.Repo, error)

Create implements the RepoService interface Create function.

func (*RepoService) Delete

func (s *RepoService) Delete(path string) error

Delete implements the RepoService interface Delete function.

func (*RepoService) EventIterator

EventIterator implements the RepoService interface EventIterator function.

func (*RepoService) Get

func (s *RepoService) Get(path string) (*api.Repo, error)

Get implements the RepoService interface Get function.

func (*RepoService) List

func (s *RepoService) List(namespace string) ([]*api.Repo, error)

List implements the RepoService interface List function.

func (*RepoService) ListAccounts

func (s *RepoService) ListAccounts(path string) ([]*api.Account, error)

ListAccounts implements the RepoService interface ListAccounts function.

func (*RepoService) ListEvents

func (s *RepoService) ListEvents(path string, subjectTypes api.AuditSubjectTypeList) ([]*api.Audit, error)

ListEvents implements the RepoService interface ListEvents function.

func (*RepoService) ListMine

func (s *RepoService) ListMine() ([]*api.Repo, error)

ListMine implements the RepoService interface ListMine function.

func (*RepoService) Services

Services returns the mocked RepoServiceService.

func (*RepoService) Users

Users returns the mocked UserService.

type RepoServiceService

type RepoServiceService struct {
	ListFunc     func(path string) ([]*api.Service, error)
	IteratorFunc func() secrethub.ServiceIterator
}

RepoServiceService is a mock of the RepoServiceService interface.

func (*RepoServiceService) Iterator

func (*RepoServiceService) List

func (s *RepoServiceService) List(path string) ([]*api.Service, error)

List implements the RepoServiceService interface List function.

type RepoUserService

type RepoUserService struct {
	InviteFunc   func(path string, username string) (*api.RepoMember, error)
	ListFunc     func(path string) ([]*api.User, error)
	RevokeFunc   func(path string, username string) (*api.RevokeRepoResponse, error)
	IteratorFunc func() secrethub.UserIterator
}

RepoUserService is a mock of the RepoUserService interface.

func (*RepoUserService) Invite

func (s *RepoUserService) Invite(path string, username string) (*api.RepoMember, error)

Invite implements the RepoUserService interface Invite function.

func (*RepoUserService) Iterator

func (*RepoUserService) List

func (s *RepoUserService) List(path string) ([]*api.User, error)

List implements the RepoUserService interface List function.

func (*RepoUserService) Revoke

func (s *RepoUserService) Revoke(path string, username string) (*api.RevokeRepoResponse, error)

Revoke implements the RepoUserService interface Revoke function.

type SecretDeleter

type SecretDeleter struct {
	ArgPath string
	Err     error
}

SecretDeleter mocks the Delete function.

func (*SecretDeleter) Delete

func (d *SecretDeleter) Delete(path string) error

Delete saves the arguments it was called with and returns the mocked response.

type SecretEventLister

type SecretEventLister struct {
	ArgPath            string
	ArgSubjectTypes    api.AuditSubjectTypeList
	ReturnsAuditEvents []*api.Audit
	Err                error
}

SecretEventLister mocks the ListEvents function.

func (*SecretEventLister) ListEvents

func (s *SecretEventLister) ListEvents(path string, subjectTypes api.AuditSubjectTypeList) ([]*api.Audit, error)

ListEvents saves the arguments it was called with and returns the mocked response.

type SecretGetter

type SecretGetter struct {
	ArgPath       string
	ReturnsSecret *api.Secret
	Err           error
}

SecretGetter mocks the Get function.

func (*SecretGetter) Get

func (g *SecretGetter) Get(path string) (*api.Secret, error)

Get saves the arguments it was called with and returns the mocked response.

type SecretReader

type SecretReader struct {
	ArgPath        string
	ReturnsVersion *api.SecretVersion
	Err            error
}

SecretReader mocks the Read function

func (*SecretReader) Read

func (r *SecretReader) Read(path string) (*api.SecretVersion, error)

Read saves the arguments it was called with and returns the mocked response

func (*SecretReader) ReadString

func (r *SecretReader) ReadString(path string) (string, error)

ReadString saves the arguments it was called with and returns the mocked response

type SecretService

type SecretService struct {
	VersionService     secrethub.SecretVersionService
	DeleteFunc         func(path string) error
	GetFunc            func(path string) (*api.Secret, error)
	ReadFunc           func(path string) (*api.SecretVersion, error)
	ReadStringFunc     func(path string) (string, error)
	ExistsFunc         func(path string) (bool, error)
	WriteFunc          func(path string, data []byte) (*api.SecretVersion, error)
	ListEventsFunc     func(path string, subjectTypes api.AuditSubjectTypeList) ([]*api.Audit, error)
	AuditEventIterator *AuditEventIterator
}

SecretService is a mock of the SecretService interface.

func (*SecretService) Delete

func (s *SecretService) Delete(path string) error

Delete implements the SecretService interface Delete function.

func (*SecretService) EventIterator

EventIterator implements the SecretService interface EventIterator function.

func (*SecretService) Exists

func (s *SecretService) Exists(path string) (bool, error)

Exists implements the SecretService interface Exists function.

func (*SecretService) Get

func (s *SecretService) Get(path string) (*api.Secret, error)

Get implements the SecretService interface Get function.

func (*SecretService) ListEvents

func (s *SecretService) ListEvents(path string, subjectTypes api.AuditSubjectTypeList) ([]*api.Audit, error)

ListEvents implements the SecretService interface ListEvents function.

func (*SecretService) Read

func (s *SecretService) Read(path string) (*api.SecretVersion, error)

func (*SecretService) ReadString

func (s *SecretService) ReadString(path string) (string, error)

func (*SecretService) Versions

Versions returns a mock of the VersionService interface.

func (*SecretService) Write

func (s *SecretService) Write(path string, data []byte) (*api.SecretVersion, error)

Write implements the SecretService interface Write function.

type SecretVersionService

type SecretVersionService struct {
	DeleteFunc          func(path string) error
	GetWithDataFunc     func(path string) (*api.SecretVersion, error)
	GetWithoutDataFunc  func(path string) (*api.SecretVersion, error)
	ListWithDataFunc    func(path string) ([]*api.SecretVersion, error)
	ListWithoutDataFunc func(path string) ([]*api.SecretVersion, error)
	IteratorFunc        func(path string, params *secrethub.SecretVersionIteratorParams) secrethub.SecretVersionIterator
}

SecretVersionService can be used to mock a SecretVersionService.

func (*SecretVersionService) Delete

func (s *SecretVersionService) Delete(path string) error

Delete implements the SecretVersionService interface Delete function.

func (*SecretVersionService) GetWithData

func (s *SecretVersionService) GetWithData(path string) (*api.SecretVersion, error)

GetWithData implements the SecretVersionService interface GetWithData function.

func (*SecretVersionService) GetWithoutData

func (s *SecretVersionService) GetWithoutData(path string) (*api.SecretVersion, error)

GetWithoutData implements the SecretVersionService interface GetWithoutData function.

func (*SecretVersionService) Iterator

func (*SecretVersionService) ListWithData

func (s *SecretVersionService) ListWithData(path string) ([]*api.SecretVersion, error)

ListWithData implements the SecretVersionService interface ListWithData function.

func (*SecretVersionService) ListWithoutData

func (s *SecretVersionService) ListWithoutData(path string) ([]*api.SecretVersion, error)

ListWithoutData implements the SecretVersionService interface ListWithoutData function.

type ServiceAWSService

type ServiceAWSService struct {
	CreateFunc func(path string, description string, keyID, role string, cfgs ...*aws.Config) (*api.Service, error)
}

ServiceAWSService is a mock of the ServiceAWSService interface.

func (*ServiceAWSService) Create

func (s *ServiceAWSService) Create(path string, description string, keyID, role string, cfgs ...*aws.Config) (*api.Service, error)

Create implements the ServiceAWSService interface Create function.

type ServiceService

type ServiceService struct {
	CreateFunc func(path string, description string, credentialCreator credentials.Creator) (*api.Service, error)
	DeleteFunc func(id string) (*api.RevokeRepoResponse, error)
	GetFunc    func(id string) (*api.Service, error)
	ListFunc   func(path string) ([]*api.Service, error)
	AWSService *ServiceAWSService

	IteratorFunc func() secrethub.ServiceIterator
}

ServiceService is a mock of the ServiceService interface.

func (*ServiceService) Create

func (s *ServiceService) Create(path string, description string, credentialCreator credentials.Creator) (*api.Service, error)

Create implements the ServiceService interface Create function.

func (*ServiceService) Delete

func (s *ServiceService) Delete(id string) (*api.RevokeRepoResponse, error)

Delete implements the ServiceService interface Delete function.

func (*ServiceService) Get

func (s *ServiceService) Get(id string) (*api.Service, error)

Get implements the ServiceService interface Get function.

func (*ServiceService) Iterator

func (*ServiceService) List

func (s *ServiceService) List(path string) ([]*api.Service, error)

List implements the ServiceService interface List function.

type UserService

type UserService struct {
	GetFunc func(username string) (*api.User, error)
	MeFunc  func() (*api.User, error)
}

UserService is a mock of the UserService interface.

func (*UserService) Get

func (s *UserService) Get(username string) (*api.User, error)

Get implements the UserService interface Get function.

func (*UserService) Me

func (s *UserService) Me() (*api.User, error)

Me implements the UserService interface Me function.

type Writer

type Writer struct {
	ArgPath        string
	ArgData        []byte
	ReturnsVersion *api.SecretVersion
	Err            error
}

Writer is a wrapper for the arguments and return values of the mocked Writer method.

func (*Writer) Write

func (w *Writer) Write(path string, data []byte) (*api.SecretVersion, error)

Writer saves the arguments it was called with and returns the mocked response.

Jump to

Keyboard shortcuts

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