mocks

package
v0.0.0-...-83c72ea Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package mocks defines implemented interfaces for testing modules

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockRequest

func MockRequest(method string, postKeyValues ...string) *http.Request

MockRequest returns a new mock request with optional key-value body (form-post)

Types

type MockAfterCallback

type MockAfterCallback struct {
	HasBeenCalled bool
	Fn            authboss.After
}

MockAfterCallback is a callback that knows if it was called

func NewMockAfterCallback

func NewMockAfterCallback() *MockAfterCallback

NewMockAfterCallback constructs a new mockaftercallback.

type MockClientStorer

type MockClientStorer struct {
	Values        map[string]string
	GetShouldFail bool
}

MockClientStorer is used for testing the client stores on context

func NewMockClientStorer

func NewMockClientStorer(data ...string) *MockClientStorer

NewMockClientStorer constructs a MockClientStorer

func (*MockClientStorer) Del

func (m *MockClientStorer) Del(key string)

Del a key/value pair

func (*MockClientStorer) Get

func (m *MockClientStorer) Get(key string) (string, bool)

Get a key's value

func (*MockClientStorer) GetErr

func (m *MockClientStorer) GetErr(key string) (string, error)

GetErr gets a key's value or err if not exist

func (*MockClientStorer) Put

func (m *MockClientStorer) Put(key, val string)

Put a value

type MockFailStorer

type MockFailStorer struct{}

MockFailStorer is used for testing module initialize functions that recover more than the base storer

func (MockFailStorer) Create

func (_ MockFailStorer) Create(_ string, _ authboss.Attributes) error

Create fails

func (MockFailStorer) Get

func (_ MockFailStorer) Get(_ string) (interface{}, error)

Get fails

func (MockFailStorer) Put

func (_ MockFailStorer) Put(_ string, _ authboss.Attributes) error

Put fails

type MockMailer

type MockMailer struct {
	Last    authboss.Email
	SendErr string
}

MockMailer helps simplify mailer testing by storing the last sent email

func NewMockMailer

func NewMockMailer() *MockMailer

NewMockMailer constructs a mock mailer

func (*MockMailer) Send

func (m *MockMailer) Send(email authboss.Email) error

Send an e-mail

type MockStorer

type MockStorer struct {
	Users          map[string]authboss.Attributes
	Tokens         map[string][]string
	CreateErr      string
	PutErr         string
	GetErr         string
	AddTokenErr    string
	DelTokensErr   string
	UseTokenErr    string
	RecoverUserErr string
	ConfirmUserErr string
}

MockStorer should be valid for any module storer defined in authboss.

func NewMockStorer

func NewMockStorer() *MockStorer

NewMockStorer constructor

func (*MockStorer) AddToken

func (m *MockStorer) AddToken(key, token string) error

AddToken for remember me

func (*MockStorer) ConfirmUser

func (m *MockStorer) ConfirmUser(confirmToken string) (result interface{}, err error)

ConfirmUser via their token

func (*MockStorer) Create

func (m *MockStorer) Create(key string, attr authboss.Attributes) error

Create a new user

func (*MockStorer) DelTokens

func (m *MockStorer) DelTokens(key string) error

DelTokens for a user

func (*MockStorer) Get

func (m *MockStorer) Get(key string) (result interface{}, err error)

Get a user

func (*MockStorer) GetOAuth

func (m *MockStorer) GetOAuth(uid, provider string) (result interface{}, err error)

GetOAuth user

func (*MockStorer) Put

func (m *MockStorer) Put(key string, attr authboss.Attributes) error

Put updates to a user

func (*MockStorer) PutOAuth

func (m *MockStorer) PutOAuth(uid, provider string, attr authboss.Attributes) error

PutOAuth user

func (*MockStorer) RecoverUser

func (m *MockStorer) RecoverUser(token string) (result interface{}, err error)

RecoverUser by the token.

func (*MockStorer) UseToken

func (m *MockStorer) UseToken(givenKey, token string) (err error)

UseToken if it exists, deleting it in the process

type MockUser

type MockUser struct {
	Username           string
	Email              string
	Password           string
	RecoverToken       string
	RecoverTokenExpiry time.Time
	ConfirmToken       string
	Confirmed          bool
	Locked             bool
	AttemptNumber      int
	AttemptTime        time.Time
	OauthToken         string
	OauthRefresh       string
	OauthExpiry        time.Time
}

MockUser represents all possible fields a authboss User may have

Jump to

Keyboard shortcuts

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