http

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2017 License: BSD-3-Clause Imports: 14 Imported by: 5

README

Venom - Executor HTTP

Step for sending SMTP

Use case: you software have to check mails for doing something with them ? Venom can send mail then execute some tests on your software.

Input

In your yaml file, you can use:

  - method optional, default value : GET
  - url mandatory
  - path optional
  - body optional
  - bodyFile optional
  - headers optional

name: Title of TestSuite
testcases:

- name: GET http testcase
  steps:
  - type: http
    method: GET
    url: https://eu.api.ovh.com/1.0/
    assertions:
    - result.body ShouldContainSubstring /dedicated/server
    - result.body ShouldContainSubstring /ipLoadbalancing
    - result.statuscode ShouldEqual 200
    - result.bodyjson.apis.apis0.path ShouldEqual /allDom


- name: POST http with bodyFile
  steps:
  - type: http
    method: POST
    url: https://eu.api.ovh.com/1.0/
    bodyFile: /tmp/myfile.tmp
    assertions:
    - result.statuscode ShouldNotEqual 200


- name: POST http with multipart
  steps:
  - type: http
    method: POST
    url: https://eu.api.ovh.com/1.0/
    multipart_form:
        file: '@/tmp/myfile.tmp'
    assertions:
    - result.statuscode ShouldNotEqual 200

NB: to post a file with multipart_form, prefix the path to the file with '@'

Output

result.executor
result.timeseconds
result.timehuman
result.statuscode
result.body
result.bodyjson
result.headers
result.error
  • result.timeseconds & result.timehuman: time of execution
  • result.executor.executor.method: HTTP method used, example: GET
  • result.executor.executor.url: url called
  • result.executor.executor.multipartform: multipartform if exists
  • result.err: if exists, this field contains error
  • result.body: body of HTTP response
  • result.bodyjson: body of HTTP response if it's a json. You can access json data as result.bodyjson.yourkey for example
  • result.headers: headers of HTTP response
  • result.statuscode: Status Code of HTTP response

Default assertion

result.statuscode ShouldEqual 200

Documentation

Index

Constants

View Source
const Name = "http"

Name of executor

Variables

This section is empty.

Functions

func New

func New() venom.Executor

New returns a new Executor

Types

type Executor

type Executor struct {
	Method        string      `json:"method" yaml:"method"`
	URL           string      `json:"url" yaml:"url"`
	Path          string      `json:"path" yaml:"path"`
	Body          string      `json:"body" yaml:"body"`
	BodyFile      string      `json:"bodyfile" yaml:"bodyfile"`
	MultipartForm interface{} `json:"multipart_form" yaml:"multipart_form"`
	Headers       Headers     `json:"headers" yaml:"headers"`
}

Executor struct. Json and yaml descriptor are used for json output

func (Executor) GetDefaultAssertions

func (Executor) GetDefaultAssertions() venom.StepAssertions

GetDefaultAssertions return default assertions for this executor Optional

func (Executor) Run

func (Executor) Run(testCaseContext venom.TestCaseContext, l venom.Logger, step venom.TestStep) (venom.ExecutorResult, error)

Run execute TestStep

type Headers

type Headers map[string]string

Headers represents header HTTP for Request

type Result

type Result struct {
	Executor    Executor    `json:"executor,omitempty" yaml:"executor,omitempty"`
	TimeSeconds float64     `json:"timeseconds,omitempty" yaml:"timeseconds,omitempty"`
	TimeHuman   string      `json:"timehuman,omitempty" yaml:"timehuman,omitempty"`
	StatusCode  int         `json:"statuscode,omitempty" yaml:"statuscode,omitempty"`
	Body        string      `json:"body,omitempty" yaml:"body,omitempty"`
	BodyJSON    interface{} `json:"bodyjson,omitempty" yaml:"bodyjson,omitempty"`
	Headers     Headers     `json:"headers,omitempty" yaml:"headers,omitempty"`
	Err         string      `json:"err,omitempty" yaml:"err,omitempty"`
}

Result represents a step result. Json and yaml descriptor are used for json output

Jump to

Keyboard shortcuts

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