A Hoverfly Behavior is a function that intercepts and modifies the API response before it returns to the client. With Behaviors, it is possible to introduce bad responses, latency modelling and more to mimic real world behavior of an API which is otherwise hard to reproduce.
Starting a service creates a public available HTTP service that simulates an API. Click on “Add” will prompt you to enter the URL of the real service. Later on you can change the mode to
passthrough to suit different test purposes. However, you can leave the "Target URL" input blank to create a simulate-only service.
You can select a simulation from the dropdown which will be imported when the service starts, and you can add a label to identify your service from the Dashboard later on.
Click “OK”, and your service should be up and running within a few seconds.
A Hoverfly Behavior is a function that intercepts and modifies the API response before it returns to the client. With Behaviors, it is possible to introduce bad responses, latency model and more to mimic real world behavior of an API which is otherwise hard to reproduce.
Currently Hoverfly Cloud supports these predefined Behaviors:
Random status code
Find and replace
Set response headers
You can add a Behavior in the
Add service dialog.
Click on the toggle next to the Behavior name, for example “Random status code”, select status code you want it to return, and use the slider to change the probability of this status code.
You can add additional entries. Probabilities that total over one will get sampled down. When the probability total is less than one, the left over probability is used for the original status code.
Sending a request to the service requires an API token. Please follow the quickstart guide to create a token and we would recommend you to export it as an environment variable.
To authenticate your access to the service, an request must contains an authentication header:
curl -H "X-Hoverfly-Authorization: Bearer $HFC_TOKEN" <service URL>
In your project, you may not want to change your code to use Hoverfly Cloud. That’s why we provide an command line tool
hoverfly-cloud-cli to handle the authentication, and you can call your Hoverfly Cloud service like a localhost service.
./hcc reverse-proxy start --name <service name> --api-token $HFC_TOKEN
Once you run the above command, the service would be available on http://localhost:8500
You can click on the service name to open up the service details page. It gives you information about the service, such as launch time, mode, URL, and target URL etcs.
You can also view the journal which is a list of access logs to the service. A green entry indicates a successful match and a red entry indicates a failed match.
You can change mode using the mode dropdown. Hoverfly Cloud currently supports 4 different modes:
Simulate: simulate API response based on simulation
Spy: similar to simulate, but call the real service if a request is not matched
Capture: requests will go to the real service and all the interactions will be captured.
Passthrough: bypass Hoverfly service, and get response from the real service. This lets you switch from using virtualized service to real service without restarting your app with different configurations.
You can update your service to use a different simulation stored in your account.
Go to service detail pages, and select the simulation name from the dropdown.
Hoverfly Cloud will take care of updating the simulations in the service.
Click on the simulation link to view the simulations loaded in the service.
You can make change to it using the editor, and click “Apply” to make your change effective.
You can also export the simulation in an active service for future sharing or reuse, especially the simulations are created via capturing.
Click on the dropdown menu in the toolbar and select “Export”, it will prompt you for the simulation name.