Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApiKeyAuthInfo ¶
ApiKeyAuthInfo is the configuration for API key authentication
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a very generic http client for making requests to url patterns
func (*Client) Do ¶
func (c *Client) Do(method, pathPattern string, vars map[string]string, body any) (resp *http.Response, err error)
Do makes an HTTP request to the path pattern, with the vars context and body with a JSON body method is the verb of the request. Ex: GET, POST, PUT, DELETE pathPattern is a path pattern with variables in the form of {var_name}. Ex: /orders/{order_id} vars is a map of variables to be applied to the path pattern. Ex: map[string]string{"order_id": "123"}
func (*Client) WithAuth ¶
func (c *Client) WithAuth(auth *ApiKeyAuthInfo) *Client
WithAuth adds authentication information to the client
func (*Client) WithNoAuth ¶
func (*Client) WithOAuth2 ¶
func (c *Client) WithOAuth2(auth *OAuth2Info) *Client
WithOAuth2 sets up OAuth2 authentication information to the client
type Config ¶
type Config struct { // BaseURL is the host or host + fixed part of the path (for every method) BaseURL string `json:"base_url"` // ApiKeyAuth is the authentication information for Api Key authentication ApiKeyAuth *ApiKeyAuthInfo `json:"auth"` // OAuth2Info is the authentication information for OAuth2 authentication OAuth2Info *OAuth2Info `json:"oauth2"` // Tests is the configuration of tests to run Tests []Test `json:"tests"` // Debug the requests/responses Debug bool `json:"debug"` }
Config is the configuration of the suite of tests
type JsonValidator ¶
type JsonValidator struct {
// contains filtered or unexported fields
}
func NewJsonValidator ¶
func NewJsonValidator(jsonSchemaPath string) (*JsonValidator, error)
func (*JsonValidator) RequireModel ¶
func (v *JsonValidator) RequireModel(t *testing.T, model string, data []byte)
type OAuth2Info ¶
type OAuth2Info struct { ClientID string `json:"client_id"` ClientSecret string `json:"client_secret"` // Url or Path in where the API is serving the OAuth2 token generation endpoint TokenUrl string `json:"token_url"` Scopes []string `json:"scopes"` GrantType string `json:"grant_type"` }
OAuth2Info is the configuration for OAuth2 authentication
type Scenario ¶
type Test ¶
type Test struct { Method string `json:"method"` UrlPattern string `json:"url_pattern"` Scenarios []Scenario `json:"scenarios"` }
func (*Test) FailTestIfScenarioNotPresent ¶
FailTestIfScenarioNotPresent requires the test config to be present