What is Sauce Connect (Proxy)?
Sauce Connect (Or Sauce Connect Proxy, as it’s sometimes called) is a, well, proxy.
OK but what’s a Proxy?
Proxy means a lot of things, but in Networking terms, it’s a name for a computer or piece of software that connects one network to another.
For instance, you might have a proxy server that connects your work computer to the Internet. Depending on how it’s set up, you probably don’t even know it’s there.
Why do I need a Proxy?
Most organisations keep their internal systems isolated from the internet. Here’s a (highly simplified) example of a common network setup:
The grey box is the corporate network. It’s designed to allow traffic within it, but not externally. The test runner is able to contact the System Under Test directly over the corporate network (Represented by the arrow), but it can’t contact the Internet. To do so, it needs to first send its request via the Corporate Proxy:
These network connections are outward only. Almost every corporate network is designed to let things inside the network make requests to the Internet, but not the other way around. This is important enough that I’m going to put it in a box:
Corporate Networks are designed to prevent people accessing them from the Internet
Why so important? Because it means that anyone outside the corporate network can’t access the System Under Test. In fact, unless your network team deliberately makes it available outside of your network, as far as the internet is concerned, it doesn’t even exist.
Why you need Sauce Connect (Proxy), Specifically
So this is where our problem occurs. If you’re running tests using local browsers, they’re easily able to navigate to the System Under Test. When you’re running tests using Sauce Labs, they’re not.
Because it’s using your Corporate Proxy, your test runner can reach out to the internet and send commands to Sauce Labs…. But the Sauce Labs browser can’t reach “back” through that connection. Instead, it’s going to try to set up its own connection, but as far as it knows, your app doesn’t exist:
This is what Sauce Connect Proxy is for. It opens a direct, secure connection, joining the Sauce Labs network to your Corporate network. Now, the Sauce Labs browser can see and talk to the System Under Test.
But hold up; How does it get through your network’s firewall? That’s the clever part; It can make connections because you run Sauce Connect inside your network. Things in your network are allowed to contact the Internet if they do so in the right manner (This is why you might also have to give Sauce Connect the details of your corporate proxy, so it knows how to get to the internet).
When you start Sauce Connect, it reaches out of your network, sets up a secure connection and sits with that connection open, waiting for requests. When the Sauce Labs browser needs to contact your System Under Test, it sends that request down the already open connection (Red lines) to the Sauce Connect client you started. Since that client is inside your network, it’s able to contact the System Under Test:
As soon as you shut down Sauce Connect, that open connection goes away, and Sauce Labs is no longer able to access the System Under Test, or any other part of your network.
And that’s it!
That’s what Sauce Connect is for. By running it inside your network, it’s able to take a system that’s invisible from the internet and allow our browsers to reach it. It gives you all the control over when your system is available to Sauce Labs, and keeps your test commands and traffic secure.