Skip to main content

Using Sauce Connect Proxy Tunnels for API Tests

If your APIs exist behind a firewall on your private network, you'll need to use our Sauce Connect Proxy solution to open up a secure trusted connection between your network and Sauce Labs.

What You'll Need#

Start an API-Specific Tunnel#

  1. First, you'll need to create a .yaml configuration file on your local machine.
    • Copy and paste the sample template below into a text editor and save it as a .yaml file. In this example, we'll name it api-config.yaml.
      Sample Template: API Config YAML File
      ---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: "YOUR-TUNNEL-NAME"
    • Substitute the SAUCE_USERNAME and SAUCE_ACCESS_KEY placeholders with your own credentials.
    • Although not required, we strongly recommend naming your Sauce Connect Proxy tunnel using tunnel-identifier to define your tunnel name.
  2. Save your .yaml file to the same folder as your Sauce Connect Proxy client.
    API Testing Sauce Connect folder structure
  3. Open your CLI terminal and navigate to the folder where you have Sauce Connect Proxy saved. If it's in the home directory, you'd run:
    cd sc-4.7.1-osx
  4. Start your tunnel by issuing:
    bin/sc -c api-config.yaml
  5. If the tunnel was launched successfully, you'll see a CLI response like this, indicating that you can start your tests.

Run an API Test with a Tunnel#

  1. Now you're set up to run API tests through a Sauce Connect Proxy tunnel. To create a test, follow the directions under Quickstart to:

    • Create a Test (use your local API endpoint here)
    • Send a Request
    • Generate Test
  2. Tunnels can be selected in any of the places where tests can be run: from the Tests tab, HTTP Client tab, Schedule tab, and Compose tab.

    Under Run Configuration, click the Sauce Connect Proxy tunnels dropdown menu (which defaults to No Tunnel), then click the name of your tunnel.
    API Testing Sauce Connect Nav

  3. Run your test.

More Information#