views:

35

answers:

0

I have some Cucumber integration tests for a gem (not a Rails app). Some of them connect to a third party which operates a web service running on port 12345 which I'll call Banana. The service whitelists certain IPs that it allows connections from, one of which is Coconut. My box, Domino, is allowed to access Coconut via ssh.

[restricted service] <====> [trusted box] <====> [my box]
    Banana:12345               Coconut            Domino

I run an SSH tunnel from Domino to Coconut which proxies a connection to Banana:

ssh -f -N -L 12345:service.banana.com:12345 [email protected]

Now I can make connections to service.banana.com via localhost. But that's not very convenient since I'd have to change my tests to call localhost, or add an entry to my hosts file, or something else like that requires a change external to my gem. That seems undesirable; I'd like to have my tests run in such a way that they don't need to be changed when I run them from a different environment.

Assuming I have a proper ssh tunnel established, what's the most Ruby-ish way to get my tests to connect to the remote server?