mock

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2019 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AryaStark *models.User

AryaStark is a mocked user

View Source
var AvengersTenant *models.Tenant

AvengersTenant is a mocked tenant

View Source
var DemoTenant *models.Tenant

DemoTenant is a mocked tenant

View Source
var JonSnow *models.User

JonSnow is a mocked user

Functions

func NewNoopTask added in v0.11.0

func NewNoopTask() worker.Task

NewNoopTask returns a worker task that does nothing

Types

type HTTPClient added in v0.14.0

type HTTPClient struct {
	Requests []*http.Request
}

HTTPClient is an mocked implementation of HTTP Client

func NewHTTPClient added in v0.14.0

func NewHTTPClient() *HTTPClient

NewHTTPClient creates a new HTTPClient

func (*HTTPClient) Do added in v0.14.0

func (client *HTTPClient) Do(req *http.Request) (*http.Response, error)

Do saves the request internally for later inspection

func (*HTTPClient) Reset added in v0.14.0

func (client *HTTPClient) Reset()

Reset the internal request store

type OAuthService added in v0.5.0

type OAuthService struct{}

OAuthService implements a mocked OAuthService

func (*OAuthService) GetAuthURL added in v0.5.0

func (s *OAuthService) GetAuthURL(provider, redirect, identifier string) (string, error)

GetAuthURL returns authentication url for given provider

func (*OAuthService) GetProfile added in v0.5.0

func (s *OAuthService) GetProfile(provider string, code string) (*oauth.UserProfile, error)

GetProfile returns user profile based on provider and code

func (*OAuthService) GetRawProfile added in v0.15.0

func (s *OAuthService) GetRawProfile(provider string, code string) (string, error)

GetRawProfile returns raw JSON response from Profile API

func (*OAuthService) ListActiveProviders added in v0.15.0

func (s *OAuthService) ListActiveProviders() ([]*oauth.ProviderOption, error)

ListActiveProviders returns a list of all providers for current tenant

func (*OAuthService) ListAllProviders added in v0.15.0

func (s *OAuthService) ListAllProviders() ([]*oauth.ProviderOption, error)

ListAllProviders returns a list of all providers for current tenant

func (*OAuthService) ParseRawProfile added in v0.15.0

func (s *OAuthService) ParseRawProfile(provider, body string) (*oauth.UserProfile, error)

ParseRawProfile parses raw profile response into UserProfile model

type Server

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

Server is a HTTP server wrapper for testing purpose

func NewServer

func NewServer() (*Server, *app.Services)

NewServer creates a new server and services for HTTP testing

func NewSingleTenantServer

func NewSingleTenantServer() (*Server, *app.Services)

NewSingleTenantServer creates a new multitenant test server

func (*Server) AddCookie added in v0.5.0

func (s *Server) AddCookie(name string, value string) *Server

AddCookie add key-value to current context cookies

func (*Server) AddHeader added in v0.5.0

func (s *Server) AddHeader(name string, value string) *Server

AddHeader add key-value to current context headers

func (*Server) AddParam added in v0.7.0

func (s *Server) AddParam(name string, value interface{}) *Server

AddParam to current context route parameters

func (*Server) AsUser added in v0.5.0

func (s *Server) AsUser(user *models.User) *Server

AsUser set current context user

func (*Server) Engine added in v0.11.0

func (s *Server) Engine() *web.Engine

Engine returns current engine from mocked server

func (*Server) Execute

func (s *Server) Execute(handler web.HandlerFunc) (int, *httptest.ResponseRecorder)

Execute given handler and return response

func (*Server) ExecuteAsJSON

func (s *Server) ExecuteAsJSON(handler web.HandlerFunc) (int, *jsonq.Query)

ExecuteAsJSON given handler and return json response

func (*Server) ExecutePost

func (s *Server) ExecutePost(handler web.HandlerFunc, body string) (int, *httptest.ResponseRecorder)

ExecutePost executes given handler as POST and return response

func (*Server) ExecutePostAsJSON added in v0.6.0

func (s *Server) ExecutePostAsJSON(handler web.HandlerFunc, body string) (int, *jsonq.Query)

ExecutePostAsJSON executes given handler as POST and return json response

func (*Server) OnTenant added in v0.5.0

func (s *Server) OnTenant(tenant *models.Tenant) *Server

OnTenant set current context tenant

func (*Server) Use

func (s *Server) Use(middleware web.MiddlewareFunc) *Server

Use adds a new middleware to pipeline

func (*Server) WithClaims added in v0.15.0

func (s *Server) WithClaims(claims *jwt.FiderClaims) *Server

WithClaims set current context user claims

func (*Server) WithClientIP added in v0.16.0

func (s *Server) WithClientIP(clientIP string) *Server

WithClientIP set current ClientIP address

func (*Server) WithURL added in v0.5.0

func (s *Server) WithURL(fullURL string) *Server

WithURL set current context Request URL

type Worker added in v0.10.0

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

Worker is fake wrapper for background worker

func NewWorker added in v0.10.0

func NewWorker() (*Worker, *app.Services)

NewWorker creates a new worker and services for worker testing

func (*Worker) AsUser added in v0.10.0

func (w *Worker) AsUser(user *models.User) *Worker

AsUser set current context user

func (*Worker) Execute added in v0.10.0

func (w *Worker) Execute(task worker.Task) error

Execute given task with current context

func (*Worker) OnTenant added in v0.10.0

func (w *Worker) OnTenant(tenant *models.Tenant) *Worker

OnTenant set current context tenant

func (*Worker) WithBaseURL added in v0.14.0

func (w *Worker) WithBaseURL(baseURL string) *Worker

WithBaseURL set current context baseURL

Jump to

Keyboard shortcuts

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