Scenario Parameters

Introduction

Scenario parameters allow you to pass parameters into your scenario from a test configuration. This enables sharing a single scenario definition across many different test configurations. Scenario parameters are often used to set the target URL of a test, credentials, number of virtual users, timeouts, etc.

Scenarios can declare parameter names in the Declared Params section. When you create a test configuration and choose that scenario, any declared parameters will automatically appear and prompt you for a value. The test configuration can also add additional parameters as required.

During test execution, scenario parameter values can be accessed as environment variables, system properties, or a params object depending on the scenario type chosen (i.e. JMeter, Gatling, Locust, Node.js script, Selenium, PhantomJS/SlimerJS, etc).

Scenario parameter values can be encrypted.

Declaring Parameters

Within any scenario there is a Declared Params widget. Declare any parameters here including whether or not they should be required or not. Any parameters declared here will appear when creating a test configuration and this scenario is chosen.

Declaring Parameters

Setting Parameters

Each test configuration that uses a scenario will be able to set different values for declared parameters as well as adding additional parameters. This is done in the Scenario Params section of the test configuration setup screen.

Setting Parameters

Accessing Parameters

In your scenario you can access the parameter value using a variety of approaches:

  1. As environment variable PARAM_[name] where name is the name of the parameter in upper case with any spaces removed.
  2. As a system property with the same name as the parameter name. Only available for JMeter and Selenium Java scenarios.
  3. With the params object for Node.js, PhantomJS, and SlimerJS scripts. For example parameter Abc is accessible with params['Abc'].

Encrypting Parameters

Scenario parameter values can be encrypted. This can be a useful way to pass sensitive information like credentials, keys, etc to your scenario.

Each test case has a unique 2048 bit public/private RSA key pair. Each parameter is encrypted using a uniquely generated 256-bit AES symmetric key and IV. The symmetric AES key is encrypted into the parameter using the RSA public key and included with the encrypted parameter contents.

Each test case's public key is available for download so that parameter values can also be encrypted locally. The private key is stored encrypted using an AWS Customer Master Key and is not accessible outside of Testable's core secured VPC.

During test execution, parameter values are decrypted just before sending to the test runners for execution over an SSL connection. The decrypted values are then available to your test like any other parameter. These decrypted values are not stored or logged anywhere by Testable.

Encrypted parameters have the format secret:[IV]:[rsa-encrypted-aes-key]:[aes-encrypted-contents].

You can encrypt any parameter value easily via our website. Next to any parameter there is an Encrypt button that will encrypt the value using that test case's public key.

Encrypting a Parameter

Download Public Key

There are 2 ways to download your public key.

  1. https://api.testable.io/[testCaseId]/key. The testCaseId is the number after https://a.testable.io in the URL when viewing a test case on our website.

  2. Click on any test case and in the upper right click the certificate icon.

Public Key Icon

Encrypt Value Locally

Use openssl to encrypt a value locally once you've downloaded the test case's public key.

Step 1: Generate a 256-bit AES key and IV. The secret can be anything.

openssl enc -aes-256-cbc -k secret -P -md sha1

Output:

salt=8C9934CF0C317E5D
key=24004A522FA5F3CBDC621BFC913EF814
iv =5221081AD31F625837582D19DA1FD567

Step 2: Encrypt the key from step 1 (the text after key=) using the public key for your test case. Substitute your key for [key] and the public key file for testable-key-123.pub below.

echo "[key]" | openssl rsautl -encrypt -pubin -inkey testable-key-123.pub -out >(base64)

Output:

pAv933Q6M695jgpQY+ZQoPHlucLBrJSb8y+NUrn/WiQO2vRkn5+OsMQVOEQcuqfK88we1eRp05KDFRiwA6UtJr6R6K4GyqbHlXggpnh4of/7rhPjvx0F1RbOUixORAFrzMz09mxfliEl/OhAOHxuag/S3oIeSYv4rGtqPw+l1gUBFhRaI9WCABqFA==

Step 3: Encrypt your parameter using the key and iv from step 1.

echo "my secret param value" | openssl enc -aes-256-cbc -base64 -K [key] -iv [iv]

Output:

aZVXPUgOmsfvwB/kBa9xUMC8HIrwP3c3jZOwWb+MxEo=

Step 4: Combine together to form the secure parameter value: secure:[iv]:[encrypted-aes-key]:[encrypted-contents]. The iv is from step 1, the encrypted-aes-key is from step 2, and the encrypted-contents is from step 3. The entire value should be pasted in as the parameter value on Testable.