fixtures

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2017 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package fixtures provide testing fixtures

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandomString

func RandomString(length int) string

RandomString return a random string of a given length

Types

type Ability

type Ability struct {
	Action string
	Object string
}

Ability is my user ability

func (Ability) GetAction

func (a Ability) GetAction() string

GetAction returns ability action

func (Ability) GetObject

func (a Ability) GetObject() string

GetObject returns ability object

type Account

type Account struct {
	Email      string
	Password   string
	EmptyEmail bool
}

Account contains login credentials

func (Account) GetEmail

func (record Account) GetEmail() string

GetEmail returns the account's email

func (Account) Valid

func (record Account) Valid(email, password string) bool

Valid checks if the given credentials match the account

type BadOAuthProvider

type BadOAuthProvider struct {
	NoClient          bool
	NoResponse        bool
	MalformedResponse bool
	OAuthProvider
}

BadOAuthProvider is the mocking provider with no client for OAuth driver

func (BadOAuthProvider) Client

func (config BadOAuthProvider) Client(ctx context.Context, token *oauth2.Token) internal.HTTPClient

Client returns an HTTP client using the provided token

type MyRoleService

type MyRoleService struct {
	// contains filtered or unexported fields
}

MyRoleService is my role service

func NewMyRoleService

func NewMyRoleService(records []Role) *MyRoleService

NewMyRoleService is the constructor for MyRoleService

func (MyRoleService) FindByIDs

func (service MyRoleService) FindByIDs(ids []string) (roles []gate.Role, err error)

FindByIDs fetches roles with the given IDs

type MyTokenService

type MyTokenService struct {
	// contains filtered or unexported fields
}

MyTokenService is my token service

func NewMyTokenService

func NewMyTokenService(records []token) *MyTokenService

NewMyTokenService is the constructor for MyTokenService

func (MyTokenService) Count

func (service MyTokenService) Count() int

Count returns the number of records

func (MyTokenService) FindOneByID

func (service MyTokenService) FindOneByID(id string) (jwt gate.JWT, err error)

FindOneByID fetches the JWT with the given ID

func (*MyTokenService) Store

func (service *MyTokenService) Store(jwt gate.JWT) error

Store appends the token

type MyUserService

type MyUserService struct {
	GenerateMyUserID func() string
	// contains filtered or unexported fields
}

MyUserService is my user service

func NewMyUserService

func NewMyUserService(records []User) *MyUserService

NewMyUserService is the constructor for MyUserService

func (*MyUserService) CreateOneByEmail

func (service *MyUserService) CreateOneByEmail(email string) (u gate.User, err error)

CreateOneByEmail creates the user with the given email

func (MyUserService) FindOneByEmail

func (service MyUserService) FindOneByEmail(email string) (u gate.User, err error)

FindOneByEmail fetches the user with the given email

func (MyUserService) FindOneByID

func (service MyUserService) FindOneByID(ID string) (u gate.User, err error)

FindOneByID fetches the user with the given ID

func (*MyUserService) FindOrCreateOneByEmail

func (service *MyUserService) FindOrCreateOneByEmail(email string) (u gate.User, err error)

FindOrCreateOneByEmail fetches the user with the given email or creates a new one if the user doesn't exist

type OAuthClient

type OAuthClient struct {
	// contains filtered or unexported fields
}

OAuthClient is the mocking HTTP client for OAuth driver

func (OAuthClient) Get

func (client OAuthClient) Get(url string) (resp *http.Response, err error)

Get makes a GET request with the given URL

type OAuthProvider

type OAuthProvider struct {
	Responses map[string]gate.HasEmail
}

OAuthProvider is the mocking provider for OAuth driver

func (OAuthProvider) AuthCodeURL

func (config OAuthProvider) AuthCodeURL(state string, opts ...oauth2.AuthCodeOption) string

AuthCodeURL returns a URL to OAuth 2.0 provider's consent page

func (OAuthProvider) Client

func (config OAuthProvider) Client(ctx context.Context, token *oauth2.Token) internal.HTTPClient

Client returns an HTTP client using the provided token

func (OAuthProvider) Exchange

func (config OAuthProvider) Exchange(ctx context.Context, code string) (*oauth2.Token, error)

Exchange converts an authorization code into a token

type Role

type Role struct {
	ID        string
	Abilities []Ability
}

Role is my user role

func (Role) GetAbilities

func (r Role) GetAbilities() (abilities []gate.UserAbility)

GetAbilities returns role abilities

type User

type User struct {
	ID    string
	Email string
	Roles []string
}

User is my user

func (User) GetEmail

func (u User) GetEmail() string

GetEmail returns user Email

func (User) GetID

func (u User) GetID() string

GetID returns user ID

func (User) GetRoles

func (u User) GetRoles() []string

GetRoles returns user Roles

Jump to

Keyboard shortcuts

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