Documentation
¶
Index ¶
- Constants
- func ConvertEnvironmentToAPIVariables(environment *PostmanEnvironment) *types.APIVariables
- func ConvertPostmanToScenarios(config *types.Configuration, collection *PostmanCollection, started time.Time, ...) (scenarios []*types.APIScenario, apiVariables *types.APIVariables)
- func LoadAndConvertPostmanEnvironment(filePath string) (*types.APIVariables, error)
- func ProcessURLPath(raw string) string
- type ListenType
- type PostmanAuth
- type PostmanAuthParam
- type PostmanCollection
- type PostmanCollectionDescription
- type PostmanContext
- func (pc *PostmanContext) AddAuth(authType string, params []*PostmanAuthParam)
- func (pc *PostmanContext) AddPreRequestScript(name, script string)
- func (pc *PostmanContext) AddScript(name string, scriptType string, code string)
- func (pc *PostmanContext) AddTestScript(name, script string)
- func (pc *PostmanContext) GetAuth(authType string) []*PostmanAuthParam
- func (pc *PostmanContext) GetScripts(scriptType string) []string
- func (pc *PostmanContext) GetVariable(name string) string
- func (pc *PostmanContext) SetVariable(scope string, name string, value string)
- type PostmanConverter
- type PostmanCookie
- type PostmanEnvVariable
- type PostmanEnvironment
- type PostmanEvent
- type PostmanHeader
- type PostmanHeaderList
- type PostmanInfo
- type PostmanItem
- type PostmanItemGroup
- type PostmanItems
- type PostmanQueryParam
- type PostmanRequest
- type PostmanRequestBody
- type PostmanRequestBodyOptions
- type PostmanRequestBodyOptionsRaw
- type PostmanResponse
- type PostmanScript
- type PostmanSettings
- type PostmanURL
- type PostmanVariable
- type ScriptConverter
Constants ¶
const ( HTML string = "html" Javascript string = "javascript" JSON string = "json" Text string = "text" XML string = "xml" )
These constants represent the available raw languages.
Variables ¶
This section is empty.
Functions ¶
func ConvertEnvironmentToAPIVariables ¶
func ConvertEnvironmentToAPIVariables(environment *PostmanEnvironment) *types.APIVariables
ConvertEnvironmentToAPIVariables converts a PostmanEnvironment to APIVariables
func ConvertPostmanToScenarios ¶
func ConvertPostmanToScenarios( config *types.Configuration, collection *PostmanCollection, started time.Time, ended time.Time, ) (scenarios []*types.APIScenario, apiVariables *types.APIVariables)
ConvertPostmanToScenarios builds scenarios from Postman contents
func LoadAndConvertPostmanEnvironment ¶
func LoadAndConvertPostmanEnvironment(filePath string) (*types.APIVariables, error)
LoadAndConvertPostmanEnvironment loads a Postman environment file and converts it to APIVariables
func ProcessURLPath ¶
ProcessURLPath processes and normalizes URL paths This is a simpler version of the function you already have
Types ¶
type ListenType ¶
type ListenType string
ListenType defines the kind of script attached to an event.
const ( // PreRequest script is usually executed before the HTTP request is sent. PreRequest ListenType = "prerequest" // Test script is usually executed after the actual HTTP request is sent, and the response is received. Test ListenType = "test" )
type PostmanAuth ¶
type PostmanAuth struct {
Type types.AuthType `json:"type,omitempty"`
APIKey []*PostmanAuthParam `json:"apikey,omitempty"`
AWSV4 []*PostmanAuthParam `json:"awsv4,omitempty"`
Basic []*PostmanAuthParam `json:"basic,omitempty"`
Bearer []*PostmanAuthParam `json:"bearer,omitempty"`
Digest []*PostmanAuthParam `json:"digest,omitempty"`
Hawk []*PostmanAuthParam `json:"hawk,omitempty"`
NoAuth []*PostmanAuthParam `json:"noauth,omitempty"`
OAuth1 []*PostmanAuthParam `json:"oauth1,omitempty"`
OAuth2 []*PostmanAuthParam `json:"oauth2,omitempty"`
NTLM []*PostmanAuthParam `json:"ntlm,omitempty"`
}
PostmanAuth contains the authentication method used and its associated parameters.
func CreateAuth ¶
func CreateAuth(a types.AuthType, params ...*PostmanAuthParam) *PostmanAuth
CreateAuth creates a new PostmanAuth struct with the given parameters.
func (*PostmanAuth) GetParams ¶
func (a *PostmanAuth) GetParams() []*PostmanAuthParam
GetParams returns the parameters related to the authentication method in use.
func (*PostmanAuth) MarshalJSON ¶
func (a *PostmanAuth) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of an PostmanAuth.
func (*PostmanAuth) UnmarshalJSON ¶
func (a *PostmanAuth) UnmarshalJSON(b []byte) (err error)
UnmarshalJSON parses the JSON-encoded data and create an PostmanAuth from it. Depending on the Postman PostmanCollection version, an auth property can either be an array or an object.
- v2.1.0 : Array
- v2.0.0 : Object
type PostmanAuthParam ¶
type PostmanAuthParam struct {
Key string `json:"key,omitempty"`
Value interface{} `json:"value,omitempty"`
Type string `json:"type,omitempty"`
}
PostmanAuthParam represents an attribute for any authentication method provided by Postman. For example "username" and "password" are set as auth attributes for Basic Authentication method.
func CreateAuthParam ¶
func CreateAuthParam(key string, value string) *PostmanAuthParam
CreateAuthParam creates a new PostmanAuthParam of type string.
type PostmanCollection ¶
type PostmanCollection struct {
Auth *PostmanAuth `json:"auth,omitempty"`
Info PostmanInfo `json:"info"`
Items []*PostmanItems `json:"item"`
Events []*PostmanEvent `json:"event,omitempty"`
Variables []*PostmanVariable `json:"variable,omitempty"`
}
PostmanCollection represents a Postman PostmanCollection.
func ConvertScenariosToPostman ¶
func ConvertScenariosToPostman( name string, scenarios ...*types.APIScenario, ) (c *PostmanCollection)
ConvertScenariosToPostman builds Postman contents
func CreateCollection ¶
func CreateCollection(name string, desc string) *PostmanCollection
CreateCollection returns a new PostmanCollection.
func ParseCollection ¶
func ParseCollection(r io.Reader) (c *PostmanCollection, err error)
ParseCollection parses the content of the provided data stream into a PostmanCollection object.
func (*PostmanCollection) AddItem ¶
func (c *PostmanCollection) AddItem(item *PostmanItems)
AddItem appends an item (PostmanItem or PostmanItemGroup) to the existing items slice.
func (*PostmanCollection) AddItemGroup ¶
func (c *PostmanCollection) AddItemGroup(name string) (f *PostmanItems)
AddItemGroup creates a new PostmanItemGroup and appends it to the existing items slice.
func (*PostmanCollection) Vars ¶
func (c *PostmanCollection) Vars() map[string]string
type PostmanCollectionDescription ¶
type PostmanCollectionDescription struct {
Content string `json:"content,omitempty"`
Type string `json:"type,omitempty"`
Version string `json:"version,omitempty"`
}
PostmanCollectionDescription contains collection description.
func (PostmanCollectionDescription) MarshalJSON ¶
func (d PostmanCollectionDescription) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of a PostmanCollectionDescription. If the PostmanCollectionDescription only has a content, it is returned as a string.
func (*PostmanCollectionDescription) UnmarshalJSON ¶
func (d *PostmanCollectionDescription) UnmarshalJSON(b []byte) (err error)
UnmarshalJSON parses the JSON-encoded data and create a PostmanCollectionDescription from it. A PostmanCollectionDescription can be created from an object or a string.
type PostmanContext ¶
type PostmanContext struct {
// Original auth handling
Auth map[string][]*PostmanAuthParam
// Environment variables from external file
Environment map[string]string
// Scripts storage (replaces exec array)
Scripts map[string][]string
// Collection variables
CollectionVars map[string]string
// Execution settings
Settings *PostmanSettings
ScriptExecs []string
}
PostmanContext stores additional Postman configuration
func NewPostmanContext ¶
func NewPostmanContext() *PostmanContext
NewPostmanContext creates a new context
func (*PostmanContext) AddAuth ¶
func (pc *PostmanContext) AddAuth(authType string, params []*PostmanAuthParam)
AddAuth Auth helper methods
func (*PostmanContext) AddPreRequestScript ¶
func (pc *PostmanContext) AddPreRequestScript(name, script string)
AddPreRequestScript Script helper methods
func (*PostmanContext) AddScript ¶
func (pc *PostmanContext) AddScript(name string, scriptType string, code string)
AddScript helper methods
func (*PostmanContext) AddTestScript ¶
func (pc *PostmanContext) AddTestScript(name, script string)
func (*PostmanContext) GetAuth ¶
func (pc *PostmanContext) GetAuth(authType string) []*PostmanAuthParam
func (*PostmanContext) GetScripts ¶
func (pc *PostmanContext) GetScripts(scriptType string) []string
GetScripts returns scripts of a specific type
func (*PostmanContext) GetVariable ¶
func (pc *PostmanContext) GetVariable(name string) string
GetVariable returns variable value with scope precedence
func (*PostmanContext) SetVariable ¶
func (pc *PostmanContext) SetVariable(scope string, name string, value string)
SetVariable helper methods
type PostmanConverter ¶
type PostmanConverter struct {
// contains filtered or unexported fields
}
PostmanConverter converter
func NewPostmanConverter ¶
func NewPostmanConverter( config *types.Configuration, started time.Time, ended time.Time, ) *PostmanConverter
NewPostmanConverter creates a new converter instance
type PostmanCookie ¶
type PostmanCookie struct {
Domain string `json:"domain"`
Expires string `json:"expires,omitempty"`
MaxAge string `json:"maxAge,omitempty"`
HostOnly bool `json:"hostOnly,omitempty"`
HTTPOnly bool `json:"httpOnly,omitempty"`
Name string `json:"name,omitempty"`
Path string `json:"path"`
Secure string `json:"secure,omitempty"`
Session bool `json:"session,omitempty"`
Value string `json:"value,omitempty"`
Extensions interface{} `json:"extensions,omitempty"`
}
PostmanCookie represents a cookie that follows the Google Chrome format (https://developer.chrome.com/extensions/cookies)
type PostmanEnvVariable ¶
type PostmanEnvVariable struct {
Key string `json:"key"`
Value string `json:"value"`
Enabled bool `json:"enabled"`
}
PostmanEnvVariable represents a variable in a Postman environment
type PostmanEnvironment ¶
type PostmanEnvironment struct {
ID string `json:"id"`
Name string `json:"name"`
Values []PostmanEnvVariable `json:"values"`
}
PostmanEnvironment represents the structure of a Postman environment file
func ParseEnvironment ¶
func ParseEnvironment(reader io.Reader) (*PostmanEnvironment, error)
ParseEnvironment parses a Postman environment file into a PostmanEnvironment struct
type PostmanEvent ¶
type PostmanEvent struct {
ID string `json:"id,omitempty"`
Listen ListenType `json:"listen,omitempty"`
Script *PostmanScript `json:"script,omitempty"`
Disabled bool `json:"disabled,omitempty"`
}
An PostmanEvent defines a script associated with an associated event name.
func CreatePostmanEvent ¶
func CreatePostmanEvent(listenType ListenType, script []string) *PostmanEvent
CreatePostmanEvent creates a new PostmanEvent of type text/javascript.
type PostmanHeader ¶
type PostmanHeader struct {
Key string `json:"key"`
Value string `json:"value"`
Disabled bool `json:"disabled,omitempty"`
Description string `json:"description,omitempty"`
}
PostmanHeader represents an HTTP PostmanHeader.
type PostmanHeaderList ¶
type PostmanHeaderList struct {
Headers []*PostmanHeader
}
PostmanHeaderList contains a list of headers.
func (PostmanHeaderList) MarshalJSON ¶
func (hl PostmanHeaderList) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of a PostmanHeaderList.
func (*PostmanHeaderList) UnmarshalJSON ¶
func (hl *PostmanHeaderList) UnmarshalJSON(b []byte) (err error)
UnmarshalJSON parses the JSON-encoded data and create a PostmanHeaderList from it. A PostmanHeaderList can be created from an array or a string.
type PostmanInfo ¶
type PostmanInfo struct {
Name string `json:"name"`
Description PostmanCollectionDescription `json:"description"`
Version string `json:"version"`
Schema string `json:"schema"`
}
PostmanInfo stores data about the collection.
type PostmanItem ¶
type PostmanItem struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Variables []*PostmanVariable `json:"variable,omitempty"`
Events []*PostmanEvent `json:"event,omitempty"`
ProtocolProfileBehavior interface{} `json:"protocolProfileBehavior,omitempty"`
ID string `json:"id,omitempty"`
Request *PostmanRequest `json:"request,omitempty"`
Responses []*PostmanResponse `json:"response,omitempty"`
}
An PostmanItem is an entity which contain an actual HTTP request, and sample responses attached to it.
type PostmanItemGroup ¶
type PostmanItemGroup struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Variables []*PostmanVariable `json:"variable,omitempty"`
Events []*PostmanEvent `json:"event,omitempty"`
ProtocolProfileBehavior interface{} `json:"protocolProfileBehavior,omitempty"`
Items []*PostmanItems `json:"item"`
Auth *PostmanAuth `json:"auth,omitempty"`
}
A PostmanItemGroup is an ordered set of requests.
type PostmanItems ¶
type PostmanItems struct {
// Common fields.
Name string `json:"name"`
Description string `json:"description,omitempty"`
Variables []*PostmanVariable `json:"variable,omitempty"`
Events []*PostmanEvent `json:"event,omitempty"`
ProtocolProfileBehavior interface{} `json:"protocolProfileBehavior,omitempty"`
// Fields specific to PostmanItem
ID string `json:"id,omitempty"`
Request *PostmanRequest `json:"request,omitempty"`
Responses []*PostmanResponse `json:"response,omitempty"`
// Fields specific to PostmanItemGroup
Items []*PostmanItems `json:"item"`
Auth *PostmanAuth `json:"auth,omitempty"`
}
PostmanItems are the basic unit for a Postman collection. It can either be a request (PostmanItem) or a folder (PostmanItemGroup).
func CreatePostmanItem ¶
func CreatePostmanItem(i PostmanItem) *PostmanItems
CreatePostmanItem is a helper to create a new PostmanItem.
func CreatePostmanItemGroup ¶
func CreatePostmanItemGroup(ig PostmanItemGroup) *PostmanItems
CreatePostmanItemGroup is a helper to create a new PostmanItemGroup.
func (*PostmanItems) AddItem ¶
func (i *PostmanItems) AddItem(item *PostmanItems)
AddItem appends an item to the existing items slice.
func (*PostmanItems) AddItemGroup ¶
func (i *PostmanItems) AddItemGroup(name string) (f *PostmanItems)
AddItemGroup creates a new PostmanItem folder and appends it to the existing items slice.
func (PostmanItems) IsGroup ¶
func (i PostmanItems) IsGroup() bool
IsGroup returns false as an PostmanItem is not a group.
func (PostmanItems) MarshalJSON ¶
func (i PostmanItems) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of an PostmanItem/PostmanItemGroup.
type PostmanQueryParam ¶
type PostmanQueryParam struct {
Key string `json:"key"`
Value string `json:"value"`
Description *string `json:"description"`
}
PostmanQueryParam param for query
type PostmanRequest ¶
type PostmanRequest struct {
URL *PostmanURL `json:"url"`
Auth *PostmanAuth `json:"auth,omitempty"`
Proxy interface{} `json:"proxy,omitempty"`
Certificate interface{} `json:"certificate,omitempty"`
Method types.MethodType `json:"method"`
Description interface{} `json:"description,omitempty"`
Header []*PostmanHeader `json:"header,omitempty"`
Body *PostmanRequestBody `json:"body,omitempty"`
}
A PostmanRequest represents an HTTP request.
func (*PostmanRequest) MarshalJSON ¶
func (r *PostmanRequest) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of a PostmanRequest. If the PostmanRequest only contains an PostmanURL with the Get HTTP method, it is returned as a string.
func (*PostmanRequest) UnmarshalJSON ¶
func (r *PostmanRequest) UnmarshalJSON(b []byte) (err error)
UnmarshalJSON parses the JSON-encoded data and create a PostmanRequest from it. A PostmanRequest can be created from an object or a string. If a string, the string is assumed to be the request PostmanURL and the method is assumed to be 'GET'.
type PostmanRequestBody ¶
type PostmanRequestBody struct {
Mode string `json:"mode"`
Raw string `json:"raw,omitempty"`
URLEncoded interface{} `json:"urlencoded,omitempty"`
FormData interface{} `json:"formdata,omitempty"`
File interface{} `json:"file,omitempty"`
GraphQL interface{} `json:"graphql,omitempty"`
Disabled bool `json:"disabled,omitempty"`
Options *PostmanRequestBodyOptions `json:"options,omitempty"`
}
PostmanRequestBody represents the data usually contained in the request body.
type PostmanRequestBodyOptions ¶
type PostmanRequestBodyOptions struct {
Raw PostmanRequestBodyOptionsRaw `json:"raw,omitempty"`
}
PostmanRequestBodyOptions holds body options.
type PostmanRequestBodyOptionsRaw ¶
type PostmanRequestBodyOptionsRaw struct {
Language string `json:"language,omitempty"`
}
PostmanRequestBodyOptionsRaw represents the acutal language to use in postman. (See possible options in the cost above)
type PostmanResponse ¶
type PostmanResponse struct {
ID string `json:"id,omitempty"`
OriginalRequest *PostmanRequest `json:"originalRequest,omitempty"`
ResponseTime interface{} `json:"responseTime,omitempty"`
Timings interface{} `json:"timings,omitempty"`
Headers *PostmanHeaderList `json:"header,omitempty"`
Cookies []*PostmanCookie `json:"cookie,omitempty"`
Body string `json:"body,omitempty"`
Status string `json:"status,omitempty"`
Code int `json:"code,omitempty"`
Name string `json:"name,omitempty"`
PreviewLanguage string `json:"_postman_previewlanguage,omitempty"`
}
A PostmanResponse represents an HTTP response.
type PostmanScript ¶
type PostmanScript struct {
ID string `json:"id,omitempty"`
Type string `json:"type,omitempty"`
Exec []string `json:"exec,omitempty"`
Src *PostmanURL `json:"src,omitempty"`
Name string `json:"name,omitempty"`
}
A PostmanScript is a snippet of Javascript code that can be used to to perform setup or teardown operations on a particular response.
type PostmanSettings ¶
PostmanSettings contains execution configuration
type PostmanURL ¶
type PostmanURL struct {
Raw string `json:"raw"`
Protocol string `json:"protocol,omitempty"`
Host []string `json:"host,omitempty"`
Path []string `json:"path,omitempty"`
Port string `json:"port,omitempty"`
Query []*PostmanQueryParam `json:"query,omitempty"`
Hash string `json:"hash,omitempty"`
Variables []*PostmanVariable `json:"variable,omitempty" mapstructure:"variable"`
}
PostmanURL is a struct that contains an PostmanURL in a "broken-down way". Raw contains the complete PostmanURL.
func UnmarshalURLJSON ¶
func UnmarshalURLJSON(b []byte) (u *PostmanURL, err error)
UnmarshalURLJSON parses the JSON-encoded data and create an PostmanURL from it. An PostmanURL can be created from an object or a string. If a string, the value is assumed to be the Raw attribute of the PostmanURL.
func (*PostmanURL) MarshalJSON ¶
func (u *PostmanURL) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of an PostmanURL. It encodes the PostmanURL as a string if it does not contain any variable. In case it contains any variable, it gets encoded as an object.
func (*PostmanURL) String ¶
func (u *PostmanURL) String() string
String returns the raw version of the PostmanURL.
type PostmanVariable ¶
type PostmanVariable struct {
ID string `json:"id,omitempty"`
Key string `json:"key,omitempty"`
Type string `json:"type,omitempty"`
Name string `json:"name,omitempty"`
Value string `json:"value,omitempty"`
Description string `json:"description,omitempty"`
System bool `json:"system,omitempty"`
Disabled bool `json:"disabled,omitempty"`
}
A PostmanVariable allows you to store and reuse values in your requests and scripts.
func CreatePostmanVariable ¶
func CreatePostmanVariable(name string, value string) *PostmanVariable
CreatePostmanVariable creates a new PostmanVariable of type string.
type ScriptConverter ¶
type ScriptConverter struct {
// contains filtered or unexported fields
}
ScriptConverter converts Postman scripts to API scenario format
func NewScriptConverter ¶
func NewScriptConverter(context *PostmanContext) *ScriptConverter
NewScriptConverter creates a new script converter that's backward compatible with ScriptProcessor
func (*ScriptConverter) ConvertPreRequestScript ¶
func (c *ScriptConverter) ConvertPreRequestScript(script string, scenario *types.APIScenario)
ConvertPreRequestScript converts a pre-request script to API scenario format
func (*ScriptConverter) ConvertTestScript ¶
func (c *ScriptConverter) ConvertTestScript(script string, scenario *types.APIScenario)
ConvertTestScript converts a test script to API scenario format
func (*ScriptConverter) ProcessScript ¶
func (c *ScriptConverter) ProcessScript(exec string, name string, headers http.Header)
ProcessScript processes a script command