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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jun 20 15:21:07 CDT 2011


Author: rmudgett
Date: Mon Jun 20 15:21:04 2011
New Revision: 1657

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1657
Log:
Initial test.  Test just does a plain SIP call.

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

Added: asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast1/extensions.conf?view=auto&rev=1657
==============================================================================
--- asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast1/extensions.conf (added)
+++ asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast1/extensions.conf Mon Jun 20 15:21:04 2011
@@ -1,0 +1,8 @@
+[general]
+
+[globals]
+
+[siptest1]
+
+exten => 1000,1,Answer()
+exten => 1000,n,AGI(agi://127.0.0.1:4573)

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

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

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

Added: asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast1/manager.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast1/manager.conf?view=auto&rev=1657
==============================================================================
--- asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast1/manager.conf (added)
+++ asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast1/manager.conf Mon Jun 20 15:21:04 2011
@@ -1,0 +1,10 @@
+[general]
+enabled = yes
+port = 5038
+bindaddr = 127.0.0.1
+
+[user]
+secret = mysecret
+read = system,call,log,verbose,agent,user,config,dtmf,reporting,cdr,dialplan
+write = system,call,agent,user,config,command,reporting,originate
+

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

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

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

Added: asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast1/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast1/sip.conf?view=auto&rev=1657
==============================================================================
--- asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast1/sip.conf (added)
+++ asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast1/sip.conf Mon Jun 20 15:21:04 2011
@@ -1,0 +1,47 @@
+[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)
+
+;encryption=no                  ; 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.
+
+[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
+
+[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/sip_srtp/configs/ast1/sip.conf
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Added: asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast2/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast2/extensions.conf?view=auto&rev=1657
==============================================================================
--- asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast2/extensions.conf (added)
+++ asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast2/extensions.conf Mon Jun 20 15:21:04 2011
@@ -1,0 +1,8 @@
+[general]
+
+[globals]
+
+[siptest2]
+
+exten => 2000,1,Answer()
+exten => 2000,n,AGI(agi://127.0.0.1:4573)

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

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

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

Added: asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast2/manager.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast2/manager.conf?view=auto&rev=1657
==============================================================================
--- asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast2/manager.conf (added)
+++ asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast2/manager.conf Mon Jun 20 15:21:04 2011
@@ -1,0 +1,10 @@
+[general]
+enabled = yes
+port = 5039
+bindaddr = 127.0.0.1
+
+[user]
+secret = mysecret
+read = system,call,log,verbose,agent,user,config,dtmf,reporting,cdr,dialplan
+write = system,call,agent,user,config,command,reporting,originate
+

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

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

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

Added: asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast2/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast2/sip.conf?view=auto&rev=1657
==============================================================================
--- asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast2/sip.conf (added)
+++ asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/configs/ast2/sip.conf Mon Jun 20 15:21:04 2011
@@ -1,0 +1,48 @@
+[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)
+
+;encryption=no                  ; 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.
+
+[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
+
+[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/sip_srtp/configs/ast2/sip.conf
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

Added: asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/run-test?view=auto&rev=1657
==============================================================================
--- asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/run-test (added)
+++ asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/run-test Mon Jun 20 15:21:04 2011
@@ -1,0 +1,112 @@
+#!/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 optparse import OptionParser
+from twisted.application import service, internet
+from twisted.internet import reactor, defer
+from starpy import fastagi
+
+sys.path.append("lib/python")
+from asterisk.asterisk import Asterisk
+from asterisk.version import AsteriskVersion
+
+workingdir = "/tmp/asterisk-testsuite/channels/SIP/sip_srtp"
+testdir = "tests/channels/SIP/sip_srtp"
+
+
+class SIPCallTest:
+    def __init__(self, argv):
+        self.chan1_connected = False
+        self.chan2_connected = False
+        self.srtp_connected = False
+        self.f = fastagi.FastAGIFactory(self.fastagi_func)
+        reactor.listenTCP(4573, self.f, 50, '127.0.0.1')
+        reactor.callWhenRunning(self.run)
+
+        parser = OptionParser()
+        parser.add_option("-v", "--version", dest="ast_version",
+                          help="Asterisk version string")
+        parser.add_option("-n", dest="test_name",
+                help="Test name")
+
+        (options, args) = parser.parse_args(argv)
+        self.ast_version = AsteriskVersion(options.ast_version)
+
+        print "Creating Asterisk instances ..."
+
+        self.ast1 = Asterisk(base=workingdir)
+        self.ast1.install_configs("%s/configs/ast1" % (testdir))
+
+        self.ast2 = Asterisk(base=workingdir)
+        self.ast2.install_configs("%s/configs/ast2" % (testdir))
+
+    def fastagi_func(self, agi):
+        sequence = fastagi.InSequence()
+        def get_channel(c):
+            print "Connection received for %s ..." % c
+            if c.split("-")[0] == "SIP/127.0.0.1:5061":
+                # Outgoing call on Ast1
+                self.chan1_connected = True
+            elif c.split("-")[0] == "SIP/1000":
+                # Incoming call on Ast2
+                self.chan2_connected = True
+        agi.getVariable("CHANNEL").addCallback(get_channel)
+        #BUGBUG need to check if connected with SRTP
+        self.srtp_connected = True
+        sequence.append(agi.execute, "Wait", "5")
+        sequence.append(agi.hangup)
+        sequence.append(agi.finish)
+
+    def stop_reactor(self):
+        print "Stopping Reactor ..."
+        if reactor.running:
+            reactor.stop()
+
+    def start_asterisk(self):
+        print "Starting Asterisk instances ..."
+        self.ast1.start()
+        self.ast2.start()
+
+    def stop_asterisk(self):
+        print "Stopping Asterisk instances ..."
+        self.ast1.stop()
+        self.ast2.stop()
+
+    def run(self):
+        self.start_asterisk()
+
+        reactor.callLater(20, self.stop_reactor)
+
+        self.ast1.cli_exec("sip set debug on")
+        self.ast2.cli_exec("sip set debug on")
+
+        #self.ast1.cli_exec("originate SIP/2000 extension 1000 at siptest")
+        #self.ast1.cli_exec("originate SIP/2000!2000 extension 1000 at siptest")
+        self.ast1.cli_exec("originate SIP/2000 at 127.0.0.1:5061 extension 1000 at siptest1")
+
+
+def main(argv=None):
+    if argv is None:
+        argv = sys.argv
+    test = SIPCallTest(argv)
+    reactor.run()
+    test.stop_asterisk()
+    if test.chan1_connected and test.chan2_connected and test.srtp_connected:
+        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/sip_srtp/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

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

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

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

Added: asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/test-config.yaml?view=auto&rev=1657
==============================================================================
--- asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/test-config.yaml (added)
+++ asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_srtp/test-config.yaml Mon Jun 20 15:21:04 2011
@@ -1,0 +1,12 @@
+testinfo:
+    summary:     'Make sure that we can do a SIP SRTP call'
+    description: |
+        'Establish a SIP call between two asterisk instances and verify
+         that it is connected with SRTP.'
+
+properties:
+    minversion: '1.8'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+

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

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

Propchange: asterisk/team/rmudgett/srtp/tests/channels/SIP/sip_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=1657&r1=1656&r2=1657
==============================================================================
--- asterisk/team/rmudgett/srtp/tests/channels/SIP/tests.yaml (original)
+++ asterisk/team/rmudgett/srtp/tests/channels/SIP/tests.yaml Mon Jun 20 15:21:04 2011
@@ -14,6 +14,7 @@
     - test: 'sip_one_legged_transfer_v6'
     - test: 'sip_register'
     - test: 'sip_channel_params'
+    - test: 'sip_srtp'
     - test: 'message_disabled'
     - test: 'message_unauth'
     - test: 'message_auth'




More information about the asterisk-commits mailing list