test

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2018 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FakeEmail = "test@abc.com"
	FakePass  = "V3vRyT!$5qNHt9H1"
	NewPass   = "*$M^kiD2Nhs8OpkR"
	FakeName  = "user.sdfsfdF"
)

Variables

This section is empty.

Functions

func CheckApiResponse

func CheckApiResponse(status api.Response, code string) error

CheckApiResponse checks an API resonse matches the provded message

func CheckRedirect

func CheckRedirect(url string, resp *http.Response) error

CheckRedirect checks that a given redirect is correct

func NewConfig

func NewConfig() *config.AuthPlzConfig

NewConfig generates a test configuration

func ParseAndCheckAPIResponse

func ParseAndCheckAPIResponse(resp *http.Response, code string) error

func ParseJson

func ParseJson(resp *http.Response, inst interface{}) error

ParseJson assists with parsing JSON responses

Types

type Client

type Client struct {
	*http.Client
	// contains filtered or unexported fields
}

Client instance Handles cookies as well as API base addresses and provides convenience wrappers to simplify testing

func NewClient

func NewClient(path string) Client

NewClient Create a new Client instance

func NewClientFromHttp

func NewClientFromHttp(path string, client *http.Client) Client

NewClientFromHttp Create a new Client instance using the provided http.Client Useful for OAuth clients

func (*Client) Get

func (tc *Client) Get(path string, statusCode int) (*http.Response, error)

Get wraps client.Get with status code checks

func (*Client) GetAPIResponse

func (tc *Client) GetAPIResponse(path string, statusCode int, code string) error

func (*Client) GetJSON

func (tc *Client) GetJSON(path string, statusCode int, inst interface{}) error

func (*Client) GetJSONWithParams

func (tc *Client) GetJSONWithParams(path string, statusCode int, v url.Values, inst interface{}) error

func (*Client) GetWithParams

func (tc *Client) GetWithParams(path string, statusCode int, v url.Values) (*http.Response, error)

GetWithParamsGet wraps client.Get with query parameters and status code checks

func (*Client) PostForm

func (tc *Client) PostForm(path string, statusCode int, v url.Values) (*http.Response, error)

PostForm Post a form to an api endpoint

func (*Client) PostJSON

func (tc *Client) PostJSON(path string, statusCode int, requestInst interface{}) (*http.Response, error)

Post JSON to an api endpoint

type MockEventEmitter

type MockEventEmitter struct {
	Event *events.AuthPlzEvent
}

func (*MockEventEmitter) SendEvent

func (m *MockEventEmitter) SendEvent(e interface{})

type TestServer

type TestServer struct {
	Router       *web.Router
	DataStore    *datastore.DataStore
	TokenControl *token.TokenController
	EventEmitter *MockEventEmitter
	Config       *config.AuthPlzConfig
}

func NewTestServer

func NewTestServer() (*TestServer, error)

func (*TestServer) Address

func (ts *TestServer) Address() string

func (*TestServer) Run

func (ts *TestServer) Run()

Jump to

Keyboard shortcuts

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