Mock recording allows an API Fortress user to pass API requests and responses directly into the API Fortress mocking platform. This largely eliminates the need to manually create mock response cases. To do so, we’re making use of the Kong Microgateway
The process is divided into a few parts. Here’s how we’re going to approach it:
- First, we’re going to turn on the Kong proxy server.
- Next, we’re going to create a proxied endpoint.
- Finally, we’re going to push that proxied endpoint into API Fortress mocking.
A few of these steps are fairly technical, but we’re going to be as explicit as possible with the documentation and as always, if you need assistance, feel free to reach out to email@example.com
What We Need:
Let’s make sure we have everything we need:
- An updated version of the API Fortress core/docker-compose.yml which includes the Kong section at the end. The bottom of your docker-compose should look like this:
2. The initialization script, init_kong.sh
3. The start script, start_kong.sh
If we have all of the above, perfect! We’re ready to start. If not, feel free to reach out to firstname.lastname@example.org
to let us know what you need!
First, we need to ensure that at the API Fortress Postgres instance is running. Execute a
sudo docker ps
from the command line and ensure that it is running. The image below is the entry that you’re looking for:
Next, we need to initialize Kong. This is done by running the previously mentioned script, init_kong.sh
. Issue the following command from the command line:
Once Kong has finished initializing, we can proceed.
Next, we need to start the Kong container itself. We do so by issuing the following command:
sudo docker-compose up -d apifortress-kong
Once the container has finished starting, we can do a
sudo docker ps
to view the currently running containers and verify that we started it successfully.
Finally, we can verify that the proxy is up and running by issuing the following cURL command from the command line, or an identically structured HTTP request from the HTTP client of your choice (note: replace the ‘apif.example.com’ component with the corresponding part of your instances URL):
curl -v http://apif.example.com:8001
A positive response from this route indicates that the proxy server is up and running. Congratulations! You now have a live proxy server!
Our last step in the setup phase is creating an API Fortress API key. The gif below shows the process.
NEXT – Step 2: Proxying a Route
- Click the gear in the upper right corner of the view
- Click “API Keys” in the navigation bar on the left
- Click “+API Key”
- Name and save your API Key. It’s helpful at this point to copy the key and secret to an easy to reach location, as we’ll need it in later steps.