mock

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EchoCtxWithKeys

func EchoCtxWithKeys(keys []string, values ...interface{}) echo.Context

EchoCtxWithKeys returns new Echo context with keys

func HeaderInvalid

func HeaderInvalid() string

HeaderInvalid is used for jwt testing

func HeaderValid

func HeaderValid() string

HeaderValid is used for jwt testing

func InsertMultiple

func InsertMultiple(db *pg.DB, models ...interface{}) error

InsertMultiple inserts multiple values into database

func NewDB

func NewDB(t *testing.T, con *dockertest.Container, models ...interface{}) *pg.DB

NewDB instantiates new postgresql database connection via docker container

func NewPGContainer

func NewPGContainer(t *testing.T) *dockertest.Container

NewPGContainer instantiates new PostgreSQL docker container

func Str2Ptr

func Str2Ptr(s string) *string

Str2Ptr converts string to pointer

func TestTime

func TestTime(year int) time.Time

TestTime is used for testing time fields

func TestTimePtr

func TestTimePtr(year int) *time.Time

TestTimePtr is used for testing pointer time fields

Types

type JWT

type JWT struct {
	GenerateTokenFn func(*gorsk.User) (string, string, error)
}

JWT mock

func (*JWT) GenerateToken

func (j *JWT) GenerateToken(u *gorsk.User) (string, string, error)

GenerateToken mock

type RBAC

type RBAC struct {
	UserFn            func(echo.Context) *gorsk.AuthUser
	EnforceRoleFn     func(echo.Context, gorsk.AccessRole) error
	EnforceUserFn     func(echo.Context, int) error
	EnforceCompanyFn  func(echo.Context, int) error
	EnforceLocationFn func(echo.Context, int) error
	AccountCreateFn   func(echo.Context, gorsk.AccessRole, int, int) error
	IsLowerRoleFn     func(echo.Context, gorsk.AccessRole) error
}

RBAC Mock

func (*RBAC) AccountCreate

func (a *RBAC) AccountCreate(c echo.Context, roleID gorsk.AccessRole, companyID, locationID int) error

AccountCreate mock

func (*RBAC) EnforceCompany

func (a *RBAC) EnforceCompany(c echo.Context, id int) error

EnforceCompany mock

func (*RBAC) EnforceLocation

func (a *RBAC) EnforceLocation(c echo.Context, id int) error

EnforceLocation mock

func (*RBAC) EnforceRole

func (a *RBAC) EnforceRole(c echo.Context, role gorsk.AccessRole) error

EnforceRole mock

func (*RBAC) EnforceUser

func (a *RBAC) EnforceUser(c echo.Context, id int) error

EnforceUser mock

func (*RBAC) IsLowerRole

func (a *RBAC) IsLowerRole(c echo.Context, role gorsk.AccessRole) error

IsLowerRole mock

func (*RBAC) User

func (a *RBAC) User(c echo.Context) *gorsk.AuthUser

User mock

type Secure

type Secure struct {
	PasswordFn            func(string, ...string) bool
	HashFn                func(string) string
	HashMatchesPasswordFn func(string, string) bool
	TokenFn               func(string) string
}

Secure mock

func (*Secure) Hash

func (s *Secure) Hash(pw string) string

Hash mock

func (*Secure) HashMatchesPassword

func (s *Secure) HashMatchesPassword(hash, pw string) bool

HashMatchesPassword mock

func (*Secure) Password

func (s *Secure) Password(pw string, inputs ...string) bool

Password mock

func (*Secure) Token

func (s *Secure) Token(token string) string

Token mock

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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