HttpTestServer

HttpTestServer{#HttpTestServer}

HttpTestServer{#HttpTestServer}

Http server to help the systemtest visualize http calls.

new HttpTestServer(params)

Param
Type
Description
params
Object
Required - The params object containing properties passed to the constructor
params.port
number
Required - Port number to start the Http server on
params.enableHealthEndpointAt
string
Required - Url string with the endpoint to the healthcheck

start()

Start the http server.
Listening on specified port.

stop()

Stop the Http server.
Checks if there are any http calls left to respond to or endpoints waiting for calls, responds to these endpoints and then stops the server.
Throws errror if there are leftover calls not handled before shutdown.

getServerHost() {#getServerHost}⇒ string

Gets the server host.
Returns: string - networkInterfaceAddress - A string with the address for the eth0 network

waitForCall(endpoint, [params]) {#waitForCall}⇒ Promise.<Object>

Gets an endpoint to handle. Checks if an endpoint is waiting for an answer and resolves an answer to it.
Or puts the endpoint on a queue to be handled when a request for that endpoints comes in.
Returns: Promise.<Object> - Promise object represents the object with resolve, reject and params to resolve the incoming http call
Param
Type
Default
Description
endpoint
string
Required - Url string with the endpoint to either resolve or put on a queue
params
Object
{}
Object with params to the request. Example: treatContentTypeAs: 'application/json'

onHttpCall(request, response) {#onHttpCall}⇒ Promise.<Object> | void

Handles all incoming Http calls
Either puts the request on queue to be handled or responds with data.
Returns: Promise.<Object> | void - Promise object represents an object with the data from the request or, returns void and puts the request in queue.
Param
Type
Description
request
Object
Required - Request object with the incoming http call
response
Object
Required - Response object to respond to the incoming http call