Documentation ¶
Index ¶
- Variables
- type Client
- func (cli *Client) AddCookie(key, value string, config *godog.Table) error
- func (cli *Client) AddHeaders(headers *godog.Table)
- func (cli *Client) AddQueryParam(key, val string)
- func (cli *Client) AddQueryParams(args *godog.Table)
- func (cli *Client) ClearBody()
- func (cli *Client) ClientHasCookies(not bool, names ...string) error
- func (Client) Debug()
- func (cli *Client) DisableAutoResetRequest()
- func (cli *Client) DisableCookie()
- func (Client) DisableDebug()
- func (cli *Client) DisableRedirect()
- func (cli *Client) DisableTrace()
- func (cli *Client) EmptyResponseBody(not bool, _ ...string) error
- func (cli *Client) EnableAutoResetRequest()
- func (cli *Client) EnableCookie()
- func (cli *Client) ExecuteRequest() error
- func (cli *Client) FollowRedirect()
- func (cli *Client) InitRequest(withCookie bool)
- func (cli Client) PickArgumentFromURLArg(argument, urlCandidate, pickAs string) error
- func (cli Client) PickFromResponseJSONBody(path, pickAs string) error
- func (cli Client) PickResponseCookie(name, pickAs string)
- func (cli Client) PickResponseHTMLTag(tag, attribute, pickAs string, filters *godog.Table) error
- func (cli Client) PickResponseHeader(name, pickAs string)
- func (cli *Client) Reset()
- func (cli *Client) ResetCookie()
- func (cli *Client) ResetRequest()
- func (cli *Client) ResponseCookieDomainShouldOrShouldNotMatch(not bool, params ...string) error
- func (cli *Client) ResponseCookiesShouldOrShouldNotBeHTTPOnly(not bool, params ...string) error
- func (cli *Client) ResponseCookiesShouldOrShouldNotBeSecure(not bool, names ...string) error
- func (cli *Client) ResponseHTMLShouldBeEquivalent(body *godog.DocString) error
- func (cli *Client) ResponseHTMLShouldContains(elements *godog.Table) error
- func (cli *Client) ResponseHasCookies(not bool, names ...string) error
- func (cli *Client) ResponseHasStatus(expectedStatus int) error
- func (cli *Client) ResponseHeaderShouldOrShouldNotMatch(not bool, params ...string) error
- func (cli *Client) ResponseJSONShouldBeEquivalent(expected *godog.DocString) error
- func (cli *Client) ResponseJSONShouldContain(fully bool, matchPaths *godog.Table) error
- func (cli *Client) SetEndpoint(endpoint string)
- func (cli *Client) SetFormBody(body *godog.Table)
- func (cli *Client) SetHeader(key, values string)
- func (cli *Client) SetJSONBody(body *godog.DocString)
- func (cli *Client) SetMethod(method string) error
- func (cli *Client) SetQueryParams(args *godog.Table) error
- func (cli *Client) SetRequestHeaders(headers *godog.Table)
- func (cli *Client) Trace()
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidStatus is thrown when response status code does not match // expected status. ErrInvalidStatus = errors.New("status code does not match expected") // ErrExpectedEmptyBody is thrown when response expected body to be empty // but it was not. ErrExpectedEmptyBody = errors.New("response body should be empty") // ErrExpectedBody is thrown when response expected body to not be empty // but it was. ErrExpectedBody = errors.New("response should have a body") // ErrUnexpectedCookie is thrown when response or client should not have // specified cookies but at least one exists. ErrUnexpectedCookie = errors.New("should not have cookie") // ErrExpectedCookie is thrown when response should have specified cookies // but at least one does not exists. ErrExpectedCookie = errors.New("should have cookie") // ErrInvalidCookieSecurity is thrown when cookies security does not match // expected. ErrInvalidCookieSecurity = errors.New("cookie security does not match expected") // ErrInvalidCookieHTTPSetting is thrown when cookies HTTP setting does // not match expected. ErrInvalidCookieHTTPSetting = errors.New("cookie HTTP setting does not match expected") // ErrInvalidCookieDomain is thrown when cookie domain does not match expected. ErrInvalidCookieDomain = errors.New("cookie domain does not match expected") // ErrInvalidArgNumber is thrown when assertions methods receive an // unexpected number of arguments on periodic argument. ErrInvalidArgNumber = errors.New("invalid quantity for periodic arguments") )
var ( // ErrNoBody is thrown when asserting on response expected a body to exists // but none exists. ErrNoBody = api.ErrNoBody // ErrUnknownKey is thrown when provided key does not exists in JSON. ErrUnknownKey = api.ErrUnknownKey // ErrNoMatch is thrown when assertions fails to match expected value. ErrNoMatch = api.ErrNoMatch // ErrNotFullyMatch is thrown when actual asserted object contains // more values than expected. ErrNotFullyMatch = api.ErrNotFullyMatch // ErrNoPath is thrown when provided assertion path does not exists // in actual object. ErrNoPath = api.ErrNoPath // ErrNoRequest is thrown when assertion expected a request to exists // but none exists. ErrNoRequest = api.ErrNoRequest )
Exposes api errors
var ErrInvalidMethod = errors.New("invalid method provided")
ErrInvalidMethod is thrown when an unsupported method is provided.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides methods to test HTTP Rest API endpoints.
func New ¶
func New(store *internalPicker.Store, autoReset bool) (*Client, error)
New initializes an HTTP API tester.
func (*Client) AddHeaders ¶
AddHeaders adds headers to known list. It ALWAYS return nil.
func (*Client) AddQueryParam ¶
AddQueryParam adds a single query parameter.
func (*Client) AddQueryParams ¶
AddQueryParams adds query parameters.
func (*Client) ClientHasCookies ¶
ClientHasCookies asserts client has or does not have specified cookie list depending on not parameter.
func (Client) Debug ¶
func (Client) Debug()
Debug start debug logs. It will be removed when calling Reset.
func (*Client) DisableAutoResetRequest ¶
func (cli *Client) DisableAutoResetRequest()
func (*Client) DisableCookie ¶
func (cli *Client) DisableCookie()
DisableCookie disables cookie storage for request.
func (*Client) DisableRedirect ¶
func (cli *Client) DisableRedirect()
DisableRedirect disables redirection.
func (*Client) DisableTrace ¶
func (cli *Client) DisableTrace()
DisableTrace disables client request tracing.
func (*Client) EmptyResponseBody ¶
EmptyResponseBody asserts response body should or should not be empty depending on not parameter.
Second argument is not used. It is present for interface.AsNot simplification in step definitions..
func (*Client) EnableAutoResetRequest ¶
func (cli *Client) EnableAutoResetRequest()
func (*Client) EnableCookie ¶
func (cli *Client) EnableCookie()
EnableCookie enables cookie storage for request.
func (*Client) ExecuteRequest ¶
ExecuteRequest builds and executes request through http client.
func (*Client) FollowRedirect ¶
func (cli *Client) FollowRedirect()
FollowRedirect enables redirection.
func (*Client) InitRequest ¶
InitRequest starts a new request with default parameter.
func (Client) PickArgumentFromURLArg ¶
PickArgumentFromURLArg picks header from response.
func (Client) PickFromResponseJSONBody ¶
PickFromResponseJSONBody picks paths value from a response JSON body.
func (Client) PickResponseCookie ¶
PickResponseCookie picks cookie from response.
func (Client) PickResponseHTMLTag ¶
PickResponseHTMLTag picks tag value from a response HTML body.
func (Client) PickResponseHeader ¶
PickResponseHeader picks header from response.
func (*Client) Reset ¶
func (cli *Client) Reset()
Reset resets client instance. Client will be reset to default. Response/request will be forgotten.
func (*Client) ResetRequest ¶
func (cli *Client) ResetRequest()
ResetRequest resets client request. If cli.autoResetRequest is enabled, request will automatically be cleared after response parsing.
func (*Client) ResponseCookieDomainShouldOrShouldNotMatch ¶
ResponseCookieDomainShouldOrShouldNotMatch asserts response cookie domain does/doesn't match expected domains.
func (*Client) ResponseCookiesShouldOrShouldNotBeHTTPOnly ¶
ResponseCookiesShouldOrShouldNotBeHTTPOnly asserts response cookies are/aren't HTTP Only.
func (*Client) ResponseCookiesShouldOrShouldNotBeSecure ¶
ResponseCookiesShouldOrShouldNotBeSecure asserts response cookies are/aren't secure.
func (*Client) ResponseHTMLShouldBeEquivalent ¶
ResponseHTMLShouldBeEquivalent asserts response body is a HTML resembling provided.
func (*Client) ResponseHTMLShouldContains ¶
ResponseHTMLShouldContains asserts response HTML body contains provided strings.
func (*Client) ResponseHasCookies ¶
ResponseHasCookies asserts response has or does not have specified cookie list depending on not parameter.
func (*Client) ResponseHasStatus ¶
ResponseHasStatus asserts Response has expected status.
func (*Client) ResponseHeaderShouldOrShouldNotMatch ¶
ResponseHeaderShouldOrShouldNotMatch asserts response header match or does not match provided value using provided matcher.
func (*Client) ResponseJSONShouldBeEquivalent ¶
ResponseJSONShouldBeEquivalent asserts response body is a JSON resembling provided JSON.
func (*Client) ResponseJSONShouldContain ¶
ResponseJSONShouldContain asserts response body is a JSON having provided keys. If fully is true, it also ensures no key exists besides provided one. Keys are provided as Path using `.` separators To match insides JSON Array, use Index.
test.0.has matches a path inside: {"test": [{"matches": val}}
func (*Client) SetEndpoint ¶
SetEndpoint adds Endpoint to request.
func (*Client) SetFormBody ¶
SetFormBody replaces current request body with new Form body.
func (*Client) SetHeader ¶
SetHeader adds a single key,value couple to request headers. It ALWAYS return nil.
func (*Client) SetJSONBody ¶
SetJSONBody replaces current request body with new JSON body.
func (*Client) SetQueryParams ¶
SetQueryParams replaces query parameters with new ones.
func (*Client) SetRequestHeaders ¶
SetRequestHeaders replaces current headers with list of provided ones. It ALWAYS return nil.