Testing API Gateway
In this microlearning, we will dive into two key functionalities for ensuring your API Gateway operates smoothly: flow testing and Swagger UI. We will start by exploring how flow testing can validate your API Gateway's exit gates, and then we will move on to using Swagger UI to test the entire operation from a client’s perspective. Let’s get started!
Should you have any questions, please contact academy@emagiz.com.
1. Prerequisites
- Basic knowledge of the eMagiz platform
- Basic knowledge of the API Gateway pattern
2. Key concepts
This microlearning centers around testing the API Gateway (operations).
- With testing, we mean: Verifying that the operation does what it is supposed to do.
3. Testing API Gateway
In this microlearning, we will focus on testing your API Gateway (operations) with the help of two functionalities that the platform offers. First, we take a look at flow testing, secondly, we turn our attention to Swagger UI.
- Flow testing is meant for testing the exit gates
- Swagger UI is meant for testing the whole operation as a client
- Both play an intricate part in testing your API Gateway
3.1 Flow Testing
In the Crash Course Platform we have several microlearnings on the topic of flow testing. Please take a look at those microlearnings first if the concept of flow testing is new to you. As described there, the flow testing functionality also works for API Gateway exit gates. There are two ways you can test your API calls to external systems, either with a mocked endpoint or live by calling the actual endpoint.
3.1.1 "Mock" Testing
Within the "mock" functionality, you can test the functional part of the API Gateway exit flow (i.e.. transformation, authentication logic, filtering, and error handling) without testing the connectivity to the external system. This way you can increase the chances of being first time right before deploying your solution on the Test (or Acceptance) environment. A typical flow test for an exit gate looks as follows.
3.1.1 "Live" Testing
Live flow testing allows you to also test the connectivity part of the endpoint without having to deploy the flow first. This can be done by toggling from "mock" towards "live" below the exit gate component in the flowtest overview. With the right URL and credentials, you are able to retrieve the response from the endpoint and see inspect whether the functionality afterwards is working properly. The restriction of live flowtesting is that it can only be done with fuctioning endpoints and with the right credentials added to your flow.
3.2 Testing with Swagger UI
When you navigate to the Swagger UI page you will see that there is a "try-it-out" button per operation. After you have pressed this button you will see a button called "Execute" appear. By pressing this button you will test the API Gateway functionality of a specific operation as if you were the client.
The Swagger UI will give feedback based on what happened after you have pressed the button to execute
4. Key takeaways
- Flow Testing is ideal for verifying API Gateway exit gates, including aspects such as transformation, authentication, filtering, and error handling. You can test either with mocked endpoints or live connections.
- Swagger UI is useful for testing API Gateway operations from a client’s perspective. It allows you to execute and validate specific API operations, providing immediate feedback on their functionality.
- Both flow testing and Swagger UI are essential for thoroughly testing your API Gateway, ensuring that both individual components and overall operations perform as expected.
5. Suggested Additional Readings
If you are interested in this topic and want more information on it please read the help text provided by eMagiz and read the following links: