Mock server for isolated functional testing.
Licensed under the Apache 2 license.
Docker image is available at pileworx/rebound on Docker Hub.
The server's default port is 8585. To create a response, PUT to /mock
{
"scenario": "Scenario Name",
"when": {
"request": {
"method": "PUT",
"path": "/foo/bar",
"query": "foo=bar&bar=baz",
"headers": [
{
"name": "accept",
"value": "application/json"
}
],
"body": "{\"foo\":\"bar\"}"
}
},
"then": [
{
"status": 200,
"headers": [
{
"name": "content-type",
"value": "application/hal+json"
}
],
"body": "{\"foo\":\"$bar\"}",
"values": {
"bar": "this is my first value"
}
}
]
}
A subsequent request to /foo/bar?foo=bar&bar=baz will return an HTTP Status of OK(200), a Content-Type of application/hal+json, and a body of:
{
"propertyName":"this is my value"
}
- Required
Name of the Scenario you are creating
- Required
- Required
The http request to expect
- Required
HTTP Verb. Currently supporting GET, PUT, POST, PATCH, and DELETE. HEAD and OPTIONS are in future plans.
- Required
URL Path.
- Optional
HTTP Query String.
- Optional
A list of name value pairs of the request headers.
- Optional
Expected body of POST, PUT, or PATCH requests.
- Required
A list of expected responses.
Responses will be returned in order submitted and will return a failed response once the list is exhausted. If one response is submitted. It will return that response on every matching request without a failure.
- Required
HTTP Status Code.
- Optional
A list of name value pairs of the response headers.
- Optional
Stubbed response body. The body field supports Velocity VTL for scripting. Velocity VTL documentation can be found here:
http://people.apache.org/~henning/velocity/html/ch02s02.html
example:
{
"status": 200,
"headers": [
{
"name": "content-type",
"value": "application/hal+json"
}
],
"body": "[#foreach($i in [1..5]){\"foo\":\"this is my value\"} #if($foreach.count != 5), #end #end]"
}
- Optional
Key-Value pairs to use in VTL
example response:
{
"status": 200,
"headers": [
{
"name": "content-type",
"value": "application/hal+json"
}
],
"body": "{\"foo\":\"$bar\"}",
"values": {
"bar": "this is my first value"
}
}