Response Processing Rules
Response Processing Rules (RPR) are multi-purpose and allow the implementation of stateful test cases and anomaly detection mechanisms.
Response Processing Rules can observe and extract data from the response and store it in Session Variables for later use. The extracted data is accessible from within Message Templates, Condition Group Rules and Callbacks, which allows the implementation of stateful test cases and testing of complex protocols.
Using RPRs, we can also detect the abnormal behaviour of the target under test. We can use one or more RPRs to define (most often) the expected behaviour of the target under test and detect irregularities during testing by analysing the response received. If the observed behaviour is not compliant with the configured rules, GUARDARA raises it as an issue.
A Response Processing Rule operates with two Comparables. A Comparable can represent a pre-defined static value or dynamic data that GUARDARA resolves during test run time. A Comparable can be many things, such as session or environment variables, strings, numbers, regular expressions or data sent or received.
For example, a dynamically resolved Comparable (A) could be the entire response or just part of the response received from the target under test. It could, for example, represent an HTTP response code. A pre-defined, static Comparable (B) could represent the number 500. Using these two Comparables, we could set up a Response Processing Rule to compare Comparable A with Comparable B to detect 500 Internal Errors when testing web services.
We can define Comparables using the Flow Template Designer by selecting View > Comparables from the editor menu.
We define what a Comparable represents using a set of fields. These fields are discussed below.
The Comparable Name field should be a short but descriptive, unique name. This name will be shown when configuring Response Processing Rules.
The Subject field defines what the Comparable represents. It can be a variety of things we will discuss in a second. The options provided by the Scope field depend on the value of the Subject field. Please note the Scope field is not visible until a Subject is selected.
The individual Subjects and related configuration options are discussed below.
The Sent subject results in the Comparable to resolve to something we have sent or a particular attribute of the data sent. When selected, the Scope field will offer the following options:
|Field Value||When selected, a Field selector appears that allows selecting from fields exposed in the session by Message Templates within the test flow. Fields can be exposed in the session by setting their Expose in Session advanced property in the Message Template Designer to Yes. Once a Field is selected, the Attribute field appears. It allows defining which attribute of the Field the Comparable should resolve to. This could be the raw or rendered value or length of the Field’s value.|
|Request||When selected, an Attribute selector appears that allows selecting Length, which represents the entire length of the data (test case) sent to the target, or Timestamp, which is the timestamp of when the test case was transmitted to the target.|
The Received subject results in the Comparable to resolve to something we have received from the test target or a particular attribute of the data received. When selected, the Scope field will offer the following options:
|Field Value||When selected, a Field selector appears that allows providing a regular expression. GUARDARA uses this regular expression to extract data from the target’s response. We have to use capture groups within the regular expression so that GUARDARA knows precisely what to extract. For example, we could set the Field to |
|Request||When selected, an Attribute selector appears that allows selecting Length, which represents the entire length of the data received, or Timestamp, which is the timestamp of when the data was received.|
The Session Variable subject results in the Comparable to resolve to the value of a Session Variable defined in the Variable Collection.
The Environment Variable subject results in the Comparable to resolve to the value of an environment variable defined on the system the Engine is running on.
The Number subject results in the Comparable to resolve to the integer value defined using the Value field.
The Number subject results in the Comparable to resolve to the string value defined using the Value field.
The Regular Expression subject results in the Comparable to resolve to the string value defined using the Regular Expression field.
Creating Processing Rules
You can create Processing Rules using the Flow Template Designer by selecting View > Response Processing Rules from the editor menu. It is expected for at least two Comparables to be available to set up a Response Processing Rule.
To add a new rule, we have to click the Add button (
+) in the Processing Rules window. From this point on, the process is the following.
- Enter a short but descriptive, unique name for the rule in the Rule Name field.
- (Optional) Add a description that tells the purpose of the processing rule.
- Select the first Comparable using the Comparable field that appears once the Rule Name is set.
- Configure the Expected and To fields according to your specific requirements.
- Select the second Comparable using the Comparable field.
- Using the Otherwise field, select what should happen if the condition defined by the rule is not met.
- Click the Save button to save the rule.
The Otherwise field options are summarised in the table below.
|Continue||Continue as if nothing happened.|
|Report||Create an issue entry in the report.|
|Skip||Skip to the next iteration.|
|Skip and Report||Skip to the next iteration and create an issue entry in the report.|
|Next||Skip to the following field.|
|Next and Report||Skip to the following field and create an issue entry in the report.|
|Pause||Pause the test.|
|Pause and Report||Pause the test and create an issue entry in the report.|
|Terminate||Terminate the test.|
|Terminate and Report||Terminate the test and create an issue entry in the report.|
Enabling Processing Rules
Response Processing Rules can be assigned to Receive actions within the Test Flow Template. It is as easy as:
- Open the Receive action by clicking on the Action Details Button
- Click on the Add New Rule button to add a new processing rule to the Action
- Select the Processing Rule to add using the drop-down menu, then click the Add button
Disabling Processing Rules
To remove a processing rule assigned to a Receive action:
- Open the Receive action by clicking on the Action Details Button
- Select the Processing Rule to be removed using the checkbox next to its name
- Click the Trash icon to remove the rule