OPTIONS (Outbound)

Introduction

These methods in from TestSipLuaAgent Lua API are used for tests which perform the SIP UAC role for a non-INVITE transaction, sending an outbound SIP OPTIONS Request and expecting one or more responses.

OPTIONS (Outbound) API

.options_send_request [Synchronous]

The options_send_request method sends a TEST-SIP-SEND message to the TestSipApp to request that an outbound SIP OPTIONS Request is sent to the previously determined remote endpoint IP and port address.

Control will return immediately to the Lua script. There is no wait for any confirmation from the TestSipApp. If there is a problem sending then the TestSipAgent will subsequently send us a TEST-SIP-FAIL message which will be detected if and when any subsequent SIP messaging is performed by the test script.

The method will:

The options_send_request method takes the following arguments:

Argument Type Description
context Object [Required] The non-INVITE context for this transaction, returned by non_invite_context.
extra_headers Array of Object An optional list of extra headers.
Each object in the array must have a name and a value.
A header name may appear more than once in this array to support repeated headers in the Request.
.name String The name of the extra header to add to the OPTIONS Request.
.value String The value of the extra header to add to the OPTIONS Request.

The options_send_request method returns nil.

Example of sending SIP OPTIONS Request:

-- Static for our call.
local endpoints = tsuo.default_endpoints ({ local_rtp_port = 3668 })
local calling_party = '665566'
local called_party  = '665566'

-- Get a SIP outcall context from our helper library.
local context = tsuo.non_invite_context (endpoints, calling_party, called_party, {})

-- Construct and Send INVITE Request.
tsuo.options_send_request (context)

-- Expect OPTIONS response (200 OK).
tsuo.options_expect_response (context, 200, "OK")

.options_expect_response [Asynchronous]

The options_expect_response method will request the TestSipLuaAgent to wait until an inbound SIP OPTIONS Response message is received, in the context of a previously established transaction which belongs to this Lua script instance.

The agent will wait up until the expect_secs configured value for a SIP message to arrive. An error will be raised if no message is received in this time. An error will be raised if the received message is not a SIP Reponse, or if the received SIP message is not a CANCEL Response message.

The options_expect_response method takes the following arguments:

Argument Type Description
context Object [Required] The non-INVITE context for this transaction as used for options_send_request.
code Integer [Required] The expected integer code value, e.g. 200.
message String [Required] The expected string message value, e.g. "OK".
extra_headers Array of Object An optional list of extra headers to be tested in the OPTIONS Response.
Each object in the array must have a name and a value.
If a header is expected to appear more than once, then value may be an Array of String.
.name String The name of the extra header to test for in the OPTIONS Response.
.value UNDEF or String or Array of String The value of the header to test from the OPTIONS Response.
The value UNDEF means "test that this header is not present".
A String value means "test" that the first header instance has this value.
An Array of String value means "test that the header exists N times with these values".

This method returns the decoded SIP OPTIONS Response message, as returned by the “n2.http” utility module.

Example: See the above example for options_send_request.