Intercepting http/https requests within tests and routing to imposter

234 views
Skip to first unread message

stephen...@gmail.com

unread,
May 3, 2018, 5:13:43 PM5/3/18
to mountebank-discuss
Apologies if this is a dumb question... I'm new to using mock services in test automation.

If my test makes a call to an internal service that makes a subsequent call to a third-party service, is there any way to intercept the second call to the 3rd party service and route it to a mountebank imposter listening on one of my ports?

For example:
- my test calls an internal service, A, via: GET https://mystuff.com/dogs
- that service in turn calls an external service, B, via: GET https://exernalstuff.com/animals

Assuming I can't modify the behavior in my internal service, A, to point to http://somelocalport/animals, is there a way for my tests to intercept the call and direct it to my imposter?

For context, our tests are written in Python/Robot Framework. Thank you in advance for your help!

Cheers,
Stephen

stephen...@gmail.com

unread,
May 3, 2018, 5:22:54 PM5/3/18
to mountebank-discuss
Ah... I just stumbled across this statement at http://www.mbtest.org/docs/api/overview:

"mountebank expects you to configure your application under test to point to the imposter."

I'm guessing this means I'll need to set up some listener or something to intercept any calls in my test runs and route them to my imposters myself... can someone please confirm if that's correct, or if I am missing something? Thanks!

Brandon Byars

unread,
May 4, 2018, 9:45:09 AM5/4/18
to stephen...@gmail.com, mountebank-discuss
Hi there,
You can't do this directly in mountebank. I believe you'd need some sort of O/S level proxy. You might be able to fudge it by fiddling with the hosts file to reroute externalstuff.com to localhost and running the imposter on port 80.
-Brandon



--
You received this message because you are subscribed to the Google Groups "mountebank-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-discuss+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages