[asterisk-commits] Add a nominal/off-nominal test for identify by header (testsuite[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Mar 15 13:32:04 CDT 2017


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

Change subject: Add a nominal/off-nominal test for identify by header
......................................................................


Add a nominal/off-nominal test for identify by header

This patch adds a test that covers both nominal and off-nominal matching
by header. In the nominal scenario, an inbound request is matched
correctly using a SIP header and a matching token. In the off-nominal
scenario, an inbound request is rejected due to having the correct
header but incorrect token value.

ASTERISK-26863

Change-Id: Idd02adba1ea97f146d5cfc37fe5f5d1a0665f45f
---
A tests/channels/pjsip/identify/header/configs/ast1/extensions.conf
A tests/channels/pjsip/identify/header/configs/ast1/pjsip.conf
A tests/channels/pjsip/identify/header/sipp/nominal.xml
A tests/channels/pjsip/identify/header/sipp/off-nominal.xml
A tests/channels/pjsip/identify/header/test-config.yaml
R tests/channels/pjsip/identify/ordering/configs/ast1/extensions.conf
R tests/channels/pjsip/identify/ordering/configs/ast1/pjsip.conf
R tests/channels/pjsip/identify/ordering/configs/ast2/extensions.conf
R tests/channels/pjsip/identify/ordering/configs/ast2/pjsip.conf
R tests/channels/pjsip/identify/ordering/test-config.yaml
A tests/channels/pjsip/identify/tests.yaml
M tests/channels/pjsip/tests.yaml
12 files changed, 218 insertions(+), 1 deletion(-)

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



diff --git a/tests/channels/pjsip/identify/header/configs/ast1/extensions.conf b/tests/channels/pjsip/identify/header/configs/ast1/extensions.conf
new file mode 100644
index 0000000..df819c9
--- /dev/null
+++ b/tests/channels/pjsip/identify/header/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/configs/ast1/pjsip.conf b/tests/channels/pjsip/identify/header/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..c2ef40a
--- /dev/null
+++ b/tests/channels/pjsip/identify/header/configs/ast1/pjsip.conf
@@ -0,0 +1,21 @@
+[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
diff --git a/tests/channels/pjsip/identify/header/sipp/nominal.xml b/tests/channels/pjsip/identify/header/sipp/nominal.xml
new file mode 100644
index 0000000..f8018a9
--- /dev/null
+++ b/tests/channels/pjsip/identify/header/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/sipp/off-nominal.xml b/tests/channels/pjsip/identify/header/sipp/off-nominal.xml
new file mode 100644
index 0000000..2d2232c
--- /dev/null
+++ b/tests/channels/pjsip/identify/header/sipp/off-nominal.xml
@@ -0,0 +1,61 @@
+<?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="401" 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>
+
+  <!-- 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/test-config.yaml b/tests/channels/pjsip/identify/header/test-config.yaml
new file mode 100644
index 0000000..9fd6160
--- /dev/null
+++ b/tests/channels/pjsip/identify/header/test-config.yaml
@@ -0,0 +1,37 @@
+testinfo:
+    summary:     'Tests incoming calls identified by header'
+    description: |
+        This test covers sending calls to an Asterisk instance
+        identified by a custom header. If the custom header
+        matches, the call is accepted; if not, Asterisk responds
+        with a 401 (as we 401 any non-matching call for security
+        reasons).
+
+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.1', '-p': '5061', '-s': 's'},
+                    'ordered-args': ['-key', 'ident_key', 'e7657250-07fa-11e7-92f8-1b946c0c7e84'] }
+                - { 'key-args': {'scenario': 'off-nominal.xml', '-i': '127.0.0.1', '-p': '5062', '-s': 's'},
+                    'ordered-args': ['-key', 'ident_key', 'derp'] }
+                - { 'key-args': {'scenario': 'off-nominal.xml', '-i': '127.0.0.1', '-p': '5063', '-s': 's'},
+                    'ordered-args': ['-key', 'ident_key', ''] }
+
+
+properties:
+    minversion: '14.4.0'
+    dependencies:
+        - sipp :
+            version : 'v3.0'
+        - asterisk : 'app_echo'
+        - asterisk : 'res_pjsip'
+    tags:
+        - pjsip
diff --git a/tests/channels/pjsip/endpoint_identify/configs/ast1/extensions.conf b/tests/channels/pjsip/identify/ordering/configs/ast1/extensions.conf
similarity index 100%
rename from tests/channels/pjsip/endpoint_identify/configs/ast1/extensions.conf
rename to tests/channels/pjsip/identify/ordering/configs/ast1/extensions.conf
diff --git a/tests/channels/pjsip/endpoint_identify/configs/ast1/pjsip.conf b/tests/channels/pjsip/identify/ordering/configs/ast1/pjsip.conf
similarity index 100%
rename from tests/channels/pjsip/endpoint_identify/configs/ast1/pjsip.conf
rename to tests/channels/pjsip/identify/ordering/configs/ast1/pjsip.conf
diff --git a/tests/channels/pjsip/endpoint_identify/configs/ast2/extensions.conf b/tests/channels/pjsip/identify/ordering/configs/ast2/extensions.conf
similarity index 100%
rename from tests/channels/pjsip/endpoint_identify/configs/ast2/extensions.conf
rename to tests/channels/pjsip/identify/ordering/configs/ast2/extensions.conf
diff --git a/tests/channels/pjsip/endpoint_identify/configs/ast2/pjsip.conf b/tests/channels/pjsip/identify/ordering/configs/ast2/pjsip.conf
similarity index 100%
rename from tests/channels/pjsip/endpoint_identify/configs/ast2/pjsip.conf
rename to tests/channels/pjsip/identify/ordering/configs/ast2/pjsip.conf
diff --git a/tests/channels/pjsip/endpoint_identify/test-config.yaml b/tests/channels/pjsip/identify/ordering/test-config.yaml
similarity index 100%
rename from tests/channels/pjsip/endpoint_identify/test-config.yaml
rename to tests/channels/pjsip/identify/ordering/test-config.yaml
diff --git a/tests/channels/pjsip/identify/tests.yaml b/tests/channels/pjsip/identify/tests.yaml
new file mode 100644
index 0000000..d8ad4d3
--- /dev/null
+++ b/tests/channels/pjsip/identify/tests.yaml
@@ -0,0 +1,4 @@
+# Enter tests here in the order they should be considered for execution:
+tests:
+    - test: 'header'
+    - test: 'ordering'
diff --git a/tests/channels/pjsip/tests.yaml b/tests/channels/pjsip/tests.yaml
index 086a61a..853a98e 100644
--- a/tests/channels/pjsip/tests.yaml
+++ b/tests/channels/pjsip/tests.yaml
@@ -6,6 +6,7 @@
     - dir: 'configuration'
     - dir: 'dialplan_functions'
     - dir: 'diversion'
+    - dir: 'identify'
     - dir: 'message'
     - dir: 'nat'
     - dir: 'one_touch_recording'
@@ -26,7 +27,6 @@
     - test: 'auth_security_events'
     - test: 'call_pickup'
     - test: 'dtmf_incompatible'
-    - test: 'endpoint_identify'
     - test: 'forward_loop'
     - test: 'handle_options_request'
     - test: 'handle_options_request_drop_options'

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Idd02adba1ea97f146d5cfc37fe5f5d1a0665f45f
Gerrit-PatchSet: 2
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-commits mailing list