String Interpolation Syntax
The string interpolation syntax is designed for configuring authentication objects. It controls data coordinating between the consequent requests and responses.
The syntax allows you to create a template (interpolation string) for the value to be extracted from the specified location. You can only create the template based on the previous authenticated requests and responses.
The interpolation string uses the double curly braces {{
and }}
as delimiters and consists of two general parts:
- Location of the data to be transformed.
- Functions separated by the
|
operator. The functions support chaining with the same operator.
Format: {{ location | function 1 | function 2 }}
The parts comprise the following components:
Part | Components |
---|---|
Location |
{{ <stage_name>.<source>.<location> | <function> }}
Example: |
Function |
{{ <location> | <pipe>: <parameter> }}
Example: Example with chained functions: Note: The functions are applied in the relevant order. It means that in the example above, first |
Supported Pipes
get
Returns the value associated with the XPath, or undefined if there is none.
Parameters:
xpath
- xpath string
Format: {{ <location> | get: <xpath> }}
Example: {{ step1.response.headers | get: '/Set-Cookie' }}
match
Retrieves the result of matching a string against a regular expression.
Parameters:
regex
- regular expressiongroup
- number of the capture group (optional, default1
)
Format: {{ <location> | match: < regex> : <group> }}
Example: {{ step1.response.body | match: /sid=(.+)/ : 1 }}
encode
Encodes the value to some format.
Parameters:
- format -
base64
,url
ornone
(optional, defaultnone
)
Format: {{ <location> | encode: <format> }}
Example: {{ step1.response.body | encode: 'base64' }}
Generating Mock Data
If you need to generate random data to use it during configuration of an authentication object, you can apply one of the following Faker.js data generators:
-
uuid
Example:{{ $faker.datatype.number }}
-
number
Example:{{ <$faker>.datatype.uuid }}
Updated 9 months ago