Closed adamp524 closed 6 years ago
@adamp524 This isn't currently possible, as event handling works in fire and forget mode, so to speak. Could you elaborate a bit on your use case?
We're running Newman tests on a network with a corporate proxy. I'm trying to parse a proxy pac file and set the http_proxy and https_proxy environment variables before the main request is issued. The proxy destination changes depending on the request URL so we can't just hardcode the proxy environment variables at the beginning of the script.
If Newman had support for setting a proxy Pac URL that would be a really useful improvement. The npm pac-resolver library or similar is something you could use to easily read and parse.
@adamp524 Thanks for the context. Based on the snippet you'd shared above, you could shift the logic in the start event handler to before the run even starts. This ensures that the run only starts after your preparatory logic has completed its work. Based on the file parsing structure, you can update the values of the proxy environment variables in the beforeRequest
/beforeItem
event handlers.
@kunagpal Our tests dynamically load in environment URLs, credentials etc. in the 'Pre-request' portion of a postman script. We don't know the full URL that the main request is going to be hitting until after the pre-request stage has been run.
You mention using the 'start' event handler however is there still not a risk of the script proceeding to further stages as the events are fire and forget? In my case I'd want to wait until the 'prerequest' event before I set the proxy. However I wouldn't be able to guarantee that the proxy had been determined before my script's main request get executed.
Yep. There’s no way to block it. Even I wanted to block some events for a newman debugging reporter I was planning. On top of it, blocking events is first an anti pattern and secondly it would go against the architecture of newman’s internals. So, on that ground we have nowhere to go - as far as I can think of.
For the proxy PAC file thing, we have support for that in our app. Wondering what effort would it take to bring the same to Newman. I’m closing this ticket and creating a new feature request. 😊
Hi,
I'm running postman collections using the newman node runner. I would like to intercept calls to various events such as 'start', 'beforeRequest', 'request' but have them block before continuing to the next stage. As far as I can tell, the handlers that are currently exposed are just triggers on events and can't block.
Does anyone know if it's possible to intercept events and block in this way?