http-endpoint-tester
A HTTP endpoint tester using node.js, inspired by the node-test-tutorial of David Beath and the talk of Danny Dinneen at the 2014 edition of the Endpoint conference., (*1)
The tool is written to be used in a CI pipeline with jenkins, to test endpoints of rest(ful) API's. That's why it depends on environment variables, this makes it easy to use the tool in a CI pipeline., (*2)
Usage
initialise environment
npm install
, (*3)
This will install/update all the required modules for running the tests, (*4)
Also a composer wrapper is provided, implemented to keep our own jenkins as stupid as possible ;), (*5)
Run tests
ENDPOINT_PATHS=<path/to/paths/file.json> ENDPOINT_HOST=<host>:<port> SITE_URI=<FQDN> ./node_modules/.bin/mocha --ui tdd
, (*6)
Adding paths to test
Select the project in resources
Open paths.json
and add the following stanza:, (*7)
json
[
{
"path": "/api/info",
"method": "GET",
"headers": {
"header1": "value1",
"header2": "value2"
},
"statusCode": [200, 302],
"public": 1,
"secure": 0,
"requireFQDN": 0,
"timeout": 500
},
{
// another stanza
}
]
, (*8)
path: path to test
method: GET,POST, PUT or PATCH
statuscode: [statuscode(s)]
public: should endpoint be available in production
secure: use http or https (needs to be implemented)
timeout: timeout in milliseconds
requireFQDN: mark a test as optional or required when an site uri has been specified. ( optional parameter ), (*9)
public and secure are not implemented yet., (*10)
NOTE on site_uri: this will be set as host header in the request object as demanded by the HTTP1.1 standard, but the request/request implementation will use this value as proxy.
So when the tested host is not identical to the site_uri, you are strongly advised to specify followRedirects to false., (*11)
Resources
Todo