[Asterisk-code-review] pjsip/srtp not loaded: Add tests which cover when res srtp i... (testsuite[master])

Joshua Colp asteriskteam at digium.com
Fri Nov 11 07:18:13 CST 2016


Joshua Colp has uploaded a new change for review. ( https://gerrit.asterisk.org/4395 )

Change subject: pjsip/srtp_not_loaded: Add tests which cover when res_srtp is not loaded.
......................................................................

pjsip/srtp_not_loaded: Add tests which cover when res_srtp is not loaded.

This change adds tests for res_pjsip SDP negotiation when res_srtp
is not loaded. These tests cover:

Normal non-SRTP call into Asterisk that gets connected.
Optimistic SRTP call into Asterisk that falls back to non-SRTP when connected.
Mandatory SRTP call into Asterisk that is rejected with 488.

ASTERISK-26575

Change-Id: I5a8c648bcc991de8d9d5531329e08bc936e19300
---
A tests/channels/pjsip/srtp_not_loaded/configs/ast1/extensions.conf
A tests/channels/pjsip/srtp_not_loaded/configs/ast1/modules.conf.inc
A tests/channels/pjsip/srtp_not_loaded/configs/ast1/pjsip.conf
A tests/channels/pjsip/srtp_not_loaded/sipp/accept_with_optimistic.xml
A tests/channels/pjsip/srtp_not_loaded/sipp/accept_without_srtp.xml
A tests/channels/pjsip/srtp_not_loaded/sipp/decline_with_required.xml
A tests/channels/pjsip/srtp_not_loaded/test-config.yaml
M tests/channels/pjsip/tests.yaml
8 files changed, 291 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/95/4395/1

diff --git a/tests/channels/pjsip/srtp_not_loaded/configs/ast1/extensions.conf b/tests/channels/pjsip/srtp_not_loaded/configs/ast1/extensions.conf
new file mode 100644
index 0000000..cf3408d
--- /dev/null
+++ b/tests/channels/pjsip/srtp_not_loaded/configs/ast1/extensions.conf
@@ -0,0 +1,4 @@
+[default]
+exten => echo,1,Answer()
+same  =>      n,Echo()
+same  =>      n,Hangup()
diff --git a/tests/channels/pjsip/srtp_not_loaded/configs/ast1/modules.conf.inc b/tests/channels/pjsip/srtp_not_loaded/configs/ast1/modules.conf.inc
new file mode 100644
index 0000000..2af782e
--- /dev/null
+++ b/tests/channels/pjsip/srtp_not_loaded/configs/ast1/modules.conf.inc
@@ -0,0 +1 @@
+noload => res_srtp.so
diff --git a/tests/channels/pjsip/srtp_not_loaded/configs/ast1/pjsip.conf b/tests/channels/pjsip/srtp_not_loaded/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..502ff4a
--- /dev/null
+++ b/tests/channels/pjsip/srtp_not_loaded/configs/ast1/pjsip.conf
@@ -0,0 +1,13 @@
+[local-transport-udp]
+protocol=udp
+type=transport
+bind=127.0.0.1
+
+[endpoint-template](!)
+type=endpoint
+context=default
+allow=!all,ulaw,alaw
+
+[alice](endpoint-template)
+media_encryption_optimistic=yes
+media_encryption=sdes
diff --git a/tests/channels/pjsip/srtp_not_loaded/sipp/accept_with_optimistic.xml b/tests/channels/pjsip/srtp_not_loaded/sipp/accept_with_optimistic.xml
new file mode 100644
index 0000000..86e8de9
--- /dev/null
+++ b/tests/channels/pjsip/srtp_not_loaded/sipp/accept_with_optimistic.xml
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="SRTP Test">
+  <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:alice@[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]
+      Max-Forwards: 70
+      Subject: Test
+      User-Agent: Test
+      Content-Type: application/sdp
+      Content-Length: [len]
+
+      v=0
+      o=guest1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+      s=-
+      c=IN IP[media_ip_type] [media_ip]
+      t=0 0
+      m=audio 6002 RTP/AVP 0
+      a=crypto:1 AES_CM_128_HMAC_SHA1_32 inline:WbTBosdVUZqEb6Htqhn+m3z7wUh4RJVR8nE15GbN
+      a=rtpmap:0 PCMU/8000
+
+    ]]>
+  </send>
+
+  <recv response="100"
+        optional="true">
+  </recv>
+
+  <recv response="180" optional="true">
+  </recv>
+
+  <recv response="183" optional="true">
+  </recv>
+
+  <recv response="200" rtd="true">
+    <action>
+      <ereg regexp="a=crypto:1" search_in="body" check_it="false" assign_to="1"/>
+    </action>
+  </recv>
+  <Reference variables="1"/>
+
+  <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:alice@[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]
+      Max-Forwards: 70
+      Subject: Test
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+  <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:alice@[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]
+      Max-Forwards: 70
+      Subject: Test
+      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/srtp_not_loaded/sipp/accept_without_srtp.xml b/tests/channels/pjsip/srtp_not_loaded/sipp/accept_without_srtp.xml
new file mode 100644
index 0000000..72a12f5
--- /dev/null
+++ b/tests/channels/pjsip/srtp_not_loaded/sipp/accept_without_srtp.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="SRTP Test">
+  <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:alice@[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]
+      Max-Forwards: 70
+      Subject: Test
+      User-Agent: Test
+      Content-Type: application/sdp
+      Content-Length: [len]
+
+      v=0
+      o=guest1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+      s=-
+      c=IN IP[media_ip_type] [media_ip]
+      t=0 0
+      m=audio 6002 RTP/AVP 0
+      a=rtpmap:0 PCMU/8000
+
+    ]]>
+  </send>
+
+  <recv response="100"
+        optional="true">
+  </recv>
+
+  <recv response="180" optional="true">
+  </recv>
+
+  <recv response="183" optional="true">
+  </recv>
+
+  <recv response="200" rtd="true">
+    <action>
+      <ereg regexp="a=crypto:1" search_in="body" check_it_inverse="true" assign_to="1"/>
+    </action>
+  </recv>
+  <Reference variables="1"/>
+
+  <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:alice@[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]
+      Max-Forwards: 70
+      Subject: Test
+      Content-Length: 0
+
+    ]]>
+  </send>
+
+  <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:alice@[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]
+      Max-Forwards: 70
+      Subject: Test
+      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/srtp_not_loaded/sipp/decline_with_required.xml b/tests/channels/pjsip/srtp_not_loaded/sipp/decline_with_required.xml
new file mode 100644
index 0000000..514548a
--- /dev/null
+++ b/tests/channels/pjsip/srtp_not_loaded/sipp/decline_with_required.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Test call declination on use of unknown cryptographic suite">
+  <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:alice@[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]
+      Max-Forwards: 70
+      Subject: Test
+      User-Agent: Test
+      Content-Type: application/sdp
+      Content-Length: [len]
+
+      v=0
+      o=guest1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+      s=-
+      c=IN IP[media_ip_type] [media_ip]
+      t=0 0
+      m=audio 6002 RTP/SAVP 0
+      a=crypto:0 AES_CM_128_HMAC_SHA1_80 inline:qtoB12WnTe19t8vuhcJVRFmoeHhHyF9tcu/4bAkS
+      a=rtpmap:0 PCMU/8000
+
+    ]]>
+  </send>
+
+  <recv response="100"
+        optional="true">
+  </recv>
+
+  <recv response="180" optional="true">
+  </recv>
+
+  <recv response="183" optional="true">
+  </recv>
+
+  <recv response="488" rtd="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/srtp_not_loaded/test-config.yaml b/tests/channels/pjsip/srtp_not_loaded/test-config.yaml
new file mode 100644
index 0000000..c0cc9cd
--- /dev/null
+++ b/tests/channels/pjsip/srtp_not_loaded/test-config.yaml
@@ -0,0 +1,32 @@
+testinfo:
+    summary:     'Tests SDP negotiation when the res_srtp module is not loaded.'
+    description: |
+        'Run a SIPp scenario that tests SDP negotiation scenarios including:
+         * scenario with non-SRTP offer that is accepted
+         * scenario with SRTP offer that is rejected
+         * scenario with optimistic SRTP offer that is accepted
+        '
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'sipp.SIPpTestCase'
+
+test-object-config:
+    test-iterations:
+        -
+            scenarios:
+                - { 'key-args': {'scenario': 'accept_without_srtp.xml', '-i': '127.0.0.1', '-p': '5061'} }
+                - { 'key-args': {'scenario': 'decline_with_required.xml', '-i': '127.0.0.1', '-p': '5062'} }
+                - { 'key-args': {'scenario': 'accept_with_optimistic.xml', '-i': '127.0.0.1', '-p': '5063'} }
+
+properties:
+    minversion: '13.1.0'
+    dependencies:
+        - sipp :
+            version : 'v3.0'
+        - asterisk: 'app_echo'
+        - asterisk: 'res_pjsip'
+        - asterisk: 'res_srtp'
+    tags:
+        - pjsip
diff --git a/tests/channels/pjsip/tests.yaml b/tests/channels/pjsip/tests.yaml
index 3f9ff10..086a61a 100644
--- a/tests/channels/pjsip/tests.yaml
+++ b/tests/channels/pjsip/tests.yaml
@@ -46,4 +46,5 @@
     - test: 'rpid_immediate'
     - test: 'set_var'
     - test: 'srtp_negotiation'
+    - test: 'srtp_not_loaded'
     - test: 'user_eq_phone'

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5a8c648bcc991de8d9d5531329e08bc936e19300
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Joshua Colp <jcolp at digium.com>



More information about the asterisk-code-review mailing list