Rules for ISO Interceptor
Rules in the ISO Interceptor provide a robust mechanism for dynamically modifying API responses based on intercepted request data. By applying rules, users can tailor responses to specific conditions, enhancing the accuracy and flexibility of API testing scenarios.
Example :
We will utilize the Transaction request example from the previous section to apply rules and validate the response.
- Interceptor uses rules in two sections, one is
Client Request Rules
& the other isClient Response Rules
.
Client Request Rules : These rules modify the request body according to specified scripts before forwarding the updated body to the client URL to match the client's url request body before execution.
Client Response Rules : These rules intercept the incoming response body from the client, apply specified scripts, and then provide the user with the updated response.
- Now we have written Rules script to update the response
Transaction
request conditionally.
// Interceptor Client Request Rule
req.set('8','00002000');
// Interceptor Client Response Rule
res.set('4', '000000012000');
- Now navigate to API module and execute this Interceptor request in PruTAN's API module using Interceptor's endpoint & port following the steps provided in previous section and User will get the conditionally updated response.
//Expected Response Body after rule implementation
<isomsg direction="incoming">
<!-- org.jpos.iso.packager.GenericPackager -->
<field id="0" value="0210"/>
<field id="3" value="310000"/>
<field id="4" value="000000012000"/>
<field id="11" value="123456"/>
<field id="13" value="1229"/>
<field id="39" value="000"/>
<field id="41" value="TERM1234"/>
<field id="42" value="MERCH1234567890"/>
<field id="49" value="356"/>
</isomsg>
- To better analyze responses and follow the execution flow of Interceptor requests, please refer to : Analytics submenu.
- For deeper insights into the practical applications of Transformer Rules, navigate to: : Rules .
By integrating Interceptor rules into your workflow, you can achieve more streamlined development cycles, better API validation, and a smoother testing experience.