Using Sauce Connect Proxy Tunnels for API Tests
Sauce Labs API Testing fully integrates with Sauce Connect Proxy tunnels, enabling you to test and monitor both internal and public APIs. If your APIs are behind a firewall on your private network, follow the steps below to launch a secure trusted connection between your network and Sauce Labs.
We do not support Allow-listing static IPs. We strongly suggest running your tests using Sauce Connect Proxy tunnel. For assistance, contact your CSM/SE or our Support Team.
What You'll Need
- A Sauce Labs account (Log in or sign up for a free trial license).
- Your Sauce Labs Username and Access Key.
- Have the Sauce Connect Proxy client installed on your local machine. If you're new to the feature, check out the Sauce Connect Proxy Quickstart.
- An existing API Testing Project and Test. For details on how to create them, see API Testing Quickstart.
Start API-Specific Tunnel
- First, you'll need to create a YAML configuration file. From a text editor or IDE, create a file called api-config.yaml, then copy and paste it into the template below.
- US Data Center
- EU Data Center
- In the api-config.yaml file:
- Leave the
- Set the
api-keyvalues as your own Sauce username and access key, respectively
- Set the
tunnel-identifiervalue to whatever you'd like to name your tunnel
- Leave the
- Save the api-config.yaml file to the Sauce Connect Proxy root folder on your local machine.
- Open your terminal and navigate to the Sauce Connect Proxy folder. If your folder is in your home directory, you'd run:
- Start your tunnel by issuing:
bin/sc -c api-config.yaml
bin\sc.exe -c api-config.yaml
If the tunnel was launched successfully, you'll see a CLI response indicating that you can start your tests.
Configure Test to Use Tunnel
Find the test you'd like to run. Tests can be located and run under the Tests tab, Compose tab, HTTP Client tab, and Schedule tabs.
Under the Run Configuration section, click on the Sauce Connect Proxy dropdown menu (defaults to No Tunnel), then click the name of your tunnel.
The Tests and Compose tabs have a session stickiness feature (also known as session persistence) that binds your tunnel session to our API testing server. When you select a tunnel from the Sauce Connect Proxy dropdown, that tunnel will stay as the default selection, even if you close your browser.
This feature does not apply to the HTTP Client or Schedule tabs, where the tunnel dropdown will always default to No Tunnel.
If you shut down a tunnel that's currently selected in a Sauce Connect dropdown anywhere in the platform (Tests, Compose, HTTP Client, or Schedule tab), the test would fail and you'd see the below error message. This is something to be mindful of when selecting a tunnel in the Schedule tab to run in the future.
Run Test through Tunnel
- Once you've selected your tunnel from the dropdown, run your test.