mock

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusEP         = "/v1/status"
	RegisterEP       = "/v1/register"
	LoginEP          = "/v1/login"
	AuthenticateEP   = "/v1/authenticate"
	RefreshEP        = "/v1/refresh"
	SwitchEP         = "/v1/switch"
	VerifyEP         = "/v1/verify"
	ResendEP         = "/v1/resend"
	ForgotPasswordEP = "/v1/forgot-password"
	ResetPasswordEP  = "/v1/reset-password"
	APIKeysEP        = "/v1/apikeys"
	ProjectsEP       = "/v1/projects"
	OrganizationsEP  = "/v1/organizations"
	UsersEP          = "/v1/users"
	InvitesEP        = "/v1/invites"
	WorkspaceEP      = "/v1/workspace"
	AccountsEP       = "/v1/accounts"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HandlerOption

type HandlerOption func(*handlerOptions)

HandlerOption allows users of the mock to configure specific endpoint handler behavior or override it entirely.

func RequireAuth added in v0.3.0

func RequireAuth() HandlerOption

Return a 401 response if the request is not authenticated

func UseError added in v0.3.0

func UseError(status int, err string) HandlerOption

Configure a basic error reply to be returned by the handler

func UseHandler

func UseHandler(f http.HandlerFunc) HandlerOption

Use the given handler, overriding all other options

func UseJSONFixture

func UseJSONFixture(fixture interface{}) HandlerOption

Configure a JSON fixture to be returned by the handler

func UseStatus

func UseStatus(status int) HandlerOption

Configure the status code to be returned by the handler

type Server

type Server struct {
	sync.RWMutex
	*httptest.Server
	// contains filtered or unexported fields
}

Server embeds an httptest Server and provides additional methods for configuring mock responses and counting requests. By default handlers will panic, it's the responsibility of the test writer to configure the behavior of each handler that will be invoked by using the appropriate On* method and passing in the desired HandlerOption(s). If no HandlerOption is specified, the default behavior is to return a 200 OK response with an empty body.

func NewServer

func NewServer() (s *Server, err error)

NewServer creates and starts a new mock server for testing Quarterdeck interactions.

func (*Server) APIKeysCreateCount added in v0.8.0

func (s *Server) APIKeysCreateCount() int

func (*Server) APIKeysDeleteCount added in v0.8.0

func (s *Server) APIKeysDeleteCount(id string) int

func (*Server) APIKeysDetailCount added in v0.8.0

func (s *Server) APIKeysDetailCount(id string) int

func (*Server) APIKeysListCount added in v0.8.0

func (s *Server) APIKeysListCount() int

func (*Server) APIKeysPermissionsCount added in v0.8.0

func (s *Server) APIKeysPermissionsCount() int

func (*Server) APIKeysUpdateCount added in v0.8.0

func (s *Server) APIKeysUpdateCount(id string) int

func (*Server) AccountUpdateCount added in v0.10.0

func (s *Server) AccountUpdateCount(id string) int

func (*Server) AuthenticateCount

func (s *Server) AuthenticateCount() int

func (*Server) Close

func (s *Server) Close()

func (*Server) CreateAccessToken added in v0.10.0

func (s *Server) CreateAccessToken(claims *tokens.Claims) (string, error)

func (*Server) CreateTokenPair added in v0.10.0

func (s *Server) CreateTokenPair(claims *tokens.Claims) (string, string, error)

func (*Server) ForgotPasswordCount added in v0.11.0

func (s *Server) ForgotPasswordCount() int

func (*Server) InvitesAcceptCount added in v0.10.0

func (s *Server) InvitesAcceptCount() int

func (*Server) InvitesCreateCount added in v0.8.0

func (s *Server) InvitesCreateCount() int

func (*Server) InvitesPreviewCount added in v0.8.0

func (s *Server) InvitesPreviewCount(token string) int

func (*Server) LoginCount

func (s *Server) LoginCount() int

func (*Server) OnAPIKeysCreate added in v0.8.0

func (s *Server) OnAPIKeysCreate(opts ...HandlerOption)

func (*Server) OnAPIKeysDelete added in v0.8.0

func (s *Server) OnAPIKeysDelete(id string, opts ...HandlerOption)

func (*Server) OnAPIKeysDetail added in v0.8.0

func (s *Server) OnAPIKeysDetail(id string, opts ...HandlerOption)

func (*Server) OnAPIKeysList added in v0.8.0

func (s *Server) OnAPIKeysList(opts ...HandlerOption)

func (*Server) OnAPIKeysPermissions added in v0.8.0

func (s *Server) OnAPIKeysPermissions(opts ...HandlerOption)

func (*Server) OnAPIKeysUpdate added in v0.8.0

func (s *Server) OnAPIKeysUpdate(id string, opts ...HandlerOption)

func (*Server) OnAccountUpdate added in v0.10.0

func (s *Server) OnAccountUpdate(id string, opts ...HandlerOption)

func (*Server) OnAuthenticate

func (s *Server) OnAuthenticate(opts ...HandlerOption)

func (*Server) OnForgotPassword added in v0.11.0

func (s *Server) OnForgotPassword(opts ...HandlerOption)

func (*Server) OnInvitesAccept added in v0.10.0

func (s *Server) OnInvitesAccept(opts ...HandlerOption)

