ovhapi

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2019 License: BSD-3-Clause Imports: 14 Imported by: 0

README

Venom - Executor OVHAPI

Step to test OVH API

Use case: you software need to make call to OVH API.
You will need OVH credentials to make API call. Please follow this tutorial to get all needed keys:
FR: https://www.ovh.com/fr/g934.premiers_pas_avec_lapi
EN: https://api.ovh.com/g934.first_step_with_api

Input

In your yaml file, you can use:

  - method optional, default value: GET
  - path mandatory, example "/me"
  - noAuth optional
  - body optional
  - bodyFile optional

name: Title of TestSuite
testcases:
- name: me
  context:
    type: default
    endpoint: 'ovh-eu'
    applicationKey: 'APPLICATION_KEY'
    applicationSecret: 'APPLICATION_SECRET'
    consumerKey: 'CONSUMER_KEY'
    insecureTLS: true #default false
  steps:
  - type: ovhapi
    method: GET
    path: /me
    headers:
      header1: value1
      header2: value2
    retry: 3
    delay: 2
    assertions:
    - result.statuscode ShouldEqual 200
    - result.bodyjson.nichandle ShouldContainSubstring MY_NICHANDLE

Output

result.executor
result.timeseconds
result.timehuman
result.statuscode
result.body
result.bodyjson
result.error
  • result.timeseconds & result.timehuman: time of execution
  • 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.statuscode: Status Code of HTTP response

Default assertion

result.statuscode ShouldEqual 200

Documentation

Index

Constants

View Source
const Name = "ovhapi"

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"`
	NoAuth   bool    `json:"no_auth" yaml:"noAuth"`
	Path     string  `json:"path" yaml:"path"`
	Body     string  `json:"body" yaml:"body"`
	BodyFile string  `json:"bodyfile" yaml:"bodyfile"`
	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, workdir string) (venom.ExecutorResult, error)

Run execute TestStep

func (Executor) ZeroValueResult added in v0.17.0

func (Executor) ZeroValueResult() venom.ExecutorResult

ZeroValueResult return an empty implemtation of this executor result

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"`
	Err         string      `json:"err,omitempty" yaml:"err,omitempty"`
	Headers     Headers     `json:"headers" yaml:"headers"`
}

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