[Asterisk-code-review] channels/pjsip/identify: Add a header or IP test (testsuite[master])

Anonymous Coward asteriskteam at digium.com
Wed Mar 15 20:02:06 CDT 2017


Anonymous Coward #1000019 has submitted this change and it was merged. ( https://gerrit.asterisk.org/5181 )

Change subject: channels/pjsip/identify: Add a header or IP test
......................................................................


channels/pjsip/identify: Add a header or IP test

This patch adds a test that covers matching an inbound request by either
SIP header: value or by the source IP address. The test checks that
requests with either a matching header or souce IP address match the
same 'identify' object that provides both options.

ASTERISK-26863

Change-Id: I9809d20208d7e55732d6382a243e4a6cfd6d972f
---
A tests/channels/pjsip/identify/header_or_ip/configs/ast1/extensions.conf
A tests/channels/pjsip/identify/header_or_ip/configs/ast1/pjsip.conf
A tests/channels/pjsip/identify/header_or_ip/sipp/nominal.xml
A tests/channels/pjsip/identify/header_or_ip/test-config.yaml
M tests/channels/pjsip/identify/tests.yaml
5 files changed, 152 insertions(+), 0 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/tests/channels/pjsip/identify/header_or_ip/configs/ast1/extensions.conf b/tests/channels/pjsip/identify/header_or_ip/configs/ast1/extensions.conf
new file mode 100644
index 0000000..df819c9
--- /dev/null
+++ b/tests/channels/pjsip/identify/header_or_ip/configs/ast1/extensions.conf
@@ -0,0 +1,6 @@
+[default]
+
+exten => echo,1,NoOp()
+ same =>      n,Answer()
+ same =>      n,Echo()
+ same =>      n,Hangup()
diff --git a/tests/channels/pjsip/identify/header_or_ip/configs/ast1/pjsip.conf b/tests/channels/pjsip/identify/header_or_ip/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..7d9c342
--- /dev/null
+++ b/tests/channels/pjsip/identify/header_or_ip/configs/ast1/pjsip.conf
@@ -0,0 +1,22 @@
+[local-transport-template](!)
+type=transport
+bind=127.0.0.1
+
+[local-transport-udp](local-transport-template)
+protocol=udp
+
+[endpoint-template-ipv4](!)
+type=endpoint
+context=default
+allow=!all,ulaw,alaw
+media_address=127.0.0.1
+
+[alice](endpoint-template-ipv4)
+
+[identify-template](!)
+type=identify
+
+[alice-identify](identify-template)
+endpoint=alice
+match_header=X-ASTERISK-TOKEN: e7657250-07fa-11e7-92f8-1b946c0c7e84
+match=127.0.0.1
diff --git a/tests/channels/pjsip/identify/header_or_ip/sipp/nominal.xml b/tests/channels/pjsip/identify/header_or_ip/sipp/nominal.xml
new file mode 100644
index 0000000..f8018a9
--- /dev/null
+++ b/tests/channels/pjsip/identify/header_or_ip/sipp/nominal.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="INVITE to echo with SDP in initial INVITE">
+  <send retrans="500">
+    <![CDATA[
+
+      INVITE sip:echo@[remote_ip]:[remote_port] SIP/2.0
+      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+      From: test1 <sip:[service]@[local_ip]:[local_port]>;tag=[call_number]
+      To: test <sip:test@[remote_ip]:[remote_port]>
+      Call-ID: [call_id]
+      CSeq: 1 INVITE
+      Contact: <sip:test@[local_ip]:[local_port];transport=[transport]>
+      Max-Forwards: 70
+      Subject: Test
+      X-ASTERISK-TOKEN: [ident_key]
+      User-Agent: Test
+      Content-Type: application/sdp
+      Content-Length: [len]
+
+      v=0
+      o=phoneA 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+      s=-
+      c=IN IP[media_ip_type] [media_ip]
+      t=0 0
+      m=audio 6000 RTP/AVP 0
+      a=rtpmap:0 PCMU/8000
+
+    ]]>
+  </send>
+
+  <recv response="100"
+        optional="true">
+  </recv>
+
+  <recv response="200" rtd="true">
+  </recv>
+
+  <send>
+    <![CDATA[
+
+      ACK sip:echo@[remote_ip]:[remote_port] SIP/2.0
+      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+      From: test1 <sip:[service]@[local_ip]:[local_port]>;tag=[call_number]
+      To: test <sip:test@[remote_ip]:[remote_port]>[peer_tag_param]
+      Call-ID: [call_id]
+      CSeq: 1 ACK
+      Contact: <sip:test@[local_ip]:[local_port];transport=[transport]>
+      Max-Forwards: 70
+      Subject: Test
+      X-ASTERISK-TOKEN: [ident_key]
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+  <pause/>
+
+  <send retrans="500">
+    <![CDATA[
+
+      BYE sip:echo@[remote_ip]:[remote_port] SIP/2.0
+      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+      From: test1 <sip:[service]@[local_ip]:[local_port]>;tag=[call_number]
+      To: test <sip:test@[remote_ip]:[remote_port]>[peer_tag_param]
+      Call-ID: [call_id]
+      CSeq: 2 BYE
+      Contact: <sip:test@[local_ip]:[local_port];transport=[transport]>
+      Max-Forwards: 70
+      Subject: Test
+      X-ASTERISK-TOKEN: [ident_key]
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+  <recv response="200" crlf="true">
+  </recv>
+
+  <!-- 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/identify/header_or_ip/test-config.yaml b/tests/channels/pjsip/identify/header_or_ip/test-config.yaml
new file mode 100644
index 0000000..d9e5b79
--- /dev/null
+++ b/tests/channels/pjsip/identify/header_or_ip/test-config.yaml
@@ -0,0 +1,35 @@
+testinfo:
+    summary:     'Tests incoming calls identified by header or source IP'
+    description: |
+        This test covers sending calls to an Asterisk instance
+        identified by a custom header OR by a source IP address.
+        It is expected that the requests are both accepted, by
+        either criteria.
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'sipp.SIPpTestCase'
+
+test-object-config:
+    fail-on-any: True
+    test-iterations:
+        # IPv4 & UDP
+        -
+            scenarios:
+                - { 'key-args': {'scenario': 'nominal.xml', '-i': '127.0.0.2', '-p': '5061', '-s': 's'},
+                    'ordered-args': ['-key', 'ident_key', 'e7657250-07fa-11e7-92f8-1b946c0c7e84'] }
+                - { 'key-args': {'scenario': 'nominal.xml', '-i': '127.0.0.1', '-p': '5062', '-s': 's'},
+                    'ordered-args': ['-key', 'ident_key', 'foobar'] }
+
+
+
+properties:
+    minversion: '14.4.0'
+    dependencies:
+        - sipp :
+            version : 'v3.0'
+        - asterisk : 'app_echo'
+        - asterisk : 'res_pjsip'
+    tags:
+        - pjsip
diff --git a/tests/channels/pjsip/identify/tests.yaml b/tests/channels/pjsip/identify/tests.yaml
index d8ad4d3..43969c1 100644
--- a/tests/channels/pjsip/identify/tests.yaml
+++ b/tests/channels/pjsip/identify/tests.yaml
@@ -1,4 +1,5 @@
 # Enter tests here in the order they should be considered for execution:
 tests:
     - test: 'header'
+    - test: 'header_or_ip'
     - test: 'ordering'

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I9809d20208d7e55732d6382a243e4a6cfd6d972f
Gerrit-PatchSet: 2
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>



More information about the asterisk-code-review mailing list