[asterisk-commits] SIP: Add redirecting reason test. (testsuite[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Aug 11 12:00:41 CDT 2015


Matt Jordan has submitted this change and it was merged.

Change subject: SIP: Add redirecting reason test.
......................................................................


SIP: Add redirecting reason test.

This is a test I actually wrote nearly three years ago and somehow did
not manage to get merged.

This test ensures that the REDIRECTING(reason) gets set to specific
values when we expect them to. We check this in three scenarios:

* As the ;reason parameter on a Diversion header in an incoming INVITE
* As the ;reason parameter on a Diversion header in an incoming 302
* As the status text on a 480 response on an outgoing call

Change-Id: Ie9f609da197a746ce2a9b8bd2595db0419e5bd87
---
A tests/channels/SIP/redirecting_reason/configs/ast1/extensions.conf
A tests/channels/SIP/redirecting_reason/configs/ast1/sip.conf
A tests/channels/SIP/redirecting_reason/sipp/uac-diversion.xml
A tests/channels/SIP/redirecting_reason/sipp/uac-no-hangup.xml
A tests/channels/SIP/redirecting_reason/sipp/uas-480.xml
A tests/channels/SIP/redirecting_reason/sipp/uas-redirect.xml
A tests/channels/SIP/redirecting_reason/test-config.yaml
M tests/channels/SIP/tests.yaml
8 files changed, 335 insertions(+), 0 deletions(-)

Approvals:
  Matt Jordan: Looks good to me, approved; Verified
  Joshua Colp: Looks good to me, but someone else must approve



diff --git a/tests/channels/SIP/redirecting_reason/configs/ast1/extensions.conf b/tests/channels/SIP/redirecting_reason/configs/ast1/extensions.conf
new file mode 100644
index 0000000..11c4fe2
--- /dev/null
+++ b/tests/channels/SIP/redirecting_reason/configs/ast1/extensions.conf
@@ -0,0 +1,13 @@
+[default]
+
+exten => diverter,1,Dial(SIP/diverter)
+same => n,Hangup
+
+exten => test_diversion,1,Answer
+same => n,UserEvent(RedirectReason, Result: ${IF($[${REDIRECTING(reason)} = eggdog]?Success:Failure)})
+same => n,Hangup()
+
+exten => unavailable,1,Dial(SIP/diverter)
+same => n,UserEvent(RedirectReason, Result: ${IF($[${REDIRECTING(reason)} = eggdog]?Success:Failure)})
+same => n,Answer()
+same => n,Hangup()
diff --git a/tests/channels/SIP/redirecting_reason/configs/ast1/sip.conf b/tests/channels/SIP/redirecting_reason/configs/ast1/sip.conf
new file mode 100644
index 0000000..b19c26e
--- /dev/null
+++ b/tests/channels/SIP/redirecting_reason/configs/ast1/sip.conf
@@ -0,0 +1,13 @@
+[general]
+
+udpbindaddr = 127.0.0.1:5060
+
+[caller]
+type=peer
+host=127.0.0.1
+port=5061
+
+[diverter]
+type=peer
+host=127.0.0.1
+port=5062
diff --git a/tests/channels/SIP/redirecting_reason/sipp/uac-diversion.xml b/tests/channels/SIP/redirecting_reason/sipp/uac-diversion.xml
new file mode 100644
index 0000000..2178d70
--- /dev/null
+++ b/tests/channels/SIP/redirecting_reason/sipp/uac-diversion.xml
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Basic Sipstone UAC">
+  <send retrans="500">
+    <![CDATA[
+
+      INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+      To: sut <sip:[service]@[remote_ip]:[remote_port]>
+      Call-ID: [call_id]
+      CSeq: 1 INVITE
+      Contact: sip:sipp@[local_ip]:[local_port]
+      Max-Forwards: 70
+      Subject: Performance Test
+      Diversion: "Salad Fork" <sip:munchies at pig_groin.net>;reason="eggdog"
+      Content-Type: application/sdp
+      Content-Length: [len]
+
+      v=0
+      o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+      s=-
+      c=IN IP[media_ip_type] [media_ip]
+      t=0 0
+      m=audio [media_port] RTP/AVP 0
+      a=rtpmap:0 PCMU/8000
+
+    ]]>
+  </send>
+
+  <recv response="100"
+        optional="true">
+  </recv>
+
+  <recv response="181"
+        optional="true">
+  </recv>
+
+  <recv response="180" optional="true">
+  </recv>
+
+  <recv response="183" optional="true">
+  </recv>
+
+  <recv response="200" rtd="true">
+  </recv>
+
+  <send>
+    <![CDATA[
+
+      ACK sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+      To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
+      Call-ID: [call_id]
+      CSeq: 1 ACK
+      Contact: sip:sipp@[local_ip]:[local_port]
+      Max-Forwards: 70
+      Subject: Performance Test
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+  <recv request="BYE">
+  </recv>
+
+  <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>
+
+  <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
+
+  <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
+
+</scenario>
+
diff --git a/tests/channels/SIP/redirecting_reason/sipp/uac-no-hangup.xml b/tests/channels/SIP/redirecting_reason/sipp/uac-no-hangup.xml
new file mode 100644
index 0000000..a458a67
--- /dev/null
+++ b/tests/channels/SIP/redirecting_reason/sipp/uac-no-hangup.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Basic Sipstone UAC">
+  <send retrans="500">
+    <![CDATA[
+
+      INVITE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+      To: sut <sip:[service]@[remote_ip]:[remote_port]>
+      Call-ID: [call_id]
+      CSeq: 1 INVITE
+      Contact: sip:sipp@[local_ip]:[local_port]
+      Max-Forwards: 70
+      Subject: Performance Test
+      Content-Type: application/sdp
+      Content-Length: [len]
+
+      v=0
+      o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+      s=-
+      c=IN IP[media_ip_type] [media_ip]
+      t=0 0
+      m=audio [media_port] RTP/AVP 0
+      a=rtpmap:0 PCMU/8000
+
+    ]]>
+  </send>
+
+  <recv response="100"
+        optional="true">
+  </recv>
+
+  <recv response="181"
+        optional="true">
+  </recv>
+
+  <recv response="180" optional="true">
+  </recv>
+
+  <recv response="183" optional="true">
+  </recv>
+
+  <recv response="200" rtd="true">
+  </recv>
+
+  <send>
+    <![CDATA[
+
+      ACK sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+      From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+      To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
+      Call-ID: [call_id]
+      CSeq: 1 ACK
+      Contact: sip:sipp@[local_ip]:[local_port]
+      Max-Forwards: 70
+      Subject: Performance Test
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+  <recv request="BYE">
+  </recv>
+
+  <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>
+
+  <timewait milliseconds="4000"/>
+
+  <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
+
+  <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
+
+</scenario>
+
diff --git a/tests/channels/SIP/redirecting_reason/sipp/uas-480.xml b/tests/channels/SIP/redirecting_reason/sipp/uas-480.xml
new file mode 100644
index 0000000..2a7896c
--- /dev/null
+++ b/tests/channels/SIP/redirecting_reason/sipp/uas-480.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Basic UAS responder">
+  <recv request="INVITE" crlf="true">
+  </recv>
+
+  <send>
+    <![CDATA[
+
+      SIP/2.0 480 eggdog
+      [last_Via:]
+      [last_From:]
+      [last_To:];tag=[pid]SIPpTag01[call_number]
+      [last_Call-ID:]
+      [last_CSeq:]
+      Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+  <recv request="ACK"
+        rtd="true"
+        crlf="true">
+  </recv>
+
+  <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
+
+  <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
+
+</scenario>
+
diff --git a/tests/channels/SIP/redirecting_reason/sipp/uas-redirect.xml b/tests/channels/SIP/redirecting_reason/sipp/uas-redirect.xml
new file mode 100644
index 0000000..d438a37
--- /dev/null
+++ b/tests/channels/SIP/redirecting_reason/sipp/uas-redirect.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Basic UAS responder">
+  <recv request="INVITE" crlf="true">
+  </recv>
+
+  <send>
+    <![CDATA[
+
+      SIP/2.0 302 Temporarily Moved
+      [last_Via:]
+      [last_From:]
+      [last_To:];tag=[pid]SIPpTag01[call_number]
+      [last_Call-ID:]
+      [last_CSeq:]
+      Diversion: <sip:[local_ip]:[local_port]>;reason="eggdog"
+      Contact: <sip:[redir_target]@[remote_ip]:[remote_port];transport=[transport]>
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+  <recv request="ACK"
+        rtd="true"
+        crlf="true">
+  </recv>
+
+  <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
+
+  <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
+
+</scenario>
+
diff --git a/tests/channels/SIP/redirecting_reason/test-config.yaml b/tests/channels/SIP/redirecting_reason/test-config.yaml
new file mode 100644
index 0000000..ae8570f
--- /dev/null
+++ b/tests/channels/SIP/redirecting_reason/test-config.yaml
@@ -0,0 +1,62 @@
+testinfo:
+    summary: 'Test that custom SIP redirecting reasons are accessible from the dialplan'
+    description: |
+        'This test performs three calls.
+
+         On the first call, an INVITE with a Diversion header arrives into Asterisk. We
+         ensure that from the dialplan, the redirecting reason is what we expect it to be.
+
+         On the second call, we place an outgoing call to a UAS that responds with a 302. In
+         that 302, there is a Diversion header with a reason parameter. We again check in the
+         dialplan to ensure that the redirecting reason has been set to this value.
+
+         On the third call, we place an outgoing call to a UAS that responds with a 480, and
+         with custom status text. We then ensure that the custom status text appears as the
+         redirecting reason in the dialplan.'
+
+test-modules:
+    test-object:
+        config-section: 'calls'
+        typename: 'sipp.SIPpTestCase'
+    modules:
+        -
+            config-section: 'ami-config'
+            typename: 'ami.AMIEventModule'
+
+calls:
+    fail-on-any: False
+    test-iterations:
+        -
+            scenarios:
+                - { 'key-args': { 'scenario': 'uac-diversion.xml', '-s': 'test_diversion'} }
+        -
+            scenarios:
+                - { 'key-args': { 'scenario': 'uas-redirect.xml', '-p': '5062'},
+                    'ordered-args': ['-key', 'redir_target', 'test_diversion']}
+                - { 'key-args': { 'scenario': 'uac-no-hangup.xml', '-d': '2000', '-s': 'diverter', '-p': '5061'} }
+        -
+            scenarios:
+                - { 'key-args': { 'scenario': 'uas-480.xml', '-p': '5062'}}
+                - { 'key-args': { 'scenario': 'uac-no-hangup.xml', '-d': '2000', '-s': 'unavailable', '-p': '5061'} }
+
+ami-config:
+    -
+        type: 'headermatch'
+        conditions:
+            match:
+                Event: 'UserEvent'
+                UserEvent: 'RedirectReason'
+        requirements:
+            match:
+                Result: 'Success'
+        count: '3'
+
+properties:
+    minversion: 1.8.15.0-cert
+    dependencies:
+        - python: 'starpy'
+        - sipp:
+            version: 'v3.1'
+        - asterisk: 'chan_sip'
+    tags:
+        - SIP
diff --git a/tests/channels/SIP/tests.yaml b/tests/channels/SIP/tests.yaml
index 9fcda79..aa0d156 100644
--- a/tests/channels/SIP/tests.yaml
+++ b/tests/channels/SIP/tests.yaml
@@ -72,3 +72,4 @@
     - test: 'no_ack_dialog_cleanup'
     - test: 'no_reinvite_after_491'
     - test: 'sip_bye_also'
+    - test: 'redirecting_reason'

-- 
To view, visit https://gerrit.asterisk.org/1058
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie9f609da197a746ce2a9b8bd2595db0419e5bd87
Gerrit-PatchSet: 2
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>



More information about the asterisk-commits mailing list