Vafion is a preferred vacation rental technology partner and API integrations are what we do every day. I would like to share with you on:
HOW vREST API CAN BE USED FOR REST TESTING?
vREST is an online API testing tool for Automated Testing, Mocking, Automated Recording and Specification of REST / RESTful / HTTP APIs. The tool’s primary function is to test rest APIs online. It works in hosted mode. The first step for using this application is to SIGN UP in the application.
The steps to use vREST API are as follows
- Test Cases.
- API Specification.
- Response Validation.
- Mock Server.
- Test Runner.
Test Case Creation: A test case can be created by the following ways
A test case can be created by simply clicking on “New” button in the “Test Cases” tab. A popup will appear as shown below and fill in the basic details to create a new test case.
API Spec tab is used to specify HTTP REST API specifications. We can create our API Specs as mentioned in the below figure.
Manual Insertion: An API spec can be created by simply clicking on “New” button in the “API Specs” tab. A popup will appear as shown below and fill in the details to create a new API spec.
Mock Server provides functionality to mock any HTTP request.
- This functionality can be helpful in decoupling backend development from the frontend functionality. One can start developing frontend directly using mock HTTP requests.
- To speedup the development because one can start writing the frontend before the backend is in place. Both teams (Backend and frontend) can work in parallel.
- Can be used to write demo applications without the backend is in place.
- API Mock CreationAn API Mock can be created by simply clicking on “New” button in the “Mock Server” tab. A popup will appear as shown below and fill in the details to create a new API Mock.
First parameter is test case, having all the details of a test case which has been provided in the test cases tab.
Second parameter is a actual response of the HTTP request. It is a JSON object with the following keys:
- headers: HTTP Response headers retrieved
- actualResults: HTTP Response result retrieved. It is also a JSON object with the following keys:
- content: (String) Actual HTTP Response body
- resultType: (String) Content type of HTTP Response body.
Third parameter is methods object. This parameter contains the following predefined utility methods:
- compareJSON: Compares two JSON objects property by property and also provides special checks for given properties by using “customJSONPropertyChecker” parameter.
- validateJSONSchema: Validates JSON objects using JSON Schemas.User can define their own custom response validators. By default, following two response validators are provided:
This validator checks the contents of expected results with actual results retrieved for a test case. This validator checks the results for exact match.
Note: If a test case always produces dynamic results, then default validator will always fail the test case. In this scenario, in order to correctly validate this test case, define your own custom response validator and in that validator, either ignore the dynamic attributes in the actual results or just check the schema of the dynamic attributes.
Default Schema Validator
This validator checks the schema of actual results (Only applicable for JSON responses) with the expected schema defined during test case definition.
This functionality serves the purpose of making authenticated/authorized HTTP requests. User can setup any number of authorizations in vREST.
In Basic Authorization, system asks for username and password for making authenticated HTTP requests and basic authorization header will be sent while making HTTP requests.
In OAuth 1.0 authorization, system asks for the following attributes:
- Signature Method (Supports HMAC-SHA1, PLAINTEXT)
- Consumer Key
- Consumer Secret
After filling these attributes, user need to follow the two steps mentioned below:
Step 1: Access Token Generator (Optional)
If you already have the access token key and secret (generated from an external application) then you can skip this step completely otherwise this step is required. Fill in the following details to complete this step:
- Request Token URL
- Authorize URL
- Access Token URL
After filling the above attributes, click on “Authorize & Generate Access Token”. System will redirect user to authorize the consumer provided in a popup window (If popup window doesn’t open then Please check in the address bar whether popups are blocked or not. If popups are blocked then allow access to complete authorization process.). After successful authorization, close the popup window and click on “Refresh” button in the previous window, to fill the access token key/secret in step 2 automatically.
Step 2: If already having the access token or generated from Step 1
If you have generated the access token key/secret pair from any external application, then just fill the details and save the authorization. And if you have completed the step 1, then click on refresh to fill these details automatically by the system.
In vREST, an inbuilt REST API testing tool is provided with the help of Chrome Extension (vREST Chrome Extension). With this Test Runner, user can make any HTTP requests for a web application whether it is deployed locally or over the intranet/internet. To run the test cases, follow the steps below:
- First select the test cases, which you want to execute otherwise the filtered list of test cases will be executed.
- Then click on “Run” button in “Test Cases” tab’s toolbar to start the test runner.
- All the test cases will be executed in sequence. A popup window will appear which will show the results of the executed test cases, their status indicator and current test run progress.
- A simple and intuitive tool to quickly test REST APIs.
- Deliver zero defect web applications with very less effort in REST API testing.
- No skilled resources required to validate your web application.
- Quickly generate documentation for your API specifications.
- Ease of maintenance over a span of releases.
- Automated REST API Testing.
- De-couple your frontend development with backend development
- Example Of Simple REST Client Using CXF WebClient API
- What is Cross-site request forgery or CSRF/XSRF ?
- Knowing the SparkJava Framework
- Accelerate your API integrations in hospitality industry
- How to reach your potential guests using optimized long tail keywords
- Advantages of working with OTA Channels
- 5 trends to know before strategizing your mobile based marketing
- Pricing terms everyone should know in vacation rental industry
- Increase your Revenue with GDS Integration
- Managing multiple OTAs with Channel Manager