22
33## Step to test OVH API
44
5- Use case: you software need to make call to OVH API.<br >
6- You will need OVH credentials to make API call. Please follow this tutorial to get all needed keys: <br >
5+ Use case: your software needs to make calls to OVH API.<br >
6+ You will need OVH credentials to make API calls. You can either use app keys authentication or OAuth2.
7+
8+ To use app keys authentication, please follow this tutorial: <br >
79EN: https://docs.ovh.com/gb/en/customer/first-steps-with-ovh-api/
810
11+ To use OAuth2, please follow this tutorial: <br >
12+ EN: https://help.ovhcloud.com/csm/en-manage-service-account?id=kb_article_view&sysparm_article=KB0059343
13+
914## Input
10- In your yaml file, you can use:
1115
12- ```
13- - endpoint optional, default value: ovh-eu
14- - applicationKey optional, if noAuth, otherwise mandatory
15- - applicationSecret optional, if noAuth, otherwise mandatory
16- - consumerKey optional, if noAuth, otherwise mandatory
17- - noAuth optional
18- - headers optional
19- - resolve optional
20- - proxy optional
21- - tlsRootCA optional
22-
23- - method optional, default value: GET
24- - path mandatory, example "/me"
25- - body optional
26- - bodyFile optional
27- ```
16+ The following parameters are available:
2817
29- The first batch of parameters can also be defined inside Venom variables like this
18+ | Parameter | Description | Default Value |
19+ | -------------------| ------------------------------------------------------------------| ---------------|
20+ | endpoint | Optional | ovh-eu |
21+ | applicationKey | Optional if ` noAuth ` , mandatory if using app keys authentication | |
22+ | applicationSecret | Optional if ` noAuth ` , mandatory if using app keys authentication | |
23+ | consumerKey | Optional if ` noAuth ` , mandatory if using app keys authentication | |
24+ | clientID | Optional if ` noAuth ` , mandatory if using OAuth2 | |
25+ | clientSecret | Optional if ` noAuth ` , mandatory if using OAuth2 | |
26+ | noAuth | Optional | |
27+ | headers | Optional | |
28+ | resolve | Optional | |
29+ | proxy | Optional | |
30+ | tlsRootCA | Optional | |
31+
32+ | Parameter | Description | Default Value |
33+ | -----------| -------------| ---------------|
34+ | method | Optional | GET |
35+ | path | Mandatory | |
36+ | body | Optional | |
37+ | bodyFile | Optional | |
38+
39+ The first batch of parameters can also be defined inside Venom variables like this:
3040
3141``` yaml
3242vars :
3343 ovh.endpoint : ovh-eu
3444 ovh.applicationKey : foo
3545 ovh.applicationSecret : foo
46+ ovh.clientID : foo
47+ ovh.clientSecret : foo
3648 ovh.consumerKey : foo
3749 ovh.noAuth : false
3850 ovh.headers :
4860` ` `
4961
5062## Example of an __ovhapi__ TestSuite
63+
64+ ### Using App Keys authentication
65+
5166` ` ` yaml
5267name : Title of TestSuite
5368testcases :
@@ -65,24 +80,42 @@ testcases:
6580 assertions :
6681 - result.statuscode ShouldEqual 200
6782 - result.bodyjson.nichandle ShouldContainSubstring MY_NICHANDLE
83+ ` ` `
84+
85+ ### Using OAuth2
6886
87+ ` ` ` yaml
88+ name : Title of TestSuite
89+ testcases :
90+ - name : me
91+ steps :
92+ - type : ovhapi
93+ endpoint : ' ovh-eu'
94+ clientID : ' CLIENT_ID'
95+ clientSecret : ' CLIENT_SECRET'
96+ method : GET
97+ path : /me
98+ retry : 3
99+ delay : 2
100+ assertions :
101+ - result.statuscode ShouldEqual 200
102+ - result.bodyjson.nichandle ShouldContainSubstring MY_NICHANDLE
69103` ` `
70104
71105## Output
72106
73- ```
74- result.executor
75- result.timeseconds
76- result.statuscode
77- result.body
78- result.bodyjson
79- result.err
80- ```
81- - result.timeseconds: execution duration
82- - result.err: if exists, this field contains error
83- - result.body: body of HTTP response
84- - result.bodyjson: body of HTTP response if it's a json. You can access json data as result.bodyjson.yourkey for example
85- - result.statuscode: Status Code of HTTP response
107+ The following output fields are available:
108+
109+ | Field | Description |
110+ |--------------------|--------------------------------------|
111+ | result.executor | |
112+ | result.timeseconds | Execution duration |
113+ | result.statuscode | Status Code of HTTP response |
114+ | result.body | Body of HTTP response |
115+ | result.bodyjson | Body of HTTP response if it's a JSON |
116+ | result.err | Error message if exists |
117+
118+ Note that you can access json data as ` result.bodyjson.yourkey` for example.
86119
87120# # Default assertion
88121
0 commit comments