[Asterisk-code-review] pjsip: Add tests for 'ip' option of 'identify by' on endpoint. (testsuite[master])

Jenkins2 asteriskteam at digium.com
Thu Oct 26 17:20:56 CDT 2017


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

Change subject: pjsip: Add tests for 'ip' option of 'identify_by' on endpoint.
......................................................................

pjsip: Add tests for 'ip' option of 'identify_by' on endpoint.

This change adds two tests:

The first test sends various calls to Asterisk that initially match
based on the username portion of the From header. The endpoint
is configured to not allow it to be matched based on username.
Afterwards matching based on IP address occurs to a valid
endpoint.

The second test sends various calls to Asterisk that initially match
based on the source IP address of the INVITE. The endpoint is
configured to not allow it to be matched based on this. Afterwards
matching based on username occurs to a valid endpoint.

In both tests if calls work then the right endpoint has been
matched. If calls fail then the endpoint was matched incorrectly.

ASTERISK-27206

Change-Id: Ieb4e504b0063c723f6cdafd0f78281e33027f7ac
---
A tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_host_only/configs/ast1/extensions.conf
A tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_host_only/configs/ast1/pjsip.conf
A tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_host_only/sipp/playback_with_initial_sdp.xml
A tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_host_only/test-config.yaml
A tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_user_only/configs/ast1/extensions.conf
A tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_user_only/configs/ast1/pjsip.conf
A tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_user_only/sipp/playback_with_initial_sdp.xml
A tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_user_only/test-config.yaml
M tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/tests.yaml
M tests/channels/pjsip/dialplan_functions/pjsip_endpoint/configs/ast1/pjsip.conf
10 files changed, 342 insertions(+), 0 deletions(-)

Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_host_only/configs/ast1/extensions.conf b/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_host_only/configs/ast1/extensions.conf
new file mode 100644
index 0000000..a52330b
--- /dev/null
+++ b/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_host_only/configs/ast1/extensions.conf
@@ -0,0 +1,4 @@
+[default]
+exten => playback,1,Answer()
+same  =>          n,Playback(hello-world)
+same  =>          n,Hangup()
diff --git a/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_host_only/configs/ast1/pjsip.conf b/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_host_only/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..e41c733
--- /dev/null
+++ b/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_host_only/configs/ast1/pjsip.conf
@@ -0,0 +1,51 @@
+[global]
+type=global
+endpoint_identifier_order=username,ip
+
+[local-transport-template](!)
+type=transport
+bind=127.0.0.1
+
+[local-transport6-template](!)
+type=transport
+bind=[::1]
+
+[local-transport-udp](local-transport-template)
+protocol=udp
+
+[local-transport-udp6](local-transport6-template)
+protocol=udp
+
+[endpoint-template-ipv4](!)
+type=endpoint
+context=default
+allow=!all,ulaw,alaw
+media_address=127.0.0.1
+identify_by=ip
+
+[endpoint-template-ipv6](!)
+type=endpoint
+context=default
+allow=!all,ulaw,alaw
+media_address=[::1]
+rtp_ipv6=yes
+identify_by=ip
+
+[alice-ipv4-udp](endpoint-template-ipv4)
+
+[alice-ipv6-udp](endpoint-template-ipv6)
+
+[unknown](endpoint-template-ipv4)
+context=does-not-exist
+
+[identify-template](!)
+type=identify
+
+[alice-identify-ipv4](identify-template)
+endpoint=alice-ipv4-udp
+match=127.0.0.1
+
+[alice-identify-ipv6](identify-template)
+endpoint=alice-ipv6-udp
+match=[::1]
+
diff --git a/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_host_only/sipp/playback_with_initial_sdp.xml b/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_host_only/sipp/playback_with_initial_sdp.xml
new file mode 100644
index 0000000..ea7d68a
--- /dev/null
+++ b/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_host_only/sipp/playback_with_initial_sdp.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="INVITE to playback with SDP in initial INVITE">
+  <send retrans="500">
+    <![CDATA[
+
+      INVITE sip:playback@[remote_ip]:[remote_port] SIP/2.0
+      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+      From: test1 <sip:unknown@[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
+      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:playback@[remote_ip]:[remote_port] SIP/2.0
+      Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+      From: test1 <sip:unknown@[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
+      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>
+
+  <!-- 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/basic_calls/incoming/nominal/unauthed/ident_by_host_only/test-config.yaml b/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_host_only/test-config.yaml
new file mode 100644
index 0000000..a7061f1
--- /dev/null
+++ b/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_host_only/test-config.yaml
@@ -0,0 +1,34 @@
+testinfo:
+    summary:     'Tests incoming calls without authentication matching only on IP address'
+    description: |
+        'Run a SIPp scenario that sends various calls to res_pjsip, which should be matched only on IP address'
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'sipp.SIPpTestCase'
+
+test-object-config:
+    reactor-timeout: 80
+    fail-on-any: False
+    test-iterations:
+        # IPv4 & UDP
+        -
+            scenarios:
+                - { 'key-args': {'scenario': 'playback_with_initial_sdp.xml', '-i': '127.0.0.1', '-p': '5061'} }
+        # IPv6 & UDP
+        -
+            scenarios:
+                 - { 'target': '[::1]', 'key-args': {'scenario': 'playback_with_initial_sdp.xml', '-i': '[::1]', '-p': '5061'} }
+
+properties:
+    minversion: [ '13.19.0', '15.2.0' ]
+    dependencies:
+        - sipp :
+            version : 'v3.0'
+        - asterisk : 'res_pjsip'
+        - asterisk : 'res_pjsip_session'
+        - asterisk : 'chan_pjsip'
+        - asterisk : 'res_pjsip_endpoint_identifier_ip'
+    tags:
+        - pjsip
diff --git a/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_user_only/configs/ast1/extensions.conf b/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_user_only/configs/ast1/extensions.conf
new file mode 100644
index 0000000..a52330b
--- /dev/null
+++ b/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_user_only/configs/ast1/extensions.conf
@@ -0,0 +1,4 @@
+[default]
+exten => playback,1,Answer()
+same  =>          n,Playback(hello-world)
+same  =>          n,Hangup()
diff --git a/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_user_only/configs/ast1/pjsip.conf b/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_user_only/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..a123c13
--- /dev/null
+++ b/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_user_only/configs/ast1/pjsip.conf
@@ -0,0 +1,51 @@
+[local-transport-template](!)
+type=transport
+bind=127.0.0.1
+
+[local-transport6-template](!)
+type=transport
+bind=[::1]
+
+[local-transport-udp](local-transport-template)
+protocol=udp
+
+[local-transport-udp6](local-transport6-template)
+protocol=udp
+
+[endpoint-template-ipv4](!)
+type=endpoint
+context=default
+allow=!all,ulaw,alaw
+media_address=127.0.0.1
+identify_by=username
+transport=local-transport-udp
+
+[endpoint-template-ipv6](!)
+type=endpoint
+context=default
+allow=!all,ulaw,alaw
+media_address=[::1]
+identify_by=username
+transport=local-transport-udp6
+
+[alice-ipv4-udp](endpoint-template-ipv4)
+
+[alice-ipv6-udp](endpoint-template-ipv6)
+
+[alice-ipv4-invalid](endpoint-template-ipv4)
+context=does-not-exist
+
+[alice-ipv6-invalid](endpoint-template-ipv6)
+context=does-not-exist
+
+[identify-template](!)
+type=identify
+
+[alice-identify-ipv4](identify-template)
+endpoint=alice-ipv4-invalid
+match=127.0.0.1
+
+[alice-identify-ipv6](identify-template)
+endpoint=alice-ipv6-invalid
+match=[::1]
+
diff --git a/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_user_only/sipp/playback_with_initial_sdp.xml b/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_user_only/sipp/playback_with_initial_sdp.xml
new file mode 100644
index 0000000..790992f
--- /dev/null
+++ b/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_user_only/sipp/playback_with_initial_sdp.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="INVITE to playback with SDP in initial INVITE">
+  <send retrans="500">
+    <![CDATA[
+
+      INVITE sip:playback@[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
+      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:playback@[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
+      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>
+
+  <!-- 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/basic_calls/incoming/nominal/unauthed/ident_by_user_only/test-config.yaml b/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_user_only/test-config.yaml
new file mode 100644
index 0000000..7b9e7b5
--- /dev/null
+++ b/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/ident_by_user_only/test-config.yaml
@@ -0,0 +1,33 @@
+testinfo:
+    summary:     'Tests incoming calls without authentication matching only based on user'
+    description: |
+        'Run a SIPp scenario that sends various calls to res_pjsip, which should be matched using username only'
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'sipp.SIPpTestCase'
+
+test-object-config:
+    fail-on-any: False
+    test-iterations:
+        -
+            scenarios:
+        # IPv4 & UDP
+                - { 'key-args': {'scenario': 'playback_with_initial_sdp.xml', '-i': '127.0.0.1', '-p': '5061', '-s': 'alice-ipv4-udp'} }
+        # IPv6 & UDP
+        -
+            scenarios:
+                 - { 'target': '[::1]', 'key-args': {'scenario': 'playback_with_initial_sdp.xml', '-i': '[::1]', '-p': '5061', '-s': 'alice-ipv6-udp'} }
+
+properties:
+    minversion: [ '13.19.0', '15.2.0' ]
+    dependencies:
+        - sipp :
+            version : 'v3.0'
+        - asterisk : 'app_dial'
+        - asterisk : 'app_echo'
+        - asterisk : 'app_playback'
+        - asterisk : 'res_pjsip'
+    tags:
+        - pjsip
diff --git a/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/tests.yaml b/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/tests.yaml
index ed1244b..722964b 100644
--- a/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/tests.yaml
+++ b/tests/channels/pjsip/basic_calls/incoming/nominal/unauthed/tests.yaml
@@ -1,5 +1,7 @@
 tests:
     - test: 'ident_by_host'
+    - test: 'ident_by_host_only'
     - test: 'ident_by_user'
+    - test: 'ident_by_user_only'
     - test: 'ident_by_user_drop_options'
     - test: 'ident_by_header'
diff --git a/tests/channels/pjsip/dialplan_functions/pjsip_endpoint/configs/ast1/pjsip.conf b/tests/channels/pjsip/dialplan_functions/pjsip_endpoint/configs/ast1/pjsip.conf
index 9cb6dbb..3baa86b 100644
--- a/tests/channels/pjsip/dialplan_functions/pjsip_endpoint/configs/ast1/pjsip.conf
+++ b/tests/channels/pjsip/dialplan_functions/pjsip_endpoint/configs/ast1/pjsip.conf
@@ -9,6 +9,7 @@
 type=endpoint
 context=default
 allow=!all,ulaw,alaw
+identify_by=username
 
 [aors-template](!)
 type=aor

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

Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ieb4e504b0063c723f6cdafd0f78281e33027f7ac
Gerrit-Change-Number: 6908
Gerrit-PatchSet: 4
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171026/6b932cfe/attachment-0001.html>


More information about the asterisk-code-review mailing list