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.

Scenario: Getting user information
Given that a secure endpoint is up at mysecureddomain.com

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

Scenario: Getting user information
Given that a endpoint is up at mydomain.com

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.

Scenario: Getting user information
Given that a endpoint is up at mydomain.com
Given I set Content-Type header to application/json
Given I set DocId header to 3001

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.

Scenario: Getting user information
Given that a endpoint is up at mydomain.com
Given I set headers to
| name | value |
| Content-Type | application/json |
| DocId | 3001 |

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.

Scenario: Getting user information
Given that a endpoint is up at mydomain.com
Given I set Content-Type header to application/json
Given I set query parameter name to John

Given I set query parameters to

If we want to set multiple parameters at the same time, we can use this step instead.

Scenario: Getting user information
Given that a endpoint is up at mydomain.com
Given I set query parameters to
| name | value |
| name | John |
| gender | male |

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.

Scenario: Creating a new task
Given that a secure endpoint is up at mydomain.com
Given I set Content-Type header to application/json
Given I set the JSON body to
"""
`{
"name": "New Task",
"priority": 1,
"notes": "Go document things"
}`
"""

Given I set follow redirection to "true/false"

If you want to enable follow redirection to enable or disable.

Scenario: Getting user information
Given that a endpoint is up at mydomain.com
Given I set follow redirection to "true"

Given I set form data to

If we want to add form data.

Scenario: Getting user information
Given that a endpoint is up at mydomain.com
Given I set form data to
| name | value |
| name | John |
| gender | male |

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.

Scenario: Getting user information
Given that a endpoint is up at mydomain.com
Given I set encoded form data to
| name | value |
| name | John |
| gender | male |

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.

Scenario: Creating a new task
Given that a secure endpoint is up at mydomain.com
Given I set Content-Type header to application/json
Given I set the cookie to channel=direct

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.

Scenario: Getting user information
Given that a endpoint is up at mydomain.com
Given I set Content-Type header to application/json
Given I set cookie "name" to "John"

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

Set basic authentication, can be as simple as the following example.

Scenario: Creating a new task
Given that a secure endpoint is up at mydomain.com
Given I set Content-Type header to application/json
Given I have basic authentication credentials myusername and mypa55w0rd

The step will automaticall add HTTP Header Authorization with Based64 encoded credentials.

Authorization: Basic bXl1c2VybmFtZTpteXBhNTV3MHJk

Given I set the bearer token to {token}

Sets bearer authorisation token to our request.

Scenario: Creating a new task
Given that a secure endpoint is up at mydomain.com
Given I set Content-Type header to application/json
Given I set the bearer token to bXl1c2VybmFtZQ==:bXlwYTU1dzByZA==

So this will add HTTP Header as follows

Authorization: Bearer bXl1c2VybmFtZQ==:bXlwYTU1dzByZA==

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.

Scenario: Creating a new task
Given that a secure endpoint is up at mydomain.com
Given I set Content-Type header to application/json
Given I set the bearer token with "userSession"

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.

Scenario: Getting user information
Given that a endpoint is up at mydomain.com
Given I set Content-Type header to application/json
Given I set DocId header to 3001
Given I set the request timeout to 5 seconds
When I GET /users/info