[asterisk-commits] rmudgett: branch rmudgett/srtp r1674 - in /asterisk/team/rmudgett/srtp/tests/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jun 23 16:30:07 CDT 2011


Author: rmudgett
Date: Thu Jun 23 16:30:03 2011
New Revision: 1674

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1674
Log:
Add test to see if SIP SRTP call does not connect if called party does not support SRTP.

Added:
    asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/
    asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/
    asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/
    asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/extensions.conf   (with props)
    asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/manager.general.conf.inc   (with props)
    asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/sip.conf   (with props)
    asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/
    asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/extensions.conf   (with props)
    asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/modules.conf   (with props)
    asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/sip.conf   (with props)
    asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/run-test   (with props)
    asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/test-config.yaml   (with props)
Modified:
    asterisk/team/rmudgett/srtp/tests/channels/SIP/tests.yaml

Added: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/extensions.conf?view=auto&rev=1674
==============================================================================
--- asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/extensions.conf (added)
+++ asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/extensions.conf Thu Jun 23 16:30:03 2011
@@ -1,0 +1,11 @@
+[general]
+
+[globals]
+
+[siptest1]
+
+exten => 1000,1,Answer()
+exten => 1000,n,Set(TEST_RESULT=${CHANNEL} secure_media=${CHANNEL(secure_media)})
+exten => 1000,n,AGI(agi://127.0.0.1:4573)
+; Give the other side a chance to get its test result
+exten => 1000,n,Wait(5)

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = 'Author Date Id Revision'

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/manager.general.conf.inc
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/manager.general.conf.inc?view=auto&rev=1674
==============================================================================
--- asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/manager.general.conf.inc (added)
+++ asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/manager.general.conf.inc Thu Jun 23 16:30:03 2011
@@ -1,0 +1,1 @@
+enabled = yes

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/manager.general.conf.inc
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/manager.general.conf.inc
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/manager.general.conf.inc
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/sip.conf?view=auto&rev=1674
==============================================================================
--- asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/sip.conf (added)
+++ asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/sip.conf Thu Jun 23 16:30:03 2011
@@ -1,0 +1,49 @@
+[general]
+context = siptest1
+allowoverlap=no                 ; Disable overlap dialing support. (Default is yes)
+
+udpbindaddr=127.0.0.1:5060      ; IP address to bind UDP listen socket to (0.0.0.0 binds to all)
+                                ; Optionally add a port number, 192.168.1.1:5062 (default is port 5060)
+tcpenable=no                    ; Enable server for incoming TCP connections (default is no)
+tcpbindaddr=0.0.0.0             ; IP address for TCP server to bind to (0.0.0.0 binds to all interfaces)
+
+sipdebug=yes
+
+[authentication]
+
+[sip-trunk](!)
+dtmfmode=rfc2833
+type=friend
+sendrpid=yes
+trustrpid=yes
+canreinvite=yes
+insecure=invite                  ; Do not require authentication of incoming INVITEs
+
+nat=no
+directmedia=no
+
+encryption=yes                  ; Whether to offer SRTP encrypted media (and only SRTP encrypted media)
+                                ; on outgoing calls to a peer. Calls will fail with HANGUPCAUSE=58 if
+                                ; the peer does not support SRTP. Defaults to no.
+
+[my-codecs](!)                    ; a template for my preferred codecs
+disallow=all
+;allow=ilbc
+;allow=g729
+;allow=gsm
+;allow=g723
+allow=ulaw
+
+[1000](sip-trunk,my-codecs)
+callerid="Ast1Name" <1000>
+
+host=127.0.0.1                   ; we have a static but private IP address
+                                 ; No registration allowed
+port=5060
+
+[2000](sip-trunk,my-codecs)
+callerid="Ast2Name" <2000>
+
+host=127.0.0.1                   ; we have a static but private IP address
+                                 ; No registration allowed
+port=5061

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/sip.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/sip.conf
------------------------------------------------------------------------------
    svn:keywords = 'Author Date Id Revision'

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast1/sip.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/extensions.conf?view=auto&rev=1674
==============================================================================
--- asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/extensions.conf (added)
+++ asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/extensions.conf Thu Jun 23 16:30:03 2011
@@ -1,0 +1,11 @@
+[general]
+
+[globals]
+
+[siptest2]
+
+exten => 2000,1,Answer()
+exten => 2000,n,Set(TEST_RESULT=${CHANNEL} secure_media=${CHANNEL(secure_media)})
+exten => 2000,n,AGI(agi://127.0.0.1:4573)
+; Give the other side a chance to get its test result
+exten => 2000,n,Wait(5)

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = 'Author Date Id Revision'

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/modules.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/modules.conf?view=auto&rev=1674
==============================================================================
--- asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/modules.conf (added)
+++ asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/modules.conf Thu Jun 23 16:30:03 2011
@@ -1,0 +1,6 @@
+[modules]
+autoload=yes
+noload => pbx_gtkconsole.so
+load => res_musiconhold.so
+noload => chan_alsa.so
+noload => res_srtp.so

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/modules.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/modules.conf
------------------------------------------------------------------------------
    svn:keywords = 'Author Date Id Revision'

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/modules.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/sip.conf?view=auto&rev=1674
==============================================================================
--- asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/sip.conf (added)
+++ asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/sip.conf Thu Jun 23 16:30:03 2011
@@ -1,0 +1,50 @@
+[general]
+context = siptest2
+allowoverlap=no                 ; Disable overlap dialing support. (Default is yes)
+
+udpbindaddr=127.0.0.1:5061      ; IP address to bind UDP listen socket to (0.0.0.0 binds to all)
+                                ; Optionally add a port number, 192.168.1.1:5062 (default is port 5060)
+tcpenable=no                    ; Enable server for incoming TCP connections (default is no)
+tcpbindaddr=0.0.0.0             ; IP address for TCP server to bind to (0.0.0.0 binds to all interfaces)
+
+sipdebug=yes
+
+[authentication]
+
+[sip-trunk](!)
+dtmfmode=rfc2833
+type=friend
+sendrpid=yes
+trustrpid=yes
+canreinvite=yes
+insecure=invite                  ; Do not require authentication of incoming INVITEs
+
+nat=no
+directmedia=no
+
+;encryption=yes                  ; Whether to offer SRTP encrypted media (and only SRTP encrypted media)
+                                ; on outgoing calls to a peer. Calls will fail with HANGUPCAUSE=58 if
+                                ; the peer does not support SRTP. Defaults to no.
+
+[my-codecs](!)                    ; a template for my preferred codecs
+disallow=all
+;allow=ilbc
+;allow=g729
+;allow=gsm
+;allow=g723
+allow=ulaw
+
+[1000](sip-trunk,my-codecs)
+callerid="Ast1Name" <1000>
+
+host=127.0.0.1                   ; we have a static but private IP address
+                                 ; No registration allowed
+port=5060
+
+[2000](sip-trunk,my-codecs)
+callerid="Ast2Name" <2000>
+
+host=127.0.0.1                   ; we have a static but private IP address
+                                 ; No registration allowed
+port=5061
+

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/sip.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/sip.conf
------------------------------------------------------------------------------
    svn:keywords = 'Author Date Id Revision'

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/configs/ast2/sip.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/run-test?view=auto&rev=1674
==============================================================================
--- asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/run-test (added)
+++ asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/run-test Thu Jun 23 16:30:03 2011
@@ -1,0 +1,110 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2011, Digium, Inc.
+Richard Mudgett <rmudgett at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import os
+import time
+from twisted.internet import reactor, defer
+
+sys.path.append("lib/python")
+from asterisk.TestCase import TestCase
+
+class SIPCallTest(TestCase):
+    def __init__(self, argv):
+        TestCase.__init__(self, argv)
+
+        self.connected_chan1 = False
+        self.connected_chan2 = False
+        self.connected_srtp1 = False
+        self.connected_srtp2 = False
+        self.got_hangup1 = False
+
+        # Safe Reactor timeout values on my own machine could be as low as 1.
+        self.reactor_timeout = 10
+
+        # Create one AGI server
+        self.create_fastagi_factory()
+
+        # Create two Asterisk instances ...
+        self.create_asterisk(2)
+
+    def run(self):
+        TestCase.run(self)
+
+        # Will link up to ami_connect() once the connection is established.
+        self.create_ami_factory()
+
+    # Once the AMI Factory connects to Asterisk, this function fires.
+    def ami_connect(self, ami):
+        TestCase.ami_connect(self, ami)
+        self.ami = ami
+
+        print "AMI - connected"
+        self.ami.registerEvent('Hangup', self.ami_test_hangup)
+
+        print "Initiating test call"
+        self.ast[0].cli_exec(
+            "originate SIP/2000/2000 extension 1000 at siptest1")
+
+    # This is called whenever a hangup event occurs on Ast1.
+    def ami_test_hangup(self, ami, event):
+        print "Received Hangup event from AMI"
+        self.got_hangup1 = True
+
+        # We are done
+        self.stop_reactor()
+
+    # This is called by each Asterisk instance if the call gets connected.
+    def fastagi_connect(self, agi):
+        def get_test_result(val):
+            print "Connection result '%s'" % val
+            if val.split("-")[0] == "SIP/2000":
+                # Outgoing call on Ast1
+                self.connected_chan1 = True
+                if val.split("=")[1] == "1":
+                    self.connected_srtp1 = True
+            elif val.split("-")[0] == "SIP/1000":
+                # Incoming call on Ast2
+                self.connected_chan2 = True
+                if val.split("=")[1] == "1":
+                    self.connected_srtp2 = True
+            else:
+                print "Don't know which side is connected."
+
+        agi.getVariable("TEST_RESULT").addCallback(get_test_result)
+
+    def stop_asterisk(self):
+        TestCase.stop_asterisk(self)
+
+        # Determine if the test passed
+        print "self.connected_chan1:%s" % (self.connected_chan1)
+        print "self.connected_srtp1:%s" % (self.connected_srtp1)
+        print "self.got_hangup1:    %s" % (self.got_hangup1)
+        print "self.connected_chan2:%s" % (self.connected_chan2)
+        print "self.connected_srtp2:%s" % (self.connected_srtp2)
+        if not self.connected_chan1 and not self.connected_srtp1 and self.got_hangup1 and not self.connected_chan2 and not self.connected_srtp2:
+            print "Test passed"
+            self.passed = True
+
+def main(argv=None):
+    if argv is None:
+        argv = sys.argv
+    test = SIPCallTest(argv)
+    test.start_asterisk()
+    reactor.run()
+    test.stop_asterisk()
+    if test.passed:
+        return 0
+    return 1
+
+if __name__ == "__main__":
+    sys.exit(main() or 0)
+
+
+# vim:sw=4:ts=4:expandtab:textwidth=79

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/run-test
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/run-test
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/run-test
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/test-config.yaml?view=auto&rev=1674
==============================================================================
--- asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/test-config.yaml (added)
+++ asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/test-config.yaml Thu Jun 23 16:30:03 2011
@@ -1,0 +1,10 @@
+testinfo:
+    summary: 'If secure media is required and is not available, the call should fail.'
+    description: |
+        'Place a call that has encryption=yes set, but the peer does not support it.'
+
+properties:
+    minversion: '1.8'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = 'Author Date Id Revision'

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/noload_res_srtp_attempt_srtp/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/team/rmudgett/srtp/tests/channels/SIP/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/rmudgett/srtp/tests/channels/SIP/tests.yaml?view=diff&rev=1674&r1=1673&r2=1674
==============================================================================
--- asterisk/team/rmudgett/srtp/tests/channels/SIP/tests.yaml (original)
+++ asterisk/team/rmudgett/srtp/tests/channels/SIP/tests.yaml Thu Jun 23 16:30:03 2011
@@ -16,6 +16,7 @@
     - test: 'sip_channel_params'
     - test: 'sip_srtp'
     - test: 'noload_res_srtp'
+    - test: 'noload_res_srtp_attempt_srtp'
     - test: 'message_disabled'
     - test: 'message_unauth'
     - test: 'message_auth'




More information about the asterisk-commits mailing list