HOW vREST API CAN BE USED FOR REST TESTING

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.
  • Authorization.
  • Test Runner.

Test Cases

Test Case Creation
: A test case can be created by the following ways

Manual Insertion

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.

add new test case in vREST

vREST testcase

API Specifications

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.

vREST API testing

Mock Server

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.

mockserver

Response Validation

Response validation is done with the help of response validators. A response validator is simply a JavaScript function. A test case passes if the assigned response validator returns true otherwise it fails. Any variables used in the expected results are first replaced and new variables are extracted from the actual results of the test case to be used in subsequent requests, if response type is JSON and if extraction rules are defined during test case definition in “Variable Extractor” tab. A response validator function will get the following input parameters:

Testcase

First parameter is test case, having all the details of a test case which has been provided in the test cases tab.

Response

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.

Methods

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:

Default Validator

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.

rest API testing tool

Authorization

This functionality serves the purpose of making authenticated/authorized HTTP requests. User can setup any number of authorizations in vREST.

Basic Authorization

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.

Test REST API

OAuth 1.0

In OAuth 1.0 authorization, system asks for the following attributes:

  • Signature Method (Supports HMAC-SHA1, PLAINTEXT)
  • Consumer Key
  • Consumer Secret
  • Scope

API test online

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.

 

Test Runner

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.

automated rest API testing

Advantages

  • 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

Visit | Vafion | Facebook | Linkedin

Similar Posts:

Related Posts

Stay UpdatedSubscribe and Get the latest updates from Vafion