mock

package
v0.0.0-...-2a11bd6 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package mock contains logic to mock various components of the application

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 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(*models.User) (string, string, error)
}

JWT mock

func (*JWT) GenerateToken

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

GenerateToken mock

type RBAC

type RBAC struct {
	UserFn           func(echo.Context) *models.AuthUser
	EnforceRoleFn    func(echo.Context, models.AccessRole) error
	EnforceUserFn    func(echo.Context, uint) error
	EnforceAccountFn func(echo.Context, uint) error
	EnforceTeamFn    func(echo.Context, uint) error
	AccountCreateFn  func(echo.Context, models.AccessRole, uint, uint) error
	IsLowerRoleFn    func(echo.Context, models.AccessRole) error
}

RBAC Mock

func (*RBAC) AccountCreate

func (a *RBAC) AccountCreate(c echo.Context, roleID models.AccessRole, accountID, teamID uint) error

AccountCreate mock

func (*RBAC) EnforceAccount

func (a *RBAC) EnforceAccount(c echo.Context, id uint) error

EnforceAccount mock

func (*RBAC) EnforceRole

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

EnforceRole mock

func (*RBAC) EnforceTeam

func (a *RBAC) EnforceTeam(c echo.Context, id uint) error

EnforceTeam mock

func (*RBAC) EnforceUser

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

EnforceUser mock

func (*RBAC) IsLowerRole

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

IsLowerRole mock

func (*RBAC) User

func (a *RBAC) User(c echo.Context) *models.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
Package mockstore is used for testing purposes to mock the store package and mock a mysql db through a docker container of mysql
Package mockstore is used for testing purposes to mock the store package and mock a mysql db through a docker container of mysql

Jump to

Keyboard shortcuts

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