[Asterisk-code-review] Add tests to verify pidf+xml & xpidf+xml NOTIFY bodies. (testsuite[master])
John Bigelow
asteriskteam at digium.com
Fri Jul 31 11:35:33 CDT 2015
John Bigelow has uploaded a new change for review.
https://gerrit.asterisk.org/1023
Change subject: Add tests to verify pidf+xml & xpidf+xml NOTIFY bodies.
......................................................................
Add tests to verify pidf+xml & xpidf+xml NOTIFY bodies.
This adds tests to verify pidf+xml & xpidf+xml NOTIFY bodies in PJSIP. The
tests set different custom states and verifies that the NOTIFY bodies match
what is expected.
AFS-129
Change-Id: Ib852d1d42ea391fe4e7d1abf0eb7ea6eabb62cba
---
A tests/channels/pjsip/subscriptions/presence/pidf_xml/configs/ast1/extensions.conf
A tests/channels/pjsip/subscriptions/presence/pidf_xml/configs/ast1/pjsip.conf
A tests/channels/pjsip/subscriptions/presence/pidf_xml/sipp/subscribe.xml
A tests/channels/pjsip/subscriptions/presence/pidf_xml/test-config.yaml
M tests/channels/pjsip/subscriptions/presence/tests.yaml
A tests/channels/pjsip/subscriptions/presence/xpidf_xml/configs/ast1/extensions.conf
A tests/channels/pjsip/subscriptions/presence/xpidf_xml/configs/ast1/pjsip.conf
A tests/channels/pjsip/subscriptions/presence/xpidf_xml/sipp/subscribe.xml
A tests/channels/pjsip/subscriptions/presence/xpidf_xml/test-config.yaml
9 files changed, 837 insertions(+), 0 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/23/1023/2
diff --git a/tests/channels/pjsip/subscriptions/presence/pidf_xml/configs/ast1/extensions.conf b/tests/channels/pjsip/subscriptions/presence/pidf_xml/configs/ast1/extensions.conf
new file mode 100644
index 0000000..b8dcca3
--- /dev/null
+++ b/tests/channels/pjsip/subscriptions/presence/pidf_xml/configs/ast1/extensions.conf
@@ -0,0 +1,2 @@
+[default]
+exten => bob,hint,Custom:bob
diff --git a/tests/channels/pjsip/subscriptions/presence/pidf_xml/configs/ast1/pjsip.conf b/tests/channels/pjsip/subscriptions/presence/pidf_xml/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..2e71a90
--- /dev/null
+++ b/tests/channels/pjsip/subscriptions/presence/pidf_xml/configs/ast1/pjsip.conf
@@ -0,0 +1,11 @@
+[global]
+type=global
+debug=no
+
+[local-transport]
+type=transport
+bind = 127.0.0.1
+
+[alice]
+type=endpoint
+context=default
diff --git a/tests/channels/pjsip/subscriptions/presence/pidf_xml/sipp/subscribe.xml b/tests/channels/pjsip/subscriptions/presence/pidf_xml/sipp/subscribe.xml
new file mode 100644
index 0000000..d5e0cc8
--- /dev/null
+++ b/tests/channels/pjsip/subscriptions/presence/pidf_xml/sipp/subscribe.xml
@@ -0,0 +1,275 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Subscribe">
+ <send retrans="500">
+ <![CDATA[
+ SUBSCRIBE sip:bob@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: "alice" <sip:alice@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+ To: <sip:bob@[remote_ip]:[remote_port]>
+ Call-ID: [call_id]
+ CSeq: 1 SUBSCRIBE
+ Contact: "alice" <sip:alice@[local_ip]:[local_port]>
+ Expires: 600
+ Max-Forwards: 70
+ Event: presence
+ Supported: replaces, 100rel, timer, norefersub
+ Accept: application/pidf+xml
+ Allow-Events: presence, message-summary, refer
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv response="200" rtd="true" />
+
+ <recv request="NOTIFY" crlf="true">
+ <action>
+ <ereg regexp="<presence entity=\"sip:bob at 127.0.0.1(:5060)?\" xmlns=\"urn:ietf:params:xml:ns:pidf\" xmlns:pp=\"urn:ietf:params:xml:ns:pidf:person\" xmlns:es=\"urn:ietf:params:xml:ns:pidf:rpid:status:rpid-status\" xmlns:ep=\"urn:ietf:params:xml:ns:pidf:rpid:rpid-person\">
+ <note>Ready</note>
+ <tuple id=\"bob\">
+ <status>
+ <basic>open</basic>
+ </status>
+ <contact priority=\"1\">"\;alice"\; <\;sip:alice at 127.0.0.1>\;</contact>
+ </tuple>
+ <pp:person>
+ <status />
+ </pp:person>
+</presence>" check_it="true" search_in="body" assign_to="body1" />
+ </action>
+ </recv>
+
+ <Reference variables="body1" />
+
+ <send>
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv request="NOTIFY" crlf="true">
+ <action>
+ <ereg regexp="<presence entity=\"sip:bob at 127.0.0.1(:5060)?\" xmlns=\"urn:ietf:params:xml:ns:pidf\" xmlns:pp=\"urn:ietf:params:xml:ns:pidf:person\" xmlns:es=\"urn:ietf:params:xml:ns:pidf:rpid:status:rpid-status\" xmlns:ep=\"urn:ietf:params:xml:ns:pidf:rpid:rpid-person\">
+ <note>Ringing</note>
+ <tuple id=\"bob\">
+ <status>
+ <basic>closed</basic>
+ </status>
+ <contact priority=\"1\">"\;alice"\; <\;sip:alice at 127.0.0.1>\;</contact>
+ </tuple>
+ <pp:person>
+ <status>
+ <ep:activities>ep:busy</ep:activities>
+ </status>
+ </pp:person>
+</presence>" check_it="true" search_in="body" assign_to="body2" />
+ </action>
+ </recv>
+
+ <Reference variables="body2" />
+
+ <send>
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv request="NOTIFY" crlf="true">
+ <action>
+ <ereg regexp="<presence entity=\"sip:bob at 127.0.0.1(:5060)?\" xmlns=\"urn:ietf:params:xml:ns:pidf\" xmlns:pp=\"urn:ietf:params:xml:ns:pidf:person\" xmlns:es=\"urn:ietf:params:xml:ns:pidf:rpid:status:rpid-status\" xmlns:ep=\"urn:ietf:params:xml:ns:pidf:rpid:rpid-person\">
+ <note>On the phone</note>
+ <tuple id=\"bob\">
+ <status>
+ <basic>closed</basic>
+ </status>
+ <contact priority=\"1\">"\;alice"\; <\;sip:alice at 127.0.0.1>\;</contact>
+ </tuple>
+ <pp:person>
+ <status>
+ <ep:activities>ep:busy</ep:activities>
+ </status>
+ </pp:person>
+</presence>" check_it="true" search_in="body" assign_to="body3" />
+ </action>
+ </recv>
+
+ <Reference variables="body3" />
+
+ <send>
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv request="NOTIFY" crlf="true">
+ <action>
+ <ereg regexp="<presence entity=\"sip:bob at 127.0.0.1(:5060)?\" xmlns=\"urn:ietf:params:xml:ns:pidf\" xmlns:pp=\"urn:ietf:params:xml:ns:pidf:person\" xmlns:es=\"urn:ietf:params:xml:ns:pidf:rpid:status:rpid-status\" xmlns:ep=\"urn:ietf:params:xml:ns:pidf:rpid:rpid-person\">
+ <note>On hold</note>
+ <tuple id=\"bob\">
+ <status>
+ <basic>closed</basic>
+ </status>
+ <contact priority=\"1\">"\;alice"\; <\;sip:alice at 127.0.0.1>\;</contact>
+ </tuple>
+ <pp:person>
+ <status>
+ <ep:activities>ep:busy</ep:activities>
+ </status>
+ </pp:person>
+</presence>" check_it="true" search_in="body" assign_to="body4" />
+ </action>
+ </recv>
+
+ <Reference variables="body4" />
+
+ <send>
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv request="NOTIFY" crlf="true">
+ <action>
+ <ereg regexp="<presence entity=\"sip:bob at 127.0.0.1(:5060)?\" xmlns=\"urn:ietf:params:xml:ns:pidf\" xmlns:pp=\"urn:ietf:params:xml:ns:pidf:person\" xmlns:es=\"urn:ietf:params:xml:ns:pidf:rpid:status:rpid-status\" xmlns:ep=\"urn:ietf:params:xml:ns:pidf:rpid:rpid-person\">
+ <note>On the phone</note>
+ <tuple id=\"bob\">
+ <status>
+ <basic>closed</basic>
+ </status>
+ <contact priority=\"1\">"\;alice"\; <\;sip:alice at 127.0.0.1>\;</contact>
+ </tuple>
+ <pp:person>
+ <status>
+ <ep:activities>ep:busy</ep:activities>
+ </status>
+ </pp:person>
+</presence>" check_it="true" search_in="body" assign_to="body5" />
+ </action>
+ </recv>
+
+ <Reference variables="body5" />
+
+ <send>
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv request="NOTIFY" crlf="true">
+ <action>
+ <ereg regexp="<presence entity=\"sip:bob at 127.0.0.1(:5060)?\" xmlns=\"urn:ietf:params:xml:ns:pidf\" xmlns:pp=\"urn:ietf:params:xml:ns:pidf:person\" xmlns:es=\"urn:ietf:params:xml:ns:pidf:rpid:status:rpid-status\" xmlns:ep=\"urn:ietf:params:xml:ns:pidf:rpid:rpid-person\">
+ <note>Unavailable</note>
+ <tuple id=\"bob\">
+ <status>
+ <basic>closed</basic>
+ </status>
+ <contact priority=\"1\">"\;alice"\; <\;sip:alice at 127.0.0.1>\;</contact>
+ </tuple>
+ <pp:person>
+ <status>
+ <ep:activities>ep:away</ep:activities>
+ </status>
+ </pp:person>
+</presence>" check_it="true" search_in="body" assign_to="body6" />
+ </action>
+ </recv>
+
+ <Reference variables="body6" />
+
+ <send>
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv request="NOTIFY" crlf="true">
+ <action>
+ <ereg regexp="<presence entity=\"sip:bob at 127.0.0.1(:5060)?\" xmlns=\"urn:ietf:params:xml:ns:pidf\" xmlns:pp=\"urn:ietf:params:xml:ns:pidf:person\" xmlns:es=\"urn:ietf:params:xml:ns:pidf:rpid:status:rpid-status\" xmlns:ep=\"urn:ietf:params:xml:ns:pidf:rpid:rpid-person\">
+ <note>Ready</note>
+ <tuple id=\"bob\">
+ <status>
+ <basic>open</basic>
+ </status>
+ <contact priority=\"1\">"\;alice"\; <\;sip:alice at 127.0.0.1>\;</contact>
+ </tuple>
+ <pp:person>
+ <status />
+ </pp:person>
+</presence>" check_it="true" search_in="body" assign_to="body7" />
+ </action>
+ </recv>
+
+ <Reference variables="body7" />
+
+ <send>
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+</scenario>
diff --git a/tests/channels/pjsip/subscriptions/presence/pidf_xml/test-config.yaml b/tests/channels/pjsip/subscriptions/presence/pidf_xml/test-config.yaml
new file mode 100644
index 0000000..5114c8f
--- /dev/null
+++ b/tests/channels/pjsip/subscriptions/presence/pidf_xml/test-config.yaml
@@ -0,0 +1,145 @@
+testinfo:
+ summary: 'Ensure NOTIFY bodies for pidf+xml subscriptions are correct.'
+ description: |
+ 'A SIPp instance subscribes to "bob" using pidf+xml. Upon the
+ first TestEvent indicating that there is an active subscription, the
+ state of "Custom:bob" is changed. Each AMI event indicating that a
+ state change occurred triggers another state change until all states
+ have been set. The SIPp scenario expects to receive a NOTIFY message
+ for each state and verifies the contents of the pidf+xml body for each.
+ If any pidf+xml body contents do not match what is expected, the test
+ fails.'
+
+properties:
+ minversion: '12.5.0'
+ dependencies:
+ - sipp :
+ version : 'v3.0'
+ - python: 'twisted'
+ - python: 'starpy'
+ - asterisk: 'res_pjsip'
+ - asterisk: 'res_pjsip_exten_state'
+ - asterisk: 'res_pjsip_pidf_body_generator'
+ tags:
+ - pjsip
+
+test-modules:
+ test-object:
+ config-section: sipp-config
+ typename: 'sipp.SIPpTestCase'
+ modules:
+ -
+ config-section: ami-config
+ typename: 'pluggable_modules.EventActionModule'
+
+sipp-config:
+ reactor-timeout: 30
+ fail-on-any: True
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': {'scenario': 'subscribe.xml', '-p': '5061'},
+ 'ordered-args': ['-timeout_error'] }
+
+ami-config:
+ -
+ ami-events:
+ id: '0'
+ conditions:
+ match:
+ Event: 'TestEvent'
+ State: 'SUBSCRIPTION_STATE_SET'
+ StateText: 'ACTIVE'
+ Endpoint: 'alice'
+ count: '>1'
+ trigger-on-count: True
+ ami-actions:
+ action:
+ action: 'SetVar'
+ variable: 'DEVICE_STATE(Custom:bob)'
+ value: 'RINGING'
+ -
+ ami-events:
+ id: '0'
+ conditions:
+ match:
+ Event: 'ExtensionStatus'
+ Exten: 'bob'
+ Hint: 'Custom:bob'
+ StatusText: 'Ringing'
+ count: '1'
+ ami-actions:
+ action:
+ action: 'SetVar'
+ variable: 'DEVICE_STATE(Custom:bob)'
+ value: 'INUSE'
+ -
+ ami-events:
+ id: '0'
+ conditions:
+ match:
+ Event: 'ExtensionStatus'
+ Exten: 'bob'
+ Hint: 'Custom:bob'
+ StatusText: 'InUse'
+ count: '1'
+ ami-actions:
+ action:
+ action: 'SetVar'
+ variable: 'DEVICE_STATE(Custom:bob)'
+ value: 'ONHOLD'
+ -
+ ami-events:
+ id: '0'
+ conditions:
+ match:
+ Event: 'ExtensionStatus'
+ Exten: 'bob'
+ Hint: 'Custom:bob'
+ StatusText: 'Hold'
+ count: '1'
+ ami-actions:
+ action:
+ action: 'SetVar'
+ variable: 'DEVICE_STATE(Custom:bob)'
+ value: 'BUSY'
+ -
+ ami-events:
+ id: '0'
+ conditions:
+ match:
+ Event: 'ExtensionStatus'
+ Exten: 'bob'
+ Hint: 'Custom:bob'
+ StatusText: 'Busy'
+ count: '1'
+ ami-actions:
+ action:
+ action: 'SetVar'
+ variable: 'DEVICE_STATE(Custom:bob)'
+ value: 'UNAVAILABLE'
+ -
+ ami-events:
+ id: '0'
+ conditions:
+ match:
+ Event: 'ExtensionStatus'
+ Exten: 'bob'
+ Hint: 'Custom:bob'
+ StatusText: 'Unavailable'
+ count: '1'
+ ami-actions:
+ action:
+ action: 'SetVar'
+ variable: 'DEVICE_STATE(Custom:bob)'
+ value: 'NOT_INUSE'
+ -
+ ami-events:
+ id: '0'
+ conditions:
+ match:
+ Event: 'ExtensionStatus'
+ Exten: 'bob'
+ Hint: 'Custom:bob'
+ StatusText: 'Idle'
+ count: '1'
diff --git a/tests/channels/pjsip/subscriptions/presence/tests.yaml b/tests/channels/pjsip/subscriptions/presence/tests.yaml
index 9123536..dd66b69 100644
--- a/tests/channels/pjsip/subscriptions/presence/tests.yaml
+++ b/tests/channels/pjsip/subscriptions/presence/tests.yaml
@@ -10,3 +10,5 @@
- test: 'presencestate_repeat'
- test: 'presencestate_repeat_okay'
- test: 'dialog_info_xml'
+ - test: 'pidf_xml'
+ - test: 'xpidf_xml'
diff --git a/tests/channels/pjsip/subscriptions/presence/xpidf_xml/configs/ast1/extensions.conf b/tests/channels/pjsip/subscriptions/presence/xpidf_xml/configs/ast1/extensions.conf
new file mode 100644
index 0000000..b8dcca3
--- /dev/null
+++ b/tests/channels/pjsip/subscriptions/presence/xpidf_xml/configs/ast1/extensions.conf
@@ -0,0 +1,2 @@
+[default]
+exten => bob,hint,Custom:bob
diff --git a/tests/channels/pjsip/subscriptions/presence/xpidf_xml/configs/ast1/pjsip.conf b/tests/channels/pjsip/subscriptions/presence/xpidf_xml/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..2e71a90
--- /dev/null
+++ b/tests/channels/pjsip/subscriptions/presence/xpidf_xml/configs/ast1/pjsip.conf
@@ -0,0 +1,11 @@
+[global]
+type=global
+debug=no
+
+[local-transport]
+type=transport
+bind = 127.0.0.1
+
+[alice]
+type=endpoint
+context=default
diff --git a/tests/channels/pjsip/subscriptions/presence/xpidf_xml/sipp/subscribe.xml b/tests/channels/pjsip/subscriptions/presence/xpidf_xml/sipp/subscribe.xml
new file mode 100644
index 0000000..658bac8
--- /dev/null
+++ b/tests/channels/pjsip/subscriptions/presence/xpidf_xml/sipp/subscribe.xml
@@ -0,0 +1,244 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Subscribe">
+ <send retrans="500">
+ <![CDATA[
+ SUBSCRIBE sip:bob@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: "alice" <sip:alice@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+ To: <sip:bob@[remote_ip]:[remote_port]>
+ Call-ID: [call_id]
+ CSeq: 1 SUBSCRIBE
+ Contact: "alice" <sip:alice@[local_ip]:[local_port]>
+ Expires: 600
+ Max-Forwards: 70
+ Event: presence
+ Supported: replaces, 100rel, timer, norefersub
+ Accept: application/xpidf+xml
+ Allow-Events: presence, message-summary, refer
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv response="200" rtd="true" />
+
+ <recv request="NOTIFY" crlf="true">
+ <action>
+ <ereg regexp="<presence>
+ <presentity uri=\"sip:bob at 127.0.0.1(:5060)?\;method=SUBSCRIBE\" />
+ <atom atomid=\".*\" id=\"bob\">
+ <address uri=\""\;alice"\; <\;sip:alice at 127.0.0.1>\;\;user=ip\" priority=\"0.80000\">
+ <status status=\"open\" />
+ <msnsubstatus substatus=\"online\" />
+ </address>
+ </atom>
+</presence>" check_it="true" search_in="body" assign_to="body1" />
+ </action>
+ </recv>
+
+ <Reference variables="body1" />
+
+ <send>
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv request="NOTIFY" crlf="true">
+ <action>
+ <ereg regexp="<presence>
+ <presentity uri=\"sip:bob at 127.0.0.1(:5060)?\;method=SUBSCRIBE\" />
+ <atom atomid=\".*\" id=\"bob\">
+ <address uri=\""\;alice"\; <\;sip:alice at 127.0.0.1>\;\;user=ip\" priority=\"0.80000\">
+ <status status=\"inuse\" />
+ <msnsubstatus substatus=\"onthephone\" />
+ </address>
+ </atom>
+</presence>" check_it="true" search_in="body" assign_to="body2" />
+ </action>
+ </recv>
+
+ <Reference variables="body2" />
+
+ <send>
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv request="NOTIFY" crlf="true">
+ <action>
+ <ereg regexp="<presence>
+ <presentity uri=\"sip:bob at 127.0.0.1(:5060)?\;method=SUBSCRIBE\" />
+ <atom atomid=\".*\" id=\"bob\">
+ <address uri=\""\;alice"\; <\;sip:alice at 127.0.0.1>\;\;user=ip\" priority=\"0.80000\">
+ <status status=\"inuse\" />
+ <msnsubstatus substatus=\"onthephone\" />
+ </address>
+ </atom>
+</presence>" check_it="true" search_in="body" assign_to="body3" />
+ </action>
+ </recv>
+
+ <Reference variables="body3" />
+
+ <send>
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv request="NOTIFY" crlf="true">
+ <action>
+ <ereg regexp="<presence>
+ <presentity uri=\"sip:bob at 127.0.0.1(:5060)?\;method=SUBSCRIBE\" />
+ <atom atomid=\".*\" id=\"bob\">
+ <address uri=\""\;alice"\; <\;sip:alice at 127.0.0.1>\;\;user=ip\" priority=\"0.80000\">
+ <status status=\"closed\" />
+ <msnsubstatus substatus=\"offline\" />
+ </address>
+ </atom>
+</presence>" check_it="true" search_in="body" assign_to="body4" />
+ </action>
+ </recv>
+
+ <Reference variables="body4" />
+
+ <send>
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv request="NOTIFY" crlf="true">
+ <action>
+ <ereg regexp="<presence>
+ <presentity uri=\"sip:bob at 127.0.0.1(:5060)?\;method=SUBSCRIBE\" />
+ <atom atomid=\".*\" id=\"bob\">
+ <address uri=\""\;alice"\; <\;sip:alice at 127.0.0.1>\;\;user=ip\" priority=\"0.80000\">
+ <status status=\"closed\" />
+ <msnsubstatus substatus=\"offline\" />
+ </address>
+ </atom>
+</presence>" check_it="true" search_in="body" assign_to="body5" />
+ </action>
+ </recv>
+
+ <Reference variables="body5" />
+
+ <send>
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv request="NOTIFY" crlf="true">
+ <action>
+ <ereg regexp="<presence>
+ <presentity uri=\"sip:bob at 127.0.0.1(:5060)?\;method=SUBSCRIBE\" />
+ <atom atomid=\".*\" id=\"bob\">
+ <address uri=\""\;alice"\; <\;sip:alice at 127.0.0.1>\;\;user=ip\" priority=\"0.80000\">
+ <status status=\"closed\" />
+ <msnsubstatus substatus=\"offline\" />
+ </address>
+ </atom>
+</presence>" check_it="true" search_in="body" assign_to="body6" />
+ </action>
+ </recv>
+
+ <Reference variables="body6" />
+
+ <send>
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv request="NOTIFY" crlf="true">
+ <action>
+ <ereg regexp="<presence>
+ <presentity uri=\"sip:bob at 127.0.0.1(:5060)?\;method=SUBSCRIBE\" />
+ <atom atomid=\".*\" id=\"bob\">
+ <address uri=\""\;alice"\; <\;sip:alice at 127.0.0.1>\;\;user=ip\" priority=\"0.80000\">
+ <status status=\"open\" />
+ <msnsubstatus substatus=\"online\" />
+ </address>
+ </atom>
+</presence>" check_it="true" search_in="body" assign_to="body7" />
+ </action>
+ </recv>
+
+ <Reference variables="body7" />
+
+ <send>
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+</scenario>
diff --git a/tests/channels/pjsip/subscriptions/presence/xpidf_xml/test-config.yaml b/tests/channels/pjsip/subscriptions/presence/xpidf_xml/test-config.yaml
new file mode 100644
index 0000000..6c4cce5
--- /dev/null
+++ b/tests/channels/pjsip/subscriptions/presence/xpidf_xml/test-config.yaml
@@ -0,0 +1,145 @@
+testinfo:
+ summary: 'Ensure NOTIFY bodies for xpidf+xml subscriptions are correct.'
+ description: |
+ 'A SIPp instance subscribes to "bob" using xpidf+xml. Upon the
+ first TestEvent indicating that there is an active subscription, the
+ state of "Custom:bob" is changed. Each AMI event indicating that a
+ state change occurred triggers another state change until all states
+ have been set. The SIPp scenario expects to receive a NOTIFY message
+ for each state and verifies the contents of the xpidf+xml body for
+ each. If any xpidf+xml body contents do not match what is expected, the
+ test fails.'
+
+properties:
+ minversion: '12.5.0'
+ dependencies:
+ - sipp :
+ version : 'v3.0'
+ - python: 'twisted'
+ - python: 'starpy'
+ - asterisk: 'res_pjsip'
+ - asterisk: 'res_pjsip_exten_state'
+ - asterisk: 'res_pjsip_xpidf_body_generator'
+ tags:
+ - pjsip
+
+test-modules:
+ test-object:
+ config-section: sipp-config
+ typename: 'sipp.SIPpTestCase'
+ modules:
+ -
+ config-section: ami-config
+ typename: 'pluggable_modules.EventActionModule'
+
+sipp-config:
+ reactor-timeout: 30
+ fail-on-any: True
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': {'scenario': 'subscribe.xml', '-p': '5061'},
+ 'ordered-args': ['-timeout_error'] }
+
+ami-config:
+ -
+ ami-events:
+ id: '0'
+ conditions:
+ match:
+ Event: 'TestEvent'
+ State: 'SUBSCRIPTION_STATE_SET'
+ StateText: 'ACTIVE'
+ Endpoint: 'alice'
+ count: '>1'
+ trigger-on-count: True
+ ami-actions:
+ action:
+ action: 'SetVar'
+ variable: 'DEVICE_STATE(Custom:bob)'
+ value: 'RINGING'
+ -
+ ami-events:
+ id: '0'
+ conditions:
+ match:
+ Event: 'ExtensionStatus'
+ Exten: 'bob'
+ Hint: 'Custom:bob'
+ StatusText: 'Ringing'
+ count: '1'
+ ami-actions:
+ action:
+ action: 'SetVar'
+ variable: 'DEVICE_STATE(Custom:bob)'
+ value: 'INUSE'
+ -
+ ami-events:
+ id: '0'
+ conditions:
+ match:
+ Event: 'ExtensionStatus'
+ Exten: 'bob'
+ Hint: 'Custom:bob'
+ StatusText: 'InUse'
+ count: '1'
+ ami-actions:
+ action:
+ action: 'SetVar'
+ variable: 'DEVICE_STATE(Custom:bob)'
+ value: 'ONHOLD'
+ -
+ ami-events:
+ id: '0'
+ conditions:
+ match:
+ Event: 'ExtensionStatus'
+ Exten: 'bob'
+ Hint: 'Custom:bob'
+ StatusText: 'Hold'
+ count: '1'
+ ami-actions:
+ action:
+ action: 'SetVar'
+ variable: 'DEVICE_STATE(Custom:bob)'
+ value: 'BUSY'
+ -
+ ami-events:
+ id: '0'
+ conditions:
+ match:
+ Event: 'ExtensionStatus'
+ Exten: 'bob'
+ Hint: 'Custom:bob'
+ StatusText: 'Busy'
+ count: '1'
+ ami-actions:
+ action:
+ action: 'SetVar'
+ variable: 'DEVICE_STATE(Custom:bob)'
+ value: 'UNAVAILABLE'
+ -
+ ami-events:
+ id: '0'
+ conditions:
+ match:
+ Event: 'ExtensionStatus'
+ Exten: 'bob'
+ Hint: 'Custom:bob'
+ StatusText: 'Unavailable'
+ count: '1'
+ ami-actions:
+ action:
+ action: 'SetVar'
+ variable: 'DEVICE_STATE(Custom:bob)'
+ value: 'NOT_INUSE'
+ -
+ ami-events:
+ id: '0'
+ conditions:
+ match:
+ Event: 'ExtensionStatus'
+ Exten: 'bob'
+ Hint: 'Custom:bob'
+ StatusText: 'Idle'
+ count: '1'
--
To view, visit https://gerrit.asterisk.org/1023
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib852d1d42ea391fe4e7d1abf0eb7ea6eabb62cba
Gerrit-PatchSet: 2
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: John Bigelow <jbigelow at digium.com>
More information about the asterisk-code-review
mailing list