ovhapi

package
v1.1.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2022 License: Apache-2.0 Imports: 16 Imported by: 3

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:
EN: https://docs.ovh.com/gb/en/customer/first-steps-with-ovh-api/

Input

In your yaml file, you can use:

  - endpoint optional, default value: ovh-eu
  - applicationKey optional, if noAuth, otherwise mandatory
  - applicationSecret optional, if noAuth, otherwise mandatory
  - consumerKey optional, if noAuth, otherwise mandatory
  - noAuth optional
  - headers optional
  - resolve optional
  - proxy optional
  - tlsRootCA optional

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

The first batch of parameters can also be defined inside Venom variables like this

vars:
  ovh.endpoint: ovh-eu
  ovh.applicationKey: foo
  ovh.applicationSecret: foo
  ovh.consumerKey: foo
  ovh.noAuth: false
  ovh.headers:
    x-foo: foo
  ovh.resolve:
  - example.org:443:127.0.0.1
  ovh.proxy: localhost:8000
  ovh.tlsRootCA: |-
    -----BEGIN CERTIFICATE-----
    MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCB
    ...
    -----END CERTIFICATE-----

Example of an ovhapi TestSuite

name: Title of TestSuite
testcases:
- name: me
  steps:
  - type: ovhapi
    endpoint: 'ovh-eu'
    applicationKey: 'APPLICATION_KEY'
    applicationSecret: 'APPLICATION_SECRET'
    consumerKey: 'CONSUMER_KEY'
    method: GET
    path: /me
    retry: 3
    delay: 2
    assertions:
    - result.statuscode ShouldEqual 200
    - result.bodyjson.nichandle ShouldContainSubstring MY_NICHANDLE

Output

result.executor
result.timeseconds
result.statuscode
result.body
result.bodyjson
result.error
  • result.timeseconds: execution duration
  • 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 {
	Endpoint          string   `json:"endpoint" yaml:"endpoint"`
	ApplicationKey    string   `json:"applicationKey" yaml:"applicationKey"`
	ApplicationSecret string   `json:"applicationSecret" yaml:"applicationSecret"`
	ConsumerKey       string   `json:"consumerKey" yaml:"consumerKey"`
	NoAuth            *bool    `json:"noAuth" yaml:"noAuth"`
	Headers           Headers  `json:"headers" yaml:"headers"`
	Resolve           []string `json:"resolve" yaml:"resolve"`
	Proxy             string   `json:"proxy" yaml:"proxy"`
	TLSRootCA         string   `json:"tlsRootCA" yaml:"tlsRootCA"`

	Method   string `json:"method" yaml:"method"`
	Path     string `json:"path" yaml:"path"`
	Body     string `json:"body" yaml:"body"`
	BodyFile string `json:"bodyFile" yaml:"bodyFile"`
}

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

func (Executor) Run

func (Executor) Run(ctx context.Context, step venom.TestStep) (interface{}, error)

Run execute TestStep

func (Executor) ZeroValueResult added in v0.17.0

func (Executor) ZeroValueResult() interface{}

ZeroValueResult return an empty implementation of this executor result

type Headers

type Headers map[string]string

Headers represents header HTTP for Request

type Result

type Result struct {
	TimeSeconds float64     `json:"timeseconds,omitempty" yaml:"timeseconds,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