Testing Demo Applications
There are 4 microservices deployed in the cluster by the setup.sh script. Three of them expose a few REST APIs and another one exposes SOAP APIs.
Those services that expose REST APIs come with Swagger UI to which you can use testing the APIs in each service. However, you can also use Postman to test both of REST APIs and SOAP APIs as well.
Table of Contents
Requirements
Postman Collection and Environment
There are 4 Postman collections you can use for API testing:
Demo Application Testing - Used for testing the APIs exposed by microservices through the OpenShift Route directly.
3Scale API Testing (API Key Auth) - Used for testing the APIs exposed through API Gateway using API Key as a credential for authentication.
3Scale API Testing (API Key Pair Auth) - Used for testing the APIs exposed through API Gateway using Application ID and Application Key pair as a credential for authentication.
3Scale API Testing (OAuth) - Used for testing the APIs exposed through API Gateway with OpenID Connect OAuth 2.0 authentication.
There is also a Postman Environment file contains all environment vairables used by the collections. The enviroment variables are used to store values e.g. cluster domain, credentials etc.
Testing REST APIs via Swagger UI
Open a route for the service that you need to test.
Append
/swagger-ui
at the end of URL then pressEnter
. You should be able to see Swagger UI page that shows all REST API endpoints exposed by the service.Click on the endpoint you need to test, the panel will expand. Then click on Try it out button.
Enter paramenter(s) (if necessary), then click Execute button. The request URL and response will be shown up like a screenshot below.
Testing REST and SOAP APIs with Postman
Import Postman Collections and Environments
Create a new workspace.
Edit Postman
cluster-domain
environment variable by replacing the OpenShift cluster domain you've provisioned in the CURRENT VALUE colume. Then click Save button.
Testing API
Select Collections panel.
Open the request you need to test.
Make sure you've select the Default environment (should be done only once).
Click Send button to send request to server.
Testing API Secured With OAuth
Select Collections panel then open the request you need to test. Go to Authorization tab, scroll to bottom then click Get New Access Token button.
Postman will send request to Authentication Server (SSO, in this case) to get a token based on Client ID, Client Secret, and Realm configured in Postman Environments (variables). An access token should be returned from the server, then click Proceed button.
The Manage Access Tokens dialog will pop up with access token details. Click on Use Token button Postman will populate necessary HTTP headers.
Now you can submit a API request to server.
You can reuse the access token with other API requests as well. In the Authorization tab for the request you need to reuse the token, just select the available token. And note that you can also manage existing tokens as well.
Last updated