Given Steps
Autokin REST Steps

Given that a secure endpoint is up at {domain}

This step is used to define that the scenario will connect to a domain API with secured or using HTTPS.
1
Scenario: Getting user information
2
Given that a secure endpoint is up at mysecureddomain.com
Copied!
In the example above, we are defining that the API call will be at https://mysecuredomain.com.

Given that a endpoint is up at {domain}

This step is the counterpart of the previous step, instead of using https this denotes that we are connecting to http only. Example, if the API is hosted at http://mydomain.com
1
Scenario: Getting user information
2
Given that a endpoint is up at mydomain.com
Copied!
Before any API call we need to have this Given step to specify the API domain and the protocol to use.

Given I set {name} header to {value}

In most request HTTP headers are set to define the behaviour of the request. This step will add header information to our scenario. For example, we want to add HTTP header Content-Type with value of application/json.
1
Scenario: Getting user information
2
Given that a endpoint is up at mydomain.com
3
Given I set Content-Type header to application/json
4
Given I set DocId header to 3001
Copied!
In the above example, we add 2 headers to our request.

Given I set headers to

We can use this alternative steps to add multiple headers.
1
Scenario: Getting user information
2
Given that a endpoint is up at mydomain.com
3
Given I set headers to
4
| name | value |
5
| Content-Type | application/json |
6
| DocId | 3001 |
Copied!
This adds 2 headers similar to the earlier example.

Given I set query parameter {name} to {value}

If we want to add query parameter to our request, we can use this step. For example, we need name query parameter with John as value.
1
Scenario: Getting user information
2
Given that a endpoint is up at mydomain.com
3
Given I set Content-Type header to application/json
4
Given I set query parameter name to John
Copied!

Given I set query parameters to

If we want to set multiple parameters at the same time, we can use this step instead.
1
Scenario: Getting user information
2
Given that a endpoint is up at mydomain.com
3
Given I set query parameters to
4
| name | value |
5
| name | John |
6
| gender | male |
Copied!
That should set our request with 2 query parameters.

Given I set the JSON body to

Now let say that we need to set the body of the request, we can do this using this step.
1
Scenario: Creating a new task
2
Given that a secure endpoint is up at mydomain.com
3
Given I set Content-Type header to application/json
4
Given I set the JSON body to
5
"""
6
`{
7
"name": "New Task",
8
"priority": 1,
9
"notes": "Go document things"
10
}`
11
"""
Copied!

Given I set follow redirection to "true/false"

If you want to enable follow redirection to enable or disable.
1
Scenario: Getting user information
2
Given that a endpoint is up at mydomain.com
3
Given I set follow redirection to "true"
Copied!

Given I set form data to

If we want to add form data.
1
Scenario: Getting user information
2
Given that a endpoint is up at mydomain.com
3
Given I set form data to
4
| name | value |
5
| name | John |
6
| gender | male |
Copied!
This will add form data to our request and include a header with Content-Type set to multipart/form-data.

Given I set encoded form data to

If we want to add encoded form data.
1
Scenario: Getting user information
2
Given that a endpoint is up at mydomain.com
3
Given I set encoded form data to
4
| name | value |
5
| name | John |
6
| gender | male |
Copied!
This will add form data to our request and include a header with Content-Type set to application/x-www-form-urlencoded.
In some cases, request required some prepopulated cookies, so let's have some example.
1
Scenario: Creating a new task
2
Given that a secure endpoint is up at mydomain.com
3
Given I set Content-Type header to application/json
4
Given I set the cookie to channel=direct
Copied!
This will create a cookie bounded to the domain that was previously sepcified.
If we want to add cookie to our request, we can use this step. For example, we need name cookie with John as value.
1
Scenario: Getting user information
2
Given that a endpoint is up at mydomain.com
3
Given I set Content-Type header to application/json
4
Given I set cookie "name" to "John"
Copied!

Given I have basic authentication credentials {username} and {password}

Set basic authentication, can be as simple as the following example.
1
Scenario: Creating a new task
2
Given that a secure endpoint is up at mydomain.com
3
Given I set Content-Type header to application/json
4
Given I have basic authentication credentials myusername and mypa55w0rd
Copied!
The step will automaticall add HTTP Header Authorization with Based64 encoded credentials.
1
Authorization: Basic bXl1c2VybmFtZTpteXBhNTV3MHJk
Copied!

Given I set the bearer token to {token}

Sets bearer authorisation token to our request.
1
Scenario: Creating a new task
2
Given that a secure endpoint is up at mydomain.com
3
Given I set Content-Type header to application/json
4
Given I set the bearer token to bXl1c2VybmFtZQ==:bXlwYTU1dzByZA==
Copied!
So this will add HTTP Header as follows
1
Authorization: Bearer bXl1c2VybmFtZQ==:bXlwYTU1dzByZA==
Copied!

Given I set the bearer token with {stored value name}

Sets bearer token with a previously stored value. For example, in one of the previous API call we do a login, and from the sucessful response, we kep the session token as userSession, we can use this to chain our scenarios.
1
Scenario: Creating a new task
2
Given that a secure endpoint is up at mydomain.com
3
Given I set Content-Type header to application/json
4
Given I set the bearer token with "userSession"
Copied!

Given I set the request timeout to {timeout} seconds

Overrides the default timeout of the API request of 10 seconds. Timeout value are in seconds.
1
Scenario: Getting user information
2
Given that a endpoint is up at mydomain.com
3
Given I set Content-Type header to application/json
4
Given I set DocId header to 3001
5
Given I set the request timeout to 5 seconds
6
When I GET /users/info
Copied!