[Asterisk-code-review] testsuite: fix rewrite contact tests (testsuite[master])

Jenkins2 asteriskteam at digium.com
Wed Oct 31 14:43:46 CDT 2018


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/10563 )

Change subject: testsuite: fix rewrite_contact tests
......................................................................

testsuite: fix rewrite_contact tests

The current rewrite_contact tests put the correct source ip in the
headers expected to be rewritten, thus the header re-write has no
effect & the test would pass regardless if rewrite_contact is enabled.
To fix this, the tests have been updated to have a bogus ip in the
route header & ensure that it is either modified, (or remains the same)

Tests were also added to validate the other half the nat logic, where
contact should be updated in the case no route set is present

Change-Id: Ic3974170dfc3bb878b663359c459a08f9674d9a6
---
A tests/channels/pjsip/nat/rewrite_contact/contact_request/configs/ast1/extensions.conf
A tests/channels/pjsip/nat/rewrite_contact/contact_request/configs/ast1/pjsip.conf
A tests/channels/pjsip/nat/rewrite_contact/contact_request/sipp/uac-route-set.xml
A tests/channels/pjsip/nat/rewrite_contact/contact_request/test-config.yaml
A tests/channels/pjsip/nat/rewrite_contact/contact_response/configs/ast1/extensions.conf
A tests/channels/pjsip/nat/rewrite_contact/contact_response/configs/ast1/pjsip.conf
A tests/channels/pjsip/nat/rewrite_contact/contact_response/sipp/uas-route-set.xml
A tests/channels/pjsip/nat/rewrite_contact/contact_response/test-config.yaml
M tests/channels/pjsip/nat/rewrite_contact/route_set_request/sipp/uac-route-set.xml
M tests/channels/pjsip/nat/rewrite_contact/route_set_response/sipp/uas-route-set.xml
M tests/channels/pjsip/nat/rewrite_contact/tests.yaml
11 files changed, 302 insertions(+), 6 deletions(-)

Approvals:
  George Joseph: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/tests/channels/pjsip/nat/rewrite_contact/contact_request/configs/ast1/extensions.conf b/tests/channels/pjsip/nat/rewrite_contact/contact_request/configs/ast1/extensions.conf
