[asterisk-commits] Add test for rewriting contact on request with Record-Routes. (testsuite[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 26 13:37:09 CDT 2015


Matt Jordan has submitted this change and it was merged.

Change subject: Add test for rewriting contact on request with Record-Routes.
......................................................................


Add test for rewriting contact on request with Record-Routes.

This test has a SIPp scenario call Asterisk. The SIPp scenario
represents a proxy that is between Asterisk and the actual endpoint
that placed the call towards Asterisk. As a result, the INVITE that
Asterisk receives has Record-Route headers in it. We ensure that,
despite the fact that the rewrite_contact option is enabled for the
endpoint on which the INVITE is received, that the contact is not
actually rewritten since the first item in the route set is the
same address from which the request is received. We test this by
inspecting the BYE request that Asterisk sends to SIPp to end
the call.

Change-Id: Ia6ca09a65d59e80f0a7f3e85eed946bd4564222c
---
A tests/channels/pjsip/nat/rewrite_contact/route_set_request/configs/ast1/extensions.conf
A tests/channels/pjsip/nat/rewrite_contact/route_set_request/configs/ast1/pjsip.conf
A tests/channels/pjsip/nat/rewrite_contact/route_set_request/sipp/uac-route-set.xml
A tests/channels/pjsip/nat/rewrite_contact/route_set_request/test-config.yaml
M tests/channels/pjsip/nat/rewrite_contact/tests.yaml
5 files changed, 149 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/pjsip/nat/rewrite_contact/route_set_request/configs/ast1/extensions.conf b/tests/channels/pjsip/nat/rewrite_contact/route_set_request/configs/ast1/extensions.conf
new file mode 100644
index 0000000..7b75b3e
--- /dev/null
+++ b/tests/channels/pjsip/nat/rewrite_contact/route_set_request/configs/ast1/extensions.conf
@@ -0,0 +1,5 @@
+[default]
+exten => echo,1,NoOp()
+same => n,Answer()
+same => n,Echo()
+same => n,Hangup()
diff --git a/tests/channels/pjsip/nat/rewrite_contact/route_set_request/configs/ast1/pjsip.conf b/tests/channels/pjsip/nat/rewrite_contact/route_set_request/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..7b8b95d
--- /dev/null
+++ b/tests/channels/pjsip/nat/rewrite_contact/route_set_request/configs/ast1/pjsip.conf
@@ -0,0 +1,9 @@
+[local]
+type = transport
+bind = 127.0.0.1:5060
+
+[sipp]
+type = endpoint
+context = default
+allow = ulaw
+rewrite_contact = yes
diff --git a/tests/channels/pjsip/nat/rewrite_contact/route_set_request/sipp/uac-route-set.xml b/tests/channels/pjsip/nat/rewrite_contact/route_set_request/sipp/uac-route-set.xml
new file mode 100644
index 0000000..65fc131
--- /dev/null
+++ b/tests/channels/pjsip/nat/rewrite_contact/route_set_request/sipp/uac-route-set.xml
@@ -0,0 +1,97 @@
+<?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
+      Record-Route: <sip:127.0.0.1:5061;lr>
+      Record-Route: <sip:127.0.0.1:5062;lr>
+      Contact: <sip:127.0.0.1:5063;transport=[transport]>
+      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">
+      <action>
+          <ereg regexp="BYE sip:127.0.0.1:5063.*"
+              search_in="msg"
+              check_it="true"
+              assign_to="1"/>
+          <ereg regexp="Route: <sip:127.0.0.1:5061;lr>\r\nRoute: <sip:127.0.0.1:5062;lr>"
+              search_in="msg"
+              check_it="true"
+              assign_to="2"/>
+      </action>
+  </recv>
+
+  <Reference variables="1,2" />
+
+  <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/nat/rewrite_contact/route_set_request/test-config.yaml b/tests/channels/pjsip/nat/rewrite_contact/route_set_request/test-config.yaml
new file mode 100644
index 0000000..baa7187
--- /dev/null
+++ b/tests/channels/pjsip/nat/rewrite_contact/route_set_request/test-config.yaml
@@ -0,0 +1,37 @@
+testinfo:
+    summary: 'Ensure that proper URI is rewritten on SIP responses'
+    description: |
+        'This test has SIPp place a call to Asterisk. The SIPp scenario
+        represents a proxy in the path to some endpoint. The INVITE that the
+        SIPp scenario sends has Record-Route headers in it. We ensure that
+        Asterisk does not attempt to rewrite the Contact header in the INVITE
+        despite the fact that the rewrite_contact option is enabled. We instead
+        ensure that the top-most Record-Route header is rewritten. We then hang
+        up the call, and we ensure that the request URI and the route set in
+        the BYE is correct.'
+
+test-modules:
+    test-object:
+        config-section: sipp-config
+        typename: 'sipp.SIPpAMIActionTestCase'
+
+sipp-config:
+    fail-on-any: True
+    test-iterations:
+        -
+            scenarios:
+                - { 'key-args': {'scenario': 'uac-route-set.xml', '-p': '5061', '-s': 'echo'} }
+    ami-action:
+        delay: 1
+        args:
+            Action: 'Hangup'
+            Channel: '/PJSIP/sipp-.*/'
+
+properties:
+    minversion: '13.5.0'
+    dependencies:
+        - sipp:
+            version: 'v3.0'
+        - asterisk: 'res_pjsip'
+    tags:
+        - pjsip
diff --git a/tests/channels/pjsip/nat/rewrite_contact/tests.yaml b/tests/channels/pjsip/nat/rewrite_contact/tests.yaml
index beef6a2..8f1a3e1 100644
--- a/tests/channels/pjsip/nat/rewrite_contact/tests.yaml
+++ b/tests/channels/pjsip/nat/rewrite_contact/tests.yaml
@@ -1,2 +1,3 @@
 tests:
     - test: 'route_set_response'
+    - test: 'route_set_request'

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia6ca09a65d59e80f0a7f3e85eed946bd4564222c
Gerrit-PatchSet: 1
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