ovhapi

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: Apache-2.0 Imports: 16 Imported by: 3

README

Venom - Executor OVHAPI

Step to test OVH API

Use case: your software needs to make calls to OVH API.
You will need OVH credentials to make API calls. You can either use app keys authentication or OAuth2.

To use app keys authentication, please follow this tutorial:
EN: https://docs.ovh.com/gb/en/customer/first-steps-with-ovh-api/

To use OAuth2, please follow this tutorial:
EN: https://help.ovhcloud.com/csm/en-manage-service-account?id=kb_article_view&sysparm_article=KB0059343

Input

The following parameters are available:

Parameter Description Default Value
endpoint Optional ovh-eu
applicationKey Optional if noAuth, mandatory if using app keys authentication
applicationSecret Optional if noAuth, mandatory if using app keys authentication
consumerKey Optional if noAuth, mandatory if using app keys authentication
clientID Optional if noAuth, mandatory if using OAuth2
clientSecret Optional if noAuth, mandatory if using OAuth2
noAuth Optional
headers Optional
resolve Optional
proxy Optional
tlsRootCA Optional
Parameter Description Default Value
method Optional GET
path Mandatory
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.clientID: foo
  ovh.clientSecret: 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

Using App Keys authentication
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
Using OAuth2
name: Title of TestSuite
testcases:
- name: me
  steps:
  - type: ovhapi
    endpoint: 'ovh-eu'
    clientID: 'CLIENT_ID'
    clientSecret: 'CLIENT_SECRET'
    method: GET
    path: /me
    retry: 3
    delay: 2
    assertions:
    - result.statuscode ShouldEqual 200
    - result.bodyjson.nichandle ShouldContainSubstring MY_NICHANDLE

Output

The following output fields are available:

Field Description
result.executor
result.timeseconds Execution duration
result.statuscode Status Code of HTTP response
result.body Body of HTTP response
result.bodyjson Body of HTTP response if it's a JSON
result.err Error message if exists

Note that you can access json data as result.bodyjson.yourkey for example.

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"`
	ClientID          string   `json:"clientID" yaml:"clientID"`
	ClientSecret      string   `json:"clientSecret" yaml:"clientSecret"`
	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