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
---
rest-url: 'https://api.us-west-4-i3er.saucelabs.com/rest/v1'
user: '$SAUCE_USERNAME'
api-key: '$SAUCE_ACCESS_KEY'
vm-version: 'v2alpha'
tunnel-identifier: '$SAUCE_USERNAME_TUNNEL'
---
rest-url: 'https://api.eu-west-3-lnbf.saucelabs.com/rest/v1'
user: '$SAUCE_USERNAME'
api-key: '$SAUCE_ACCESS_KEY'
vm-version: 'v2alpha'
tunnel-identifier: '$SAUCE_USERNAME_TUNNEL'
- In the api-config.yaml file:
- Leave the
rest-url
andvm-version
values as-is - Set the
user
andapi-key
values as your own Sauce username and access key, respectively - Set the
tunnel-identifier
value 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:
- Linux
- Windows
- Mac
cd sc-4.9.2-linux
cd C:\sc-4.9.2-win32
cd sc-4.9.1-osx
- Start your tunnel by issuing:
- Mac/Linux
- Windows
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.
Learn more
Run Test through Tunnel
- Once you've selected your tunnel from the dropdown, run your test.