0

I am using mountebank for service virtualisation in my performance test. So, first time when I hit the mountebank service url with request parameter e.g. flightNo=513, it goes to target application using proxyOnce mode and saves the response in imposter at specific port but second time when I change the flightNo so I don't want to hit the target application but I want to manipulate the saved response based on the given flightNo. How can I do that in mountebank ? Please help.

Shivam
  • 35
  • 7

1 Answers1

1

You'll want to use the addDecorateBehavior, which allows you to access the incoming request (request.query.flightNo, in your case) to manipulate the saved response on the way out.

bbyars
  • 406
  • 3
  • 3
  • Thanks @bbyars. Now I am trying to inject .js file in [addDecorateBehaviour] where I have written a logic to edit the response but I am getting an exception.I have enabled --allowInjection flag as well at the time of start up and used the syntax as: "addDecorateBehavior": "<%- stringify(filename, 'proxy-decorate.js') %>" – Shivam Sep 16 '20 at 07:05
  • Getting an exception :: "TypeError: Converting circular structure to JSON\n --> starting at object with constructor 'DerivedLogger'\n | property '_readableState' -> object with constructor 'ReadableState'\n | property 'pipes' -> object with constructor 'Array'\n | index 0 -> object with constructor 'Console'\n --- property 'parent' closes the circle\n at JSON.stringify () .............. when tried from Postman – Shivam Sep 16 '20 at 07:17
  • Yes, the --allowInject flag is required as an acknowledgment that you're explicitly allowed user-provided JavaScript execution, as left unchecked, that can open you up to security concerns. Read this page for more details: http://www.mbtest.org/docs/security – bbyars Sep 17 '20 at 11:40
  • The TypeError means that you're calling JSON.stringify something that cannot be converted to JSON due to circular references. – bbyars Sep 17 '20 at 11:41