Formatting a message with MIME, S/MIME, DIME, and multipart content

You can format a message by applying a MIME or DIME schema. HCL OneTest API supports the S/MIME standard for secure encryption, decryption, and signing of MIME data.

The MIME and DIME schemas

To apply a MIME or DIME schema:
  1. Right-click the Text node of the message and click Schema.
  2. In the Schema Selector window, click Web > MIME or Web > DIME as the Schema Type.
  3. Select a root from the displayed options. A sample message is displayed with the schema applied.
    The screen capture shows a Multipart MIME root selected.
  4. Click OK to return to the message.
  5. For multipart MIME nodes, you can add parts. Right-click the content (multipart/*) node and click Add Child > Choice and select one of the following part types:
    • Binary
    • Multipart
    • Text
  6. For DIME messages, you can add records to the (Message) node. Right-click the node and click Add Child > Choice and select one of the following record types:
    • Binary
    • Text

Multiparts

Text content such as JSON can be pasted into the Multipart node and HCL OneTest API recognizes it and expands it as a tree.

To add content into a multipart node:

Binary Data

  1. Add Binary content such as file data by editing the ByteArray node. Right-click the node and select Open Field Value.
    The Open Field Value is available in the pop-up menu.
  2. Select the file to load in.

Form-Data

Form-Data messages are commonly used to send files over HTTP, and require additional header configuration.

To add the Form-Data file:

  1. Set the MIME > Multipart > header > Content-Type node to multipart/form-data.
  2. Add the message text part as previously described. Configure the headers to identify the content type and a name.
  3. Set the MIME > Multipart > content > part > header > Content-Type node to application/pdf to describe the data.
  4. Right-click the MIME > Multipart > content > part > header node and select Add Child > (String).
  5. In the field editor, provide a name for the Content-Disposition node by setting the value to
    
    form-data; name="file"; filename="Readme.pdf"
    
  6. Edit the MIME > Multipart > content > part > content node. Change the type to ByteArray and use the Open Field Value menu option to pull in the file data.

To add Form-Data inline:

  1. Set the MIME > Multipart > header > Content-Type node to multipart/form-data.
  2. Add message text as previously described. Configure the headers to identify the content type and a name.
  3. Right-click the MIME > Multipart > content > part > header node and select Add Child > (String).
  4. In the field editor, provide a name for the Content-Disposition node by setting the value to
    
    form-data; name="body"
    
  5. Edit the MIME > Multipart > content > part > content node to include the inline data.
    An example message that contains two items of form data that is named body and file is shown:
    A mime multipart message example.

S/MIME properties

To add security to a MIME message:
  1. In the Test Factory perspective message tree, double-click the message to open it in the message editor.
  2. Right-click the text (String) {MIME} or data(ByteArray) {MIME} node and then click Properties.
    The Properties option is available in the pop-up menu.
  3. On the S/MIME security settings dialog, you have four options:
    • Encrypt
    • Decrypt
    • Sign
    • Unsign
    The S/MIME dialog with Encrypt and Sign options selected.

    The Encrypt and Sign options can be selected together or separately.

    The Decrypt and Unsign options are inbound options and can also be selected together or separately.

    The Encrypt, Decrypt, Sign options require the name of a Keystore and a Certificate Alias from within that keystore. Outbound options (Encrypt and Sign) require an Algorithm. Decrypt and Sign options require a Password.

    Note: If you apply the MIME schema to a message, you can also apply the S/MIME properties at the same time, through the Schema Selector window.
    Formatter properties are located below the Schema Type pane.

Content Transfer Encoding

The Content-Transfer-Encoding header is a MIME header that controls how the content must be encoded for transmission. HCL OneTest API chooses an encoding based on the content and the type of root node that the MIME message is built on. If the MIME message is built on a Text node, then it is assumed that the content is required to be 7-bit data and is encoded by using 7 bit, base64, or quoted-printable encoding. If the MIME message is built on a ByteArray node, then binary encoding is chosen, which is suitable for protocols without a 7-bit restriction such as HTTP and AS2.