1. Home
  2. Docs
  3. User’s Guide
  4. Templates / Response Processing Rules

Templates / Response Processing Rules

Using Response Processing Rules (RPR) is one way to detect anomalous behavior of the target under test. We can use one or more RPR to define (most often) the expected behavior of the target under test and detect irregularities during testing by analyzing the response received. If the observed behavior is not compliant with the configured rules, FuzzLabs raises that as an issue.

Response Processing Rules also helpful to extract data from the response and store it in session variables for later use. The extracted data is accessible from within Unit templates and Callbacks, which allows for the implementation of stateful test cases and testing complicated protocols.

Comparables

A Response Processing Rules operates with two Comparables. A Comparable is either pre-defined static data or dynamic data that FuzzLabs resolve 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 while testing web services.

We can define Comparables in Flow templates by selecting View > Comparables from the main menu of the Flow Designer. This is shown below.

When creating a new Comparable, we define what it should represent using multiple fields. These fields are discussed below.

Comparable Name

The Comparable Name fields should be a short but descriptive, unique name. This name will be shown when configuring Response Processing Rules.

Subject

The Subject field defines what the Comparable represents. It can be something we sent to the target or received from the target, a session  or environment variable, a static number or string, or a regular expression. 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.

Sent

The Sent subject results in the Comparable to be resolved to something we have sent or a certain attribute of the data sent. When selected, the Scope field will offer the following options:

Scope Description
Field Value When selected, a Field selector appears that allows selecting from primitives that are exposed in the session by Unit templates assigned to the Flow template. Primitives can be Exposed by setting their Expose in Session advanced property in the Unit Designer to Yes. Once a Primitive is selected, the Attribute field appears that allow to define which attribute of the Primitive the Comparable should resolve to. This could be either the raw or rendered value or length of the Primitive’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.

An example comparable before saving that represents something we are sending to the target under test can be seen below.


Received

The Received subject results in the Comparable to be resolved to something we have received from the target under test or a certain attribute of the data received. When selected, the Scope field will offer the following options:

Scope Description
Field Value When selected, a Field selector appears that allows providing a regular expression. This regular expression is used by FuzzLabs to extract data from the response of the target under test. We have to use capture groups within the regular expression so that FuzzLabs knows exactly what to extract. For example, to resolve the comparable to the entire response, we could set the Field to (.*). If we wanted to extract, for example, a session ID from an HTTP response that is returned as a Cookie, we could do use a regular expression similar to this: .*Set-Cookie: SESSIONID=([a-zA-Z0-9]*);.*.
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.

Session Variable

The Session Variable subject results in the Comparable to be resolved to the value of a Session Variable either defined in a Unit template, in the Flow template or created by an already created Response Processing Rule. The Session Variable field allows selecting the desired variable.

Environment Variable

The Environment Variable subject results in the Comparable to be resolved to the value of an environment variable defined on the system the Engine is running on.

Number

The Number subject results in the Comparable to be resolved to the integer value defined using the Value field.

String

The Number subject results in the Comparable to be resolved to the string value defined using the Value field.

Regular Expression

The Number subject results in the Comparable to be resolved to the string value defined using the Regular Expression field.

Processing Rules

Processing Rules allow defining the expected behavior of the target under test and what action to take if the observed behavior did not match what was expected. The process of setting up a response processing rule is as follows.

Setting Up Comparables

The first step of creating a Response Processing Rule is to define the two Comparables the rule will operate with. This process has been discussed under the Comparables section of this page.

Creating a Processing Rule

Once the two Comparables are defined, we can proceed to set up the processing rule by selecting View > Response Processing Rules from the main menu of the Flow Designer. In the Processing Rules window we have to click the Add button (+) to add a new rule. From this point on the process is the following.

  • Enter a short but descriptive, unique name for the rule in the Rule Name field.
  • 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.

The following screenshot shows how the interface looks after selecting the first Comparable.

As can be seen, additional fields show up after selecting the first Comparable. The rule is fairly straightforward, there is probably one thing worth discussing in a little bit more detail, which is the final field to appear, named Otherwise.

The Otherwise field can be used to tell FuzzLabs how to handle if the target under test does not work according to the expectations. The table below summarizes each option.

Rule Action Description
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 next primitive.
Next and Report Skip to the next primitive and create an issue entry in the report.
Pause Pause the job.
Pause and Report Pause the job and create an issue entry in the report.
Terminate Terminate the job.
Terminate and Report Terminate the job and create an issue entry in the report.

Enable a Processing Rule

Response Processing Rules can be assigned to Receive actions within the Flow template. It is as easy as:

  1. Drag and drop a Receive action to the Workspace area
  2. Open the Receive action by clicking on the Arrow button
  3. Click on the Add New Rule button to add a new processing rule to the action
  4. Select the Processing Rule to add using the drop down menu, then click the green Add button


Disable a Processing Rule

To removing a processing rule assigned to a Receive action is as simple as:

  1. Open the Receive action by clicking on the Arrow button
  2. Select the Processing Rule to be removed using the checkbox next to it’s name
  3. Click the trash icon

 

Was this article helpful to you? Yes No