layout | page_title | sidebar_current | description |
---|---|---|---|
runscope |
Runscope: runscope_step |
docs-runscope-resource-step |
Provides a Runscope step resource. |
A step resource. API tests are comprised of a series of steps, most often HTTP requests. In addition to requests, you can also add additional types of steps to your tests like pauses and conditions.
resource "runscope_step" "main_page" {
bucket_id = "${runscope_bucket.bucket.id}"
test_id = "${runscope_test.test.id}"
step_type = "request"
url = "http://example.com"
note = "A comment for the test step"
method = "GET"
variables {
name = "httpStatus"
source = "response_status"
}
variables {
name = "httpContentEncoding"
source = "response_header"
property = "Content-Encoding"
}
assertions {
source = "response_status"
comparison = "equal_number"
value = "200"
}
assertions {
source = "response_json"
comparison = "equal"
value = "c5baeb4a-2379-478a-9cda-1b671de77cf9"
property = "data.id"
}
auth {
username = "myUsername"
auth_type = "basic"
password = "myPassword"
}
before_scripts = [<<EOF
var endVar = new Date();
var startVar = new Date();
alert('this is a multi-line before script')
EOF
]
scripts = [<<EOF
var endVar = new Date();
var startVar = new Date();
alert('this is a multi-line after script')
EOF
]
headers {
header = "Accept-Encoding"
value = "application/json"
}
headers {
header = "Accept-Encoding"
value = "application/xml"
}
headers {
header = "Authorization"
value = "Bearer bb74fe7b-b9f2-48bd-9445-bdc60e1edc6a"
}
}
resource "runscope_test" "test" {
bucket_id = "${runscope_bucket.bucket.id}"
name = "runscope test"
description = "This is a test test..."
}
resource "runscope_bucket" "bucket" {
name = "terraform-provider-test"
team_uuid = "dfb75aac-eeb3-4451-8675-3a37ab421e4f"
}
The following arguments are supported:
bucket_id
- (Required) The id of the bucket to associate this step with.test_id
- (Required) The id of the test to associate this step with.note
= (Optional) A comment attached to the test step.step_type
- (Required) The type of step.- request
- pause
- condition
- ghost
- subtest
When creating a request
type of step the additional arguments also apply:
method
- (Required) The HTTP method for this request step.variables
- (Optional) A list of variables to extract out of the HTTP response from this request. Variables documented below.assertions
- (Optional) A list of assertions to apply to the HTTP response from this request. Assertions documented below.headers
- (Optional) A list of headers to apply to the request. Headers documented below.body
- (Optional) A string to use as the body of the request.auth
- (Optional) The credentials used to authenticate the requestbefore_script
- (Optional) Runs a script before the request is madescript
- (Optional) Runs a script after the request is made
Variables (variables
) supports the following:
name
- (Required) Name of the variable to define.property
- (Required) The name of the source property. i.e. header name or json pathsource
- (Required) The variable source, for list of allowed values see: https://www.runscope.com/docs/api/steps#assertions
Assertions (assertions
) supports the following:
source
- (Required) The assertion source, for list of allowed values see: https://www.runscope.com/docs/api/steps#assertionsproperty
- (Optional) The name of the source property. i.e. header name or json pathcomparison
- (Required) The assertion comparison to make i.e.equals
, for list of allowed values see: https://www.runscope.com/docs/api/steps#assertionsvalue
- (Optional) The value thecomparison
will use
Example Assertions
Status Code == 200
"assertions": [
{
"source": "response_status",
"comparison": "equal_number",
"value": 200
}
]
JSON element 'address' contains the text "avenue"
"assertions": [
{
"source": "response_json",
"property": "address",
"comparison": "contains",
"value": "avenue"
}
]
Response Time is faster than 1 second.
"assertions": [
{
"source": "response_time",
"comparison": "is_less_than",
"value": 1000
}
]
The headers
list supports the following:
header
- (Required) The name of the headervalue
- (Required) The name header value
The following attributes are exported:
id
- The ID of the step.