Documentation
¶
Index ¶
- Constants
- func AddAssertion(assertions []string, assert string) []string
- func MatchPathGroups(rawPath string, targetPath string) (res map[string]string)
- func NormalizeDirPath(path string) string
- func NormalizeGroup(title string, path string) string
- func NormalizePath(path string, sepChar uint8) string
- func SanitizeNonAlphabet(name string, rep string) string
- func SanitizeRegexValue(val string) string
- type APIAuthorization
- type APIKeyConfig
- type APIKeyData
- func (kd *APIKeyData) Equals(other *APIKeyData) error
- func (kd *APIKeyData) MatchGroups(path string) map[string]string
- func (kd *APIKeyData) MethodNamePathPrefixKey() string
- func (kd *APIKeyData) MethodPath() string
- func (kd *APIKeyData) PartialMethodPathKey() string
- func (kd *APIKeyData) PathPrefix(max int) string
- func (kd *APIKeyData) SafeName() string
- func (kd *APIKeyData) String() string
- func (kd *APIKeyData) Validate() error
- type APIRequest
- func (r APIRequest) Assert(queryParams map[string]string, postParams map[string]string, ...) error
- func (r APIRequest) AssertContentsPatternOrContent() string
- func (r APIRequest) AuthHeader() string
- func (r APIRequest) BuildTemplateParams(req *http.Request, pathGroups map[string]string, inHeaders http.Header, ...) (templateParams map[string]any, queryParams map[string]string, ...)
- func (r APIRequest) ContentType(defContentType string) string
- func (r APIRequest) TargetHeader() string
- type APIResponse
- type APIResponseKey
- type APIScenario
- func (api *APIScenario) BuildName(prefix string) string
- func (api *APIScenario) BuildURL(overrideBaseURL string) string
- func (api *APIScenario) Digest() string
- func (api *APIScenario) GetEndTime() time.Time
- func (api *APIScenario) GetMillisTime() int64
- func (api *APIScenario) GetNetURL(u *url.URL) (*url.URL, error)
- func (api *APIScenario) GetStartTime() time.Time
- func (api *APIScenario) GetURL(defBase string) (u *url.URL, err error)
- func (api *APIScenario) HasURL() bool
- func (api *APIScenario) LoadFileVariables(apiVariables *APIVariables)
- func (api *APIScenario) MethodPath() string
- func (api *APIScenario) MethodPathTarget() string
- func (api *APIScenario) NormalName() string
- func (api *APIScenario) NormalPath(sep uint8) string
- func (api *APIScenario) SafeName() string
- func (api *APIScenario) SetName(prefix string)
- func (api *APIScenario) String() string
- func (api *APIScenario) ToKeyData() *APIKeyData
- func (api *APIScenario) Validate() error
- type APIVariables
- type AWSConfig
- type AuthType
- type BasicAuthConfig
- type Configuration
- type DigestAuthConfig
- type GroupConfig
- type HMACConfig
- type JWTConfig
- type MethodType
- type NotFoundError
- type OAuth2Config
- type ProducerContractRequest
- type ProducerContractResponse
- type ValidationError
- type Version
Constants ¶
const APIKeyHeader = "x-api-key"
APIKeyHeader constant
const AuthorizationHeader = "Authorization"
AuthorizationHeader constant
const ContentLengthHeader = "Content-Length"
ContentLengthHeader header
const ContentTypeHeader = "Content-Type"
ContentTypeHeader header
const ETagHeader = "Etag"
ETagHeader canonical name
const MockChaosEnabled = "X-Mock-Chaos-Enabled"
MockChaosEnabled header
const MockGroup = "X-Mock-Group"
MockGroup header
const MockPlayback = "X-Mock-Playback"
MockPlayback header
const MockRecordMode = "X-Mock-Record"
MockRecordMode header
const MockRecordModeDisabled = "false"
MockRecordModeDisabled disabled value
const MockRecordModeEnabled = "true"
MockRecordModeEnabled enabled value
const MockRequestCount = "X-Mock-Request-Count"
MockRequestCount header
const MockResponseStatus = "X-Mock-Response-Status"
MockResponseStatus header
const MockScenarioHeader = "X-Mock-Scenario"
MockScenarioHeader header
const MockScenarioPath = "X-Mock-Path"
MockScenarioPath header
const MockURL = "X-Mock-Url"
MockURL header
const MockWaitBeforeReply = "X-Mock-Wait-Before-Reply"
MockWaitBeforeReply header
const ScenarioExt = ".yaml"
ScenarioExt extension
Variables ¶
This section is empty.
Functions ¶
func AddAssertion ¶
AddAssertion helper method
func MatchPathGroups ¶
MatchPathGroups return match groups for dynamic params in path
func NormalizeDirPath ¶
NormalizeDirPath normalizes dir path
func NormalizeGroup ¶
NormalizeGroup normalizes group name
func NormalizePath ¶
NormalizePath normalizes path
func SanitizeNonAlphabet ¶
SanitizeNonAlphabet helper method
func SanitizeRegexValue ¶
SanitizeRegexValue sanitizes (val string) string {
Types ¶
type APIAuthorization ¶
type APIAuthorization struct {
Type string `json:"type,omitempty" yaml:"type,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
In string `json:"in,omitempty" yaml:"in,omitempty"`
Format string `json:"format,omitempty" yaml:"format,omitempty"`
Scheme string `json:"scheme,omitempty" yaml:"scheme,omitempty"`
URL string `json:"url,omitempty" yaml:"url,omitempty"`
}
APIAuthorization defines mock auth parameters
type APIKeyConfig ¶
type APIKeyConfig struct {
Enabled bool `yaml:"enabled" mapstructure:"enabled" env:"API_KEY_ENABLED"`
Location string `yaml:"location" mapstructure:"location" env:"API_KEY_LOCATION"` // header, query, cookie
HeaderName string `yaml:"header_name" mapstructure:"header_name" env:"API_KEY_HEADER"` // e.g., X-API-Key
QueryName string `yaml:"query_name" mapstructure:"query_name" env:"API_KEY_QUERY"` // e.g., api_key
CookieName string `yaml:"cookie_name" mapstructure:"cookie_name" env:"API_KEY_COOKIE"` // e.g., api_key
// API key for mock api server
APIKey string `yaml:"api_key" mapstructure:"api_key" env:"API_KEY"`
// GenerateTokenUrl key for mock api server
GenerateTokenPath string `yaml:"generate_token_path" mapstructure:"generate_token_path" env:"API_KEY_PATH"`
}
APIKeyConfig configuration
type APIKeyData ¶
type APIKeyData struct {
// Method for HTTP API
Method MethodType `yaml:"method" json:"method"`
// Name to uniquely identify the scenario
Name string `yaml:"name" json:"name"`
// Path for the API (excluding query params)
Path string `yaml:"path" json:"path"`
// Order of scenario
Order int `yaml:"order" json:"order"`
// Response for the API
Response APIResponseKey `yaml:"response" json:"response"`
// Group of scenario
Group string `yaml:"group" json:"group"`
// Tags of scenario
Tags []string `yaml:"tags" json:"tags"`
// Predicate for the request
Predicate string `yaml:"predicate" json:"predicate"`
// AssertQueryParamsPattern for the API
AssertQueryParamsPattern map[string]string `yaml:"assert_query_params_pattern" json:"assert_query_params_pattern"`
// AssertPostParamsPattern for the API
AssertPostParamsPattern map[string]string `yaml:"assert_post_params_pattern" json:"assert_post_params_pattern"`
// AssertHeadersPattern for api response
AssertHeadersPattern map[string]string `yaml:"assert_headers_pattern" json:"assert_headers_pattern"`
// AssertContentsPattern for request optionally
AssertContentsPattern string `yaml:"assert_contents_pattern" json:"assert_contents_pattern"`
// LastUsageTime of key data
LastUsageTime int64
// RequestCount for the API
RequestCount uint64
}
APIKeyData defines keys of api scenario for in-memory store
func (*APIKeyData) Equals ¶
func (kd *APIKeyData) Equals(other *APIKeyData) error
Equals compares path and query path
func (*APIKeyData) MatchGroups ¶
func (kd *APIKeyData) MatchGroups(path string) map[string]string
MatchGroups return match groups for dynamic params in path
func (*APIKeyData) MethodNamePathPrefixKey ¶
func (kd *APIKeyData) MethodNamePathPrefixKey() string
MethodNamePathPrefixKey returns full key for the scenario
func (*APIKeyData) PartialMethodPathKey ¶
func (kd *APIKeyData) PartialMethodPathKey() string
PartialMethodPathKey for key by method and first-level path
func (*APIKeyData) PathPrefix ¶
func (kd *APIKeyData) PathPrefix(max int) string
PathPrefix builds prefix of path
func (*APIKeyData) SafeName ¶
func (kd *APIKeyData) SafeName() string
SafeName strips invalid characters
type APIRequest ¶
type APIRequest struct {
// PathParams for the API
PathParams map[string]string `yaml:"path_params" json:"path_params"`
// QueryParams for the API
QueryParams map[string]string `yaml:"query_params" json:"query_params"`
// PostParams for the API
PostParams map[string]string `yaml:"post_params" json:"post_params"`
// Headers for mock request
Headers map[string]string `yaml:"headers" json:"headers"`
// Description for response optionally
Description string `yaml:"description" json:"description"`
// Contents for request optionally
Contents string `yaml:"contents" json:"contents"`
// ExampleContents sample for request optionally
ExampleContents string `yaml:"example_contents" json:"example_contents"`
// HTTPVersion version of http
HTTPVersion string `yaml:"http_version" json:"http_version"`
// AssertQueryParamsPattern for the API
AssertQueryParamsPattern map[string]string `yaml:"assert_query_params_pattern" json:"assert_query_params_pattern"`
// AssertPostParamsPattern for the API
AssertPostParamsPattern map[string]string `yaml:"assert_post_params_pattern" json:"assert_post_params_pattern"`
// AssertHeadersPattern for mock response
AssertHeadersPattern map[string]string `yaml:"assert_headers_pattern" json:"assert_headers_pattern"`
// AssertContentsPattern for request optionally
AssertContentsPattern string `yaml:"assert_contents_pattern" json:"assert_contents_pattern"`
// Assertions for validating response
Assertions []string `yaml:"assertions" json:"assertions"`
// Variables to set for templates
Variables map[string]string `yaml:"variables" json:"variables"`
}
APIRequest defines mock request for APIs
func (APIRequest) Assert ¶
func (r APIRequest) Assert( queryParams map[string]string, postParams map[string]string, reqHeaders http.Header, reqContents any, templateParams map[string]any) error
Assert asserts response
func (APIRequest) AssertContentsPatternOrContent ¶
func (r APIRequest) AssertContentsPatternOrContent() string
AssertContentsPatternOrContent helper method
func (APIRequest) AuthHeader ¶
func (r APIRequest) AuthHeader() string
AuthHeader finds AuthHeaderType
func (APIRequest) BuildTemplateParams ¶
func (r APIRequest) BuildTemplateParams( req *http.Request, pathGroups map[string]string, inHeaders http.Header, overrides map[string]any, ) (templateParams map[string]any, queryParams map[string]string, postParams map[string]string, reqHeaders http.Header)
BuildTemplateParams builds template
func (APIRequest) ContentType ¶
func (r APIRequest) ContentType(defContentType string) string
ContentType find content-type
func (APIRequest) TargetHeader ¶
func (r APIRequest) TargetHeader() string
TargetHeader find header matching target
type APIResponse ¶
type APIResponse struct {
// Headers for mock response
Headers http.Header `yaml:"headers" json:"headers"`
// Contents for request
Contents string `yaml:"contents" json:"contents"`
// ContentsFile for request
ContentsFile string `yaml:"contents_file" json:"contents_file"`
// Description for response optionally
Description string `yaml:"description" json:"description"`
// ExampleContents sample for response optionally
ExampleContents string `yaml:"example_contents" json:"example_contents"`
// StatusCode for response
StatusCode int `yaml:"status_code" json:"status_code"`
// HTTPVersion version of http
HTTPVersion string `yaml:"http_version" json:"http_version"`
AddSharedVariables []string `yaml:"add_shared_variables" json:"add_shared_variables"`
DeleteSharedVariables []string `yaml:"delete_shared_variables" json:"delete_shared_variables"`
// AssertHeadersPattern for mock response
AssertHeadersPattern map[string]string `yaml:"assert_headers_pattern" json:"assert_headers_pattern"`
// AssertContentsPattern for request optionally
AssertContentsPattern string `yaml:"assert_contents_pattern" json:"assert_contents_pattern"`
// Assertions for validating response
Assertions []string `yaml:"assertions" json:"assertions"`
}
APIResponse defines mock response for APIs
func (APIResponse) Assert ¶
func (r APIResponse) Assert( resHeaders http.Header, resContents any, templateParams map[string]any) error
Assert asserts response
func (APIResponse) AssertContentsPatternOrContent ¶
func (r APIResponse) AssertContentsPatternOrContent() string
AssertContentsPatternOrContent helper method
func (APIResponse) ContentType ¶
func (r APIResponse) ContentType(defContentType string) string
ContentType find content-type
type APIResponseKey ¶
type APIResponseKey struct {
// StatusCode for response
StatusCode int `yaml:"status_code" json:"status_code"`
}
type APIScenario ¶
type APIScenario struct {
// Method for HTTP API
Method MethodType `yaml:"method" json:"method"`
// Name to uniquely identify the scenario
Name string `yaml:"name" json:"name"`
// Path for the API (excluding query params)
Path string `yaml:"path" json:"path"`
// BaseURL of remote server
BaseURL string `yaml:"base_url" json:"base_url"`
// Description of scenario
Description string `yaml:"description" json:"description"`
// Load next request before executing current scenario
NextRequest string `yaml:"next_request" json:"next_request"`
// Order of scenario
Order int `yaml:"order" json:"order"`
// Group of scenario
Group string `yaml:"group" json:"group"`
// Tags of scenario
Tags []string `yaml:"tags" json:"tags"`
// Predicate for the scenario
Predicate string `yaml:"predicate" json:"predicate"`
// Variables File for the scenario
VariablesFile string `yaml:"variables_file" json:"variables_file"`
// Authentication for the API
Authentication map[string]APIAuthorization `yaml:"authentication" json:"authentication"`
// Request for the API
Request APIRequest `yaml:"request" json:"request"`
// Response for the API
Response APIResponse `yaml:"response" json:"response"`
// WaitMillisBeforeReply for response
WaitBeforeReply time.Duration `yaml:"wait_before_reply" json:"wait_before_reply"`
// StartTime of request
StartTime time.Time `yaml:"start_time" json:"start_time"`
// EndTime of request
EndTime time.Time `yaml:"end_time" json:"end_time"`
// RequestCount of request
RequestCount uint64 `yaml:"-" json:"-"`
}
APIScenario defines mock scenario for APIs
func BuildScenarioFromHTTP ¶
func BuildScenarioFromHTTP( config *Configuration, prefix string, u *url.URL, method string, group string, reqHTTPVersion string, resHTTPVersion string, reqBody []byte, resBody []byte, queryParams map[string][]string, postParams map[string][]string, reqHeaders http.Header, reqContentType string, resHeaders http.Header, resContentType string, resStatus int, started time.Time, ended time.Time, ) (*APIScenario, error)
BuildScenarioFromHTTP helper method
func BuildTestScenario ¶
func BuildTestScenario(method MethodType, name string, path string, n int) *APIScenario
BuildTestScenario helper method
func (*APIScenario) BuildName ¶
func (api *APIScenario) BuildName(prefix string) string
BuildName builds name
func (*APIScenario) BuildURL ¶
func (api *APIScenario) BuildURL(overrideBaseURL string) string
BuildURL helper method
func (*APIScenario) GetEndTime ¶
func (api *APIScenario) GetEndTime() time.Time
GetEndTime helper method
func (*APIScenario) GetMillisTime ¶
func (api *APIScenario) GetMillisTime() int64
GetMillisTime helper method
func (*APIScenario) GetStartTime ¶
func (api *APIScenario) GetStartTime() time.Time
GetStartTime helper method
func (*APIScenario) GetURL ¶
func (api *APIScenario) GetURL(defBase string) (u *url.URL, err error)
GetURL helper method
func (*APIScenario) LoadFileVariables ¶
func (api *APIScenario) LoadFileVariables(apiVariables *APIVariables)
func (*APIScenario) MethodPath ¶
func (api *APIScenario) MethodPath() string
MethodPath helper method
func (*APIScenario) MethodPathTarget ¶
func (api *APIScenario) MethodPathTarget() string
MethodPathTarget helper method
func (*APIScenario) NormalName ¶
func (api *APIScenario) NormalName() string
NormalName normalizes name from path
func (*APIScenario) NormalPath ¶
func (api *APIScenario) NormalPath(sep uint8) string
NormalPath normalizes path
func (*APIScenario) SafeName ¶
func (api *APIScenario) SafeName() string
SafeName strips invalid characters
func (*APIScenario) ToKeyData ¶
func (api *APIScenario) ToKeyData() *APIKeyData
ToKeyData converts scenario to key data
type APIVariables ¶
type APIVariables struct {
// Name of variable collection
Name string `yaml:"name" json:"name"`
// Variables to set for templates
Variables map[string]string `yaml:"variables" json:"variables"`
}
APIVariables defines shared variables for APIs
func (*APIVariables) Validate ¶
func (v *APIVariables) Validate() error
type AWSConfig ¶
type AWSConfig struct {
Enabled bool `yaml:"enabled" mapstructure:"enabled" env:"AWS_ENABLED"`
StripRequestHeaders []string `yaml:"strip" mapstructure:"strip" env:"AWS_STRIP_HEADERS"`
SigningNameOverride string `yaml:"name" mapstructure:"name" env:"AWS_SIGNING_NAME"`
SigningRegionOverride string `yaml:"aws_region" mapstructure:"aws_region" env:"AWS_REGION"`
SigningHostOverride string `yaml:"sign_host" mapstructure:"sign_host" env:"AWS_SIGN_HOST"`
HostOverride string `yaml:"host" mapstructure:"host" env:"AWS_HOST"`
ResignAllRequests bool `yaml:"resign_all_requests" mapstructure:"resign_all_requests" env:"AWS_RESIGN_ALL_REQUESTS"`
ResignOnlyExpiredDate bool `yaml:"resign_only_expired_date" mapstructure:"resign_only_expired_date" env:"AWS_RESIGN_ONLY_EXPIRED"`
Debug bool `yaml:"debug" mapstructure:"debug" env:"AWS_DEBUG"`
}
AWSConfig config
type AuthType ¶
type AuthType string
AuthType for API authorization
const ( // APIKey stands for API Key Authentication. APIKey AuthType = "apikey" // AWSV4 is Amazon AWS Authentication. AWSV4 AuthType = "awsv4" // Basic Authentication. Basic AuthType = "basic" // Bearer Token Authentication. Bearer AuthType = "bearer" // Digest Authentication. Digest AuthType = "digest" // Hawk Authentication. Hawk AuthType = "hawk" // NoAuth Authentication. NoAuth AuthType = "noauth" // OAuth1 Authentication. OAuth1 AuthType = "oauth1" // OAuth2 Authentication. OAuth2 AuthType = "oauth2" // NTLM Authentication. NTLM AuthType = "ntlm" JWT AuthType = "jwt" HMAC AuthType = "hmac" AWSSignature AuthType = "aws" )
type BasicAuthConfig ¶
type BasicAuthConfig struct {
Enabled bool `yaml:"enabled" mapstructure:"enabled" env:"BASIC_AUTH_ENABLED"`
Username string `yaml:"username" mapstructure:"username" env:"USERNAME"`
Password string `yaml:"password" mapstructure:"password" env:"PASSWORD"`
}
BasicAuthConfig config
type Configuration ¶
type Configuration struct {
// HTTPPort for server
HTTPPort int `yaml:"http_port" mapstructure:"http_port" env:"HTTP_PORT"`
// ProxyPort for server
ProxyPort int `yaml:"proxy_port" mapstructure:"proxy_port" env:"PROXY_PORT"`
// ProxyURLFilter for filtering url
ProxyURLFilter string `yaml:"proxy_url_filter" mapstructure:"proxy_url_filter" env:"PROXY_URL_FILTER"`
// ConnectionTimeout for remote server
ConnectionTimeout int `yaml:"connection_timeout" mapstructure:"connection_timeout"`
// DataDir for storing api scenarios, history, fixtures, assets, etc.
DataDir string `yaml:"data_dir" mapstructure:"data_dir" env:"DATA_DIR"`
// MaxHistory for max limit of storing execution history
MaxHistory int `yaml:"max_history" mapstructure:"max_history" env:"MAX_HISTORY"`
// UserAgent for mock api server
UserAgent string `yaml:"user_agent" mapstructure:"user_agent" env:"USER_AGENT"`
// ProxyURL for mock api server
ProxyURL string `yaml:"proxy_url" mapstructure:"proxy_url" env:"PROXY_URL"`
// AssertHeadersPattern to always match HTTP headers and store them in match-header property of api scenario
AssertHeadersPattern string `yaml:"assert_headers_pattern" mapstructure:"assert_headers_pattern" env:"ASSERT_HEADERS_PATTERN"`
// AssertQueryParamsPattern to always match HTTP query params and store them in match-query parameters of api scenario
AssertQueryParamsPattern string `yaml:"assert_query_params_pattern" mapstructure:"assert_query_params_pattern" env:"ASSERT_QUERY_PATTERN"`
// AssertPostParamsPattern to always match HTTP post params and store them in match-query parameters of api scenario
AssertPostParamsPattern string `yaml:"assert_post_params_pattern" mapstructure:"assert_post_params_pattern" env:"ASSERT_POST_PATTERN"`
CORS string `yaml:"cors" mapstructure:"cors" env:"MOCK_CORS"`
RecordOnly bool `yaml:"record_only" mapstructure:"record_only" env:"RECORD_ONLY"`
Debug bool `yaml:"debug" mapstructure:"debug" env:"MOCK_DEBUG"`
// Version of API
Version *Version `yaml:"-" mapstructure:"-" json:"-"`
// Bearer token for mock api server
AuthBearerToken string `yaml:"auth_bearer_token" mapstructure:"auth_bearer_token" env:"AUTH_TOKEN"`
// AWSConfig
AWS AWSConfig `yaml:"aws" mapstructure:"aws"`
// BasicAuth
BasicAuth BasicAuthConfig `yaml:"basic_auth" mapstructure:"basic_auth"`
OAuth2 OAuth2Config `yaml:"oauth2" mapstructure:"oauth2"`
HMAC HMACConfig `yaml:"hmac" mapstructure:"hmac"`
JWT JWTConfig `yaml:"jwt" mapstructure:"jwt"`
Digest DigestAuthConfig `yaml:"digest" mapstructure:"digest"`
APIKeyConfig APIKeyConfig `yaml:"api_key_config" mapstructure:"api_key_config"`
TestEnvironments []string `yaml:"test_env" mapstructure:"test_env"`
}
Configuration for mock api service
func NewConfiguration ¶
func NewConfiguration( httpPort int, proxyPort int, dataDir string, version *Version) (config *Configuration, err error)
NewConfiguration -- Initializes the default config
func (*Configuration) AssertHeader ¶
func (c *Configuration) AssertHeader(h string) bool
AssertHeader match header
func (*Configuration) AssertPostParams ¶
func (c *Configuration) AssertPostParams(p string) bool
AssertPostParams match post params
func (*Configuration) AssertQueryParams ¶
func (c *Configuration) AssertQueryParams(p string) bool
AssertQueryParams match query params
func (*Configuration) GetAuthMethod ¶
func (c *Configuration) GetAuthMethod() AuthType
type DigestAuthConfig ¶
type DigestAuthConfig struct {
Enabled bool `yaml:"enabled" mapstructure:"enabled" env:"DIGEST_ENABLED"`
Username string `yaml:"username" mapstructure:"username" env:"DIGEST_USERNAME"`
Password string `yaml:"password" mapstructure:"password" env:"DIGEST_PASSWORD"`
Realm string `yaml:"realm" mapstructure:"realm" env:"DIGEST_REALM"`
}
DigestAuthConfig configuration
type GroupConfig ¶
type GroupConfig struct {
// Variables to set for templates
Variables map[string]string `json:"variables" mapstructure:"variables"`
// ChaosEnabled to enable faults and delays
ChaosEnabled bool `json:"chaos_enabled" mapstructure:"chaos_enabled"`
// MeanTimeBetweenFailure for failure
MeanTimeBetweenFailure float64 `json:"mean_time_between_failure" mapstructure:"mean_time_between_failure"`
// MeanTimeBetweenAdditionalLatency for adding delay
MeanTimeBetweenAdditionalLatency float64 `json:"mean_time_between_additional_latency" mapstructure:"mean_time_between_additional_latency"`
// MaxAdditionalLatency for max delay
MaxAdditionalLatencySecs float64 `json:"max_additional_latency_secs" mapstructure:"max_additional_latency_secs"`
// HTTPErrors to return for failure
HTTPErrors []int `json:"http_errors" mapstructure:"http_errors"`
// contains filtered or unexported fields
}
GroupConfig for group configuration
func (*GroupConfig) GetDelayLatency ¶
func (gc *GroupConfig) GetDelayLatency() time.Duration
GetDelayLatency calculates latency
func (*GroupConfig) GetHTTPStatus ¶
func (gc *GroupConfig) GetHTTPStatus() int
GetHTTPStatus accessor
type HMACConfig ¶
type HMACConfig struct {
Enabled bool `yaml:"enabled" mapstructure:"enabled" env:"HMAC_ENABLED"`
Secret string `yaml:"secret" mapstructure:"secret" env:"HMAC_SECRET"`
Algorithm string `yaml:"algorithm" mapstructure:"algorithm" env:"HMAC_ALGORITHM"`
HeaderName string `yaml:"header_name" mapstructure:"header_name" env:"HMAC_HEADER_NAME"`
}
HMACConfig configuration
type JWTConfig ¶
type JWTConfig struct {
Enabled bool `yaml:"enabled" mapstructure:"enabled" env:"JWT_ENABLED"`
Secret string `yaml:"secret" mapstructure:"secret" env:"JWT_SECRET"`
Algorithm string `yaml:"algorithm" mapstructure:"algorithm" env:"JWT_ALGORITHM"`
Issuer string `yaml:"issuer" mapstructure:"issuer" env:"JWT_ISSUER"`
Audience string `yaml:"audience" mapstructure:"audience" env:"JWT_AUDIENCE"`
ExpiryHours int `yaml:"expiry_hours" mapstructure:"expiry_hours" env:"JWT_EXPIRY_HOURS"`
}
JWTConfig configuration
type MethodType ¶
type MethodType string
MethodType for HTTP
const ( // Get HTTP request Get MethodType = "GET" // Post HTTP request Post MethodType = "POST" // Put HTTP request Put MethodType = "PUT" // Delete HTTP request Delete MethodType = "DELETE" // Option HTTP request Option MethodType = "OPTION" // Head HTTP request Head MethodType = "HEAD" // Patch HTTP request Patch MethodType = "PATCH" // Connect HTTP request Connect MethodType = "CONNECT" // Options HTTP request Options MethodType = "OPTIONS" // Trace HTTP request Trace MethodType = "TRACE" // Copy HTTP Method. Copy MethodType = "COPY" // Link HTTP Method. Link MethodType = "LINK" // Unlink HTTP Method. Unlink MethodType = "UNLINK" // Purge HTTP Method. Purge MethodType = "PURGE" // Lock HTTP Method. Lock MethodType = "LOCK" // Unlock HTTP Method. Unlock MethodType = "UNLOCK" // Propfind HTTP Method. Propfind MethodType = "PROPFIND" // View HTTP Method. View MethodType = "VIEW" )
type NotFoundError ¶
type NotFoundError struct {
Message string
}
NotFoundError error
func NewNotFoundError ¶
func NewNotFoundError(msg string) *NotFoundError
NewNotFoundError constructor
func (*NotFoundError) Error ¶
func (ne *NotFoundError) Error() string
type OAuth2Config ¶
type OAuth2Config struct {
Enabled bool `yaml:"enabled" mapstructure:"enabled" env:"OAUTH2_ENABLED"`
TokenURL string `yaml:"token_url" mapstructure:"token_url" env:"OAUTH2_TOKEN_URL"`
ClientID string `yaml:"client_id" mapstructure:"client_id" env:"OAUTH2_CLIENT_ID"`
ClientSecret string `yaml:"client_secret" mapstructure:"client_secret" env:"OAUTH2_CLIENT_SECRET"`
Scopes []string `yaml:"scopes" mapstructure:"scopes" env:"OAUTH2_SCOPES"`
GrantType string `yaml:"grant_type" mapstructure:"grant_type" env:"OAUTH2_GRANT_TYPE"`
RefreshToken string `yaml:"refresh_token" mapstructure:"refresh_token" env:"OAUTH2_REFRESH_TOKEN"`
}
OAuth2Config configuration
type ProducerContractRequest ¶
type ProducerContractRequest struct {
// BaseURL of remote server
BaseURL string `yaml:"base_url" json:"base_url"`
// ExecutionTimes for contract testing
ExecutionTimes int `yaml:"execution_times" json:"execution_times"`
// MatchResponseCode for contract testing
MatchResponseCode int `yaml:"match_response_code" json:"match_response_code"`
// Track coverage
TrackCoverage bool `yaml:"track_coverage" json:"track_coverage"`
// RecordResults determines if contract validation results should be stored
RecordResults bool `yaml:"record_results" json:"record_results"`
// Verbose setting
Verbose bool `yaml:"verbose" json:"verbose"`
// Headers overrides
Headers http.Header `yaml:"-" json:"-"`
// Params local overrides
Params map[string]any `yaml:"-" json:"-"`
}
ProducerContractRequest for generating fuzz-data requests to an API implementation for producer based contract testing
func NewProducerContractRequest ¶
func NewProducerContractRequest(baseURL string, execTimes int, matchStatusCode int) *ProducerContractRequest
NewProducerContractRequest constructor
func (*ProducerContractRequest) Overrides ¶
func (req *ProducerContractRequest) Overrides() map[string]any
Overrides helper methods to aggregate headers and params
func (*ProducerContractRequest) String ¶
func (req *ProducerContractRequest) String() string
type ProducerContractResponse ¶
type ProducerContractResponse struct {
Results map[string]any `yaml:"results" json:"results"`
Errors map[string]string `yaml:"errors" json:"errors"`
Metrics map[string]float64 `yaml:"metrics" json:"metrics"`
URLs map[string]int `yaml:"urls" json:"urls"`
Succeeded int `yaml:"succeeded" json:"succeeded"`
Mismatched int `yaml:"mismatched" json:"mismatched"`
Failed int `yaml:"failed" json:"failed"`
}
ProducerContractResponse for returning summary of producer based test results
func NewProducerContractResponse ¶
func NewProducerContractResponse() *ProducerContractResponse
NewProducerContractResponse constructor
type ValidationError ¶
type ValidationError struct {
Message string
}
ValidationError error
func NewValidationError ¶
func NewValidationError(msg string) *ValidationError
NewValidationError constructor
func (*ValidationError) Error ¶
func (ve *ValidationError) Error() string
type Version ¶
type Version struct {
Version string `json:"version,omitempty"`
Commit string `json:"commit,omitempty"`
Date string `json:"date,omitempty"`
Started time.Time `json:"started,omitempty"`
}
Version creates a formatted struct for output
func NewVersion ¶
NewVersion will create a pointer to a new version object
func (*Version) ToShortened ¶
ToShortened converts the Version into a JSON String