chatterbox is a tool for chatting with a REST endpoint.
You write conversations using a yaml
formalism describing an arbitrary
complex interaction between chatterbox and the endpoint.
chatterbox keeps a state during the execution of a conversation so that you can use the collected responses and use those to feed the subsequent inputs.
chatterbox could be useful to you when you have to:
- Prototype RESTful protocols.
- Quickly build a complex interaction with an endpoint.
- Debug/test your endpoint when APIs are not available.
chatterbox embeds a JavaScript interpreter: V8 so the user can benefit from scripting capabilities. A JavaScript context is kept during the entire conversation; this allows to maintain an arbitrary state.
The following example describes a conversation against an S3 service
running on localhost:7480
.
The interaction uses 3 distinct requests to realize an object multipart
upload using the S3 APIs:
Every request is authenticated using the AWS Signature Version 4.
conversations:
- host: localhost:7480
auth:
accessKey: test
secretKey: test
requests:
- method: POST
id: req1
enabled: true
uri: my-bucket/my-object.mp
queryString: uploads
auth: aws_v4
- method: PUT
id: req2
enabled: true
uri: my-bucket/my-object.mp
queryString: partNumber=1&uploadId={{req1.response.body.UploadId}}
data: "some-test-data-1"
auth: aws_v4
- method: POST
enabled: true
uri: my-bucket/my-object.mp
queryString: format=json&uploadId={{req1.response.body.UploadId}}
auth: aws_v4
data: |
<?xml version="1.0" encoding="UTF-8"?>
<CompleteMultipartUpload xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Part>
<ETag>{{req2.response.headers.ETag}}</ETag>
<PartNumber>1</PartNumber>
</Part>
</CompleteMultipartUpload>
The second request is making use of the UploadId
property
obtained from the response's body in the first request:
queryString: partNumber=1&uploadId={{req1.response.body.UploadId}}
The syntax:
{{req1.*}}
denotes a path starting from the node identified with id: req1
in the output yaml
.
Any property added in the output yaml
during the conversation can be
referenced in any subsequent property using the {{.id.*}}
syntax.