Multifetch feature - that allows you to access multiple datasources in one pass thus avoiding expensive round trips.
Test a Multifetch Service using postman tool
Testing service is crucial to ensure that the service (API) takes the right set of inputs and provides a valid result. A service can be tested in the following ways:
- Use Abstracta UI itself
It is simple and easy to do if the tester is able to log in with multiple user roles. But it is not the case all the time. Perform testcases using tools like postman will enable user impersonation to test it and ensure that all users get the right data based on data profiling and policies enforced.
- Create multiple datasources to test Multifetch feature in Abstracta using Postman collection.
- Use Postman Collections
Postman collections simplify the testing strategy to validate data security applied to various users.
Export services as a postman collection:
- Menu > Organizations
- A list of organizations are displayed
- Choose an organization by clicking on the checkbox
- The "Postman Collection" button is enabled on top of the organizations' list
- Click on "Postman Collection"
- Two files of type "Collection" and "Environment" will be downloaded. (Browsers like chrome shows up a popup button to "allow multiple files to download". Accept that to download)
- Follow the below steps to import:
- Open Postman Tool. If not downloaded already, download from here.
- Click on "Import" > Upload files popup appears
- Import the files downloaded from Abstracta™
- Configure values for the "Environment" file:
- Select "Environments"
- Click on the imported environment file
- Get application token
- Open Abstracta™ UI
- Menu > Applications
- Choose an application and select "Manage API Token"
- Copy Client id & Client Secret from the below dialogue.
- If an API token is not generated, generate API Token. When an API token is generated, an M2M user is generated. (Check Menu > Admin > Users)
- Copy *as another user* (>>YOUR_FORUSER_SECRET_HERE<< ) secret from above.
- Update the current value for variable client_id_x with the value copied from the API token screen.
- Update the current value for variable secret_id_x with the value copied from the API token screen.
- Update the current value for variable for_user_secret_id_x with the value copied from the Manage user dialogue screen.
- Get "For User Secret"
- The API testing expects the user secret to enforce the data policies.
- Open Abstracta™ UI
- Menu > Admin > Users
- Choose a user for which you want to impersonate (A user can give impersonate access to the application M2M user). You can do other uses as well provided you are an Administrator.
- Copy the secret code generated
- Update the current value for variable var_for_user_secret with the value copied.
- Save the changes.
- Multifetch Test the service in Postman Collection:
- Select "Collections"
- Choose the imported collection file
- Navigate to your application in the collection folder
- Each data source defined in Abstracta™ would appear as a folder
- One additional folder with the name "_auth" appear as well
- Expand folder "_auth" > Select API "Get Token" > Click on "Send" > It generates a token and saves it in a variable jwt_token.
- Create New Request and name it as your wish. Here I have named it as "MultiFetch" and use Request URL is like "https://playground.azure-api.abstracta.cloud/rest/data/multifetch" and Request body should be in an array like below and send request.
- [ { "org": "a7F7CEEA41E154DD6B6F0AB0F00EDB958", "app": "Demo Application", "db": "demo_datasource_001", "table": "container", "version": "0.0.0", "from": 1, "to": 10, "columns": "cont_sys_no,container_code", "pipes": "", "format": "application/json", "forUser": "sakalanivas@outlook.com", "forUserSecret": "{{var_foruser_secret}}" }, { "org": "a7F7CEEA41E154DD6B6F0AB0F00EDB958", "app": "Demo Application", "db": "mongo_ds", "table": "abstracta-demo:companies", "version": "0.0.0", "from": 1, "to": 10, "columns": "company_id,company_name", "pipes": "", "format": "application/json", "forUser": "sakalanivas@outlook.com", "forUserSecret": "{{var_foruser_secret}}" }]
Response is populated below. First array string of response is "demo_datasource_001" MSSQL Datasource related.
- 2nd array string of response is "mongo_ds" response. Both relational and non-relational DBs responses are incorporated in the same array of Abstracta REST API reponse.