func (*Server) OnInvitesCreate added in v0.8.0

func (s *Server) OnInvitesCreate(opts ...HandlerOption)

func (*Server) OnInvitesPreview added in v0.8.0

func (s *Server) OnInvitesPreview(token string, opts ...HandlerOption)

func (*Server) OnLogin

func (s *Server) OnLogin(opts ...HandlerOption)

func (*Server) OnOrganizations added in v0.4.0

func (s *Server) OnOrganizations(param string, opts ...HandlerOption)

func (*Server) OnOrganizationsUpdate added in v0.10.0

func (s *Server) OnOrganizationsUpdate(id string, opts ...HandlerOption)

func (*Server) OnProjectsAccess added in v0.8.0

func (s *Server) OnProjectsAccess(opts ...HandlerOption)

func (*Server) OnProjectsCreate added in v0.8.0

func (s *Server) OnProjectsCreate(opts ...HandlerOption)

func (*Server) OnProjectsDetail added in v0.8.0

func (s *Server) OnProjectsDetail(id string, opts ...HandlerOption)

func (*Server) OnProjectsList added in v0.8.0

func (s *Server) OnProjectsList(opts ...HandlerOption)

func (*Server) OnRefresh

func (s *Server) OnRefresh(opts ...HandlerOption)

func (*Server) OnRegister

func (s *Server) OnRegister(opts ...HandlerOption)

func (*Server) OnResendEmail added in v0.10.0

func (s *Server) OnResendEmail(opts ...HandlerOption)

func (*Server) OnResetPassword added in v0.11.0

func (s *Server) OnResetPassword(opts ...HandlerOption)

func (*Server) OnStatus

func (s *Server) OnStatus(opts ...HandlerOption)

Endpoint handlers

func (*Server) OnSwitch added in v0.5.2

func (s *Server) OnSwitch(opts ...HandlerOption)

func (*Server) OnUsersDetail added in v0.8.0

func (s *Server) OnUsersDetail(id string, opts ...HandlerOption)

func (*Server) OnUsersList added in v0.8.0

func (s *Server) OnUsersList(opts ...HandlerOption)

func (*Server) OnUsersRemove added in v0.8.0

func (s *Server) OnUsersRemove(id string, opts ...HandlerOption)

func (*Server) OnUsersRemoveConfirm added in v0.8.0

func (s *Server) OnUsersRemoveConfirm(id string, opts ...HandlerOption)

func (*Server) OnUsersRoleUpdate added in v0.8.0

func (s *Server) OnUsersRoleUpdate(id string, opts ...HandlerOption)

func (*Server) OnUsersUpdate added in v0.8.0

func (s *Server) OnUsersUpdate(id string, opts ...HandlerOption)

func (*Server) OnVerify added in v0.5.0

func (s *Server) OnVerify(opts ...HandlerOption)

func (*Server) OnWorkspace added in v0.10.0

func (s *Server) OnWorkspace(opts ...HandlerOption)

func (*Server) OrganizationsCount added in v0.4.0

func (s *Server) OrganizationsCount(param string) int

func (*Server) OrganizationsUpdateCount added in v0.10.0

func (s *Server) OrganizationsUpdateCount(id string) int

func (*Server) ProjectsAccessCount added in v0.8.0

func (s *Server) ProjectsAccessCount() int

func (*Server) ProjectsCreateCount added in v0.8.0

func (s *Server) ProjectsCreateCount() int

func (*Server) ProjectsDetailCount added in v0.8.0

func (s *Server) ProjectsDetailCount(id string) int

func (*Server) ProjectsListCount added in v0.8.0

func (s *Server) ProjectsListCount() int

func (*Server) RefreshCount

func (s *Server) RefreshCount() int

func (*Server) RegisterCount

func (s *Server) RegisterCount() int

func (*Server) ResendEmailCount added in v0.10.0

func (s *Server) ResendEmailCount() int

func (*Server) Reset added in v0.3.0

func (s *Server) Reset()

func (*Server) ResetPasswordCount added in v0.11.0

func (s *Server) ResetPasswordCount() int

func (*Server) StatusCount

func (s *Server) StatusCount() int

Request counters

func (*Server) SwitchCount added in v0.5.2

func (s *Server) SwitchCount() int

func (*Server) URL

func (s *Server) URL() string

func (*Server) UsersDetailCount added in v0.8.0

func (s *Server) UsersDetailCount(id string) int

func (*Server) UsersListCount added in v0.8.0

func (s *Server) UsersListCount() int

func (*Server) UsersRemoveConfirmCount added in v0.8.0

func (s *Server) UsersRemoveConfirmCount(id string) int

func (*Server) UsersRemoveCount added in v0.8.0

func (s *Server) UsersRemoveCount(id string) int

func (*Server) UsersRoleUpdateCount added in v0.8.0

func (s *Server) UsersRoleUpdateCount(id string) int

func (*Server) UsersUpdateCount added in v0.8.0

func (s *Server) UsersUpdateCount(id string) int

func (*Server) VerifyCount added in v0.5.0

func (s *Server) VerifyCount() int

func (*Server) WorkspaceCount added in v0.10.0

func (s *Server) WorkspaceCount() int

Jump to

Keyboard shortcuts

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