new file mode 100644
index 0000000..7b75b3e
--- /dev/null
+++ b/tests/channels/pjsip/nat/rewrite_contact/contact_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/contact_request/configs/ast1/pjsip.conf b/tests/channels/pjsip/nat/rewrite_contact/contact_request/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..f2ec207
--- /dev/null
+++ b/tests/channels/pjsip/nat/rewrite_contact/contact_request/configs/ast1/pjsip.conf
@@ -0,0 +1,14 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[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/contact_request/sipp/uac-route-set.xml b/tests/channels/pjsip/nat/rewrite_contact/contact_request/sipp/uac-route-set.xml
new file mode 100644
index 0000000..eae7f53
--- /dev/null
+++ b/tests/channels/pjsip/nat/rewrite_contact/contact_request/sipp/uac-route-set.xml
@@ -0,0 +1,91 @@
+<?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:1.2.3.4: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:[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:5061.*"
+              search_in="msg"
+              check_it="true"
+              assign_to="1"/>
+      </action>
+  </recv>
+
+  <Reference variables="1" />
+
+  <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/contact_request/test-config.yaml b/tests/channels/pjsip/nat/rewrite_contact/contact_request/test-config.yaml
new file mode 100644
index 0000000..47f743d
--- /dev/null
+++ b/tests/channels/pjsip/nat/rewrite_contact/contact_request/test-config.yaml
@@ -0,0 +1,35 @@
+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 does not have Record-Route headers in it.
+        We ensure that Asterisk correctly rewrites the Contact header in the
+        INVITE when the rewrite_contact option is enabled.  We then hang
+        up the call, and we ensure that the request URI is correct.'
+
+test-modules:
+    test-object:
+        config-section: sipp-config
+        typename: 'sipp.SIPpAMIActionTestCase'
+
+sipp-config:
+    memcheck-delay-stop: 7
+    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:
+    dependencies:
+        - sipp:
+            version: 'v3.0'
+        - asterisk: 'res_pjsip'
+    tags:
+        - pjsip
diff --git a/tests/channels/pjsip/nat/rewrite_contact/contact_response/configs/ast1/extensions.conf b/tests/channels/pjsip/nat/rewrite_contact/contact_response/configs/ast1/extensions.conf
new file mode 100644
index 0000000..c0f0b19
--- /dev/null
+++ b/tests/channels/pjsip/nat/rewrite_contact/contact_response/configs/ast1/extensions.conf
@@ -0,0 +1,4 @@
+[default]
+exten => sipp,1,NoOp()
+same => n,Dial(PJSIP/sipp)
+same => n,Hangup()
diff --git a/tests/channels/pjsip/nat/rewrite_contact/contact_response/configs/ast1/pjsip.conf b/tests/channels/pjsip/nat/rewrite_contact/contact_response/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..e2330b0
--- /dev/null
+++ b/tests/channels/pjsip/nat/rewrite_contact/contact_response/configs/ast1/pjsip.conf
@@ -0,0 +1,19 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local]
+type = transport
+bind = 127.0.0.1:5060
+
+[sipp]
+type = endpoint
+context = default
+allow = ulaw
+rewrite_contact = yes
+aors = sipp
+
+[sipp]
+type = aor
+contact = sip:sipp at 127.0.0.1:5061
diff --git a/tests/channels/pjsip/nat/rewrite_contact/contact_response/sipp/uas-route-set.xml b/tests/channels/pjsip/nat/rewrite_contact/contact_response/sipp/uas-route-set.xml
new file mode 100644
index 0000000..1727ad8
--- /dev/null
+++ b/tests/channels/pjsip/nat/rewrite_contact/contact_response/sipp/uas-route-set.xml
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Basic UAS responder">
+  <!-- By adding rrs="true" (Record Route Sets), the route sets         -->
+  <!-- are saved and used for following messages sent. Useful to test   -->
+  <!-- against stateful SIP proxies/B2BUAs.                             -->
+  <Global variables="remote_tag" />
+  <recv request="INVITE" crlf="true">
+      <!-- Save the from tag. We'll need it when we send our BYE -->
+      <action>
+          <ereg regexp=".*(;tag=.*)"
+              header="From:"
+              search_in="hdr"
+              check_it="true"
+              assign_to="remote_tag"/>
+	  </action>
+  </recv>
+
+  <send retrans="500">
+    <![CDATA[
+
+      SIP/2.0 200 OK
+      [last_Via:]
+      [last_From:]
+      [last_To:];tag=[pid]SIPpTag01[call_number]
+      [last_Call-ID:]
+      [last_CSeq:]
+      Contact: <sip:1.2.3.4:5063>
+      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 request="ACK"
+        rtd="true"
+        crlf="true">
+        <action>
+            <ereg regexp="ACK sip:127.0.0.1:5061.*"
+                search_in="msg"
+                check_it="true"
+                assign_to="1"/>
+        </action>
+  </recv>
+
+  <Reference variables="1" />
+
+  <pause/>
+
+  <send retrans="500">
+    <![CDATA[
+
+      BYE sip:[service]@127.0.0.1:[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]SIPpTag01[call_number]
+      To: [$remote_tag]
+      [last_Call-ID:]
+      CSeq: [cseq] BYE
+      Contact: sip:sipp@[local_ip]:[local_port]
+      Max-Forwards: 70
+      Subject: Performance Test
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+  <recv response="200">
+  </recv>
+
+  <!-- Keep the call open for a while in case the 200 is lost to be     -->
+  <!-- able to retransmit it if we receive the BYE again.               -->
+  <timewait milliseconds="4000"/>
+
+
+  <!-- definition of the response time repartition table (unit is ms)   -->
+  <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
+
+  <!-- definition of the call length repartition table (unit is ms)     -->
+  <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
+
+</scenario>
+
diff --git a/tests/channels/pjsip/nat/rewrite_contact/contact_response/test-config.yaml b/tests/channels/pjsip/nat/rewrite_contact/contact_response/test-config.yaml
new file mode 100644
index 0000000..bbfad0f
--- /dev/null
+++ b/tests/channels/pjsip/nat/rewrite_contact/contact_response/test-config.yaml
@@ -0,0 +1,35 @@
+testinfo:
+    summary: 'Ensure that proper URI is rewritten on SIP responses'
+    description: |
+        'This test has Asterisk place an outbound call to a SIPp scenario,
+        which represents a proxy in the path to some endpoint. The 200 OK
+        response that SIPp sends has no Record-Route headers in it. We ensure
+        that Asterisk does rewrite the Contact header in the SIP response.'
+
+test-modules:
+    test-object:
+        config-section: sipp-config
+        typename: 'sipp.SIPpAMIActionTestCase'
+
+sipp-config:
+    memcheck-delay-stop: 7
+    fail-on-any: True
+    test-iterations:
+        -
+            scenarios:
+                - { 'key-args': {'scenario': 'uas-route-set.xml', '-p': '5061'} }
+    ami-action:
+        delay: 1
+        args:
+            Action: 'Originate'
+            Channel: 'PJSIP/sipp'
+            Application: 'Echo'
+
+
+properties:
+    dependencies:
+        - sipp:
+            version: 'v3.0'
+        - asterisk: 'res_pjsip'
+    tags:
+        - pjsip
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
index 65fc131..6fb9b51 100644
--- 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
@@ -11,9 +11,9 @@
       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:1.2.3.4:5061;lr>
       Record-Route: <sip:127.0.0.1:5062;lr>
-      Contact: <sip:127.0.0.1:5063;transport=[transport]>
+      Contact: <sip:1.2.3.4:5063;transport=[transport]>
       Max-Forwards: 70
       Subject: Performance Test
       Content-Type: application/sdp
@@ -66,7 +66,7 @@
 
   <recv request="BYE">
       <action>
-          <ereg regexp="BYE sip:127.0.0.1:5063.*"
+          <ereg regexp="BYE sip:1.2.3.4:5063.*"
               search_in="msg"
               check_it="true"
               assign_to="1"/>
diff --git a/tests/channels/pjsip/nat/rewrite_contact/route_set_response/sipp/uas-route-set.xml b/tests/channels/pjsip/nat/rewrite_contact/route_set_response/sipp/uas-route-set.xml
index 9a1532e..ca0a6eb 100644
--- a/tests/channels/pjsip/nat/rewrite_contact/route_set_response/sipp/uas-route-set.xml
+++ b/tests/channels/pjsip/nat/rewrite_contact/route_set_response/sipp/uas-route-set.xml
@@ -27,8 +27,8 @@
       [last_Call-ID:]
       [last_CSeq:]
       Record-Route: <sip:127.0.0.1:5062;lr>
-      Record-Route: <sip:127.0.0.1:5061;lr>
-      Contact: <sip:127.0.0.1:5063>
+      Record-Route: <sip:1.2.3.4:5061;lr>
+      Contact: <sip:1.2.3.4:5063>
       Content-Type: application/sdp
       Content-Length: [len]
 
@@ -47,7 +47,7 @@
         rtd="true"
         crlf="true">
         <action>
-            <ereg regexp="ACK sip:127.0.0.1:5063.*"
+            <ereg regexp="ACK sip:1.2.3.4:5063.*"
                 search_in="msg"
                 check_it="true"
                 assign_to="1"/>
diff --git a/tests/channels/pjsip/nat/rewrite_contact/tests.yaml b/tests/channels/pjsip/nat/rewrite_contact/tests.yaml
index 9c04329..6cfd65c 100644
--- a/tests/channels/pjsip/nat/rewrite_contact/tests.yaml
+++ b/tests/channels/pjsip/nat/rewrite_contact/tests.yaml
@@ -2,3 +2,5 @@
     - test: 'route_set_response'
     - test: 'route_set_request'
     - test: 'route_set_reinvite'
+    - test: 'contact_request'
+    - test: 'contact_response'

-- 
To view, visit https://gerrit.asterisk.org/10563
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic3974170dfc3bb878b663359c459a08f9674d9a6
Gerrit-Change-Number: 10563
Gerrit-PatchSet: 2
Gerrit-Owner: Torrey Searle <tsearle at gmail.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2 (1000185)
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20181031/1cba0cf5/attachment-0001.html>


More information about the asterisk-code-review mailing list