[asterisk-commits] rmudgett: testsuite/asterisk/trunk r3177 - in /asterisk/trunk/tests/channels/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Apr 12 10:41:27 CDT 2012


Author: rmudgett
Date: Thu Apr 12 10:41:23 2012
New Revision: 3177

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3177
Log:
Add AMI action MessageSend test for SIP MESSAGE message.

Added:
    asterisk/trunk/tests/channels/SIP/message_send_ami/
    asterisk/trunk/tests/channels/SIP/message_send_ami/configs/
    asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/
    asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/extensions.conf   (with props)
    asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/manager.users.conf.inc   (with props)
    asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/sip.conf   (with props)
    asterisk/trunk/tests/channels/SIP/message_send_ami/run-test   (with props)
    asterisk/trunk/tests/channels/SIP/message_send_ami/sipp/
    asterisk/trunk/tests/channels/SIP/message_send_ami/sipp/message_recv.xml   (with props)
    asterisk/trunk/tests/channels/SIP/message_send_ami/test-config.yaml   (with props)
Modified:
    asterisk/trunk/tests/channels/SIP/tests.yaml

Added: asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/extensions.conf?view=auto&rev=3177
==============================================================================
--- asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/extensions.conf Thu Apr 12 10:41:23 2012
@@ -1,0 +1,7 @@
+[default]
+
+exten => _.,1,NoOp(ERROR: THIS SHOULD NOT BE EXECUTED)
+
+[not_default]
+
+exten => _.,1,NoOp()

Propchange: asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/manager.users.conf.inc
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/manager.users.conf.inc?view=auto&rev=3177
==============================================================================
--- asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/manager.users.conf.inc (added)
+++ asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/manager.users.conf.inc Thu Apr 12 10:41:23 2012
@@ -1,0 +1,1 @@
+write = system,call,agent,user,config,command,reporting,originate,message

Propchange: asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/manager.users.conf.inc
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/manager.users.conf.inc
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/manager.users.conf.inc
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/sip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/sip.conf?view=auto&rev=3177
==============================================================================
--- asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/sip.conf (added)
+++ asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/sip.conf Thu Apr 12 10:41:23 2012
@@ -1,0 +1,21 @@
+[general]
+
+sipdebug=yes
+accept_outofcall_message = yes
+auth_message_requests = yes
+
+[user2]
+type=peer
+host=127.0.0.1
+port=5062
+context=not_default
+username=user2
+secret=blah
+
+[fred]
+type=friend
+;host=dynamic
+callerid="Johnny Appleseed" <9876>        ; Full caller ID, to override the phones config
+username=fred
+secret=blah
+

Propchange: asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/sip.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/sip.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/SIP/message_send_ami/configs/ast1/sip.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/SIP/message_send_ami/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/message_send_ami/run-test?view=auto&rev=3177
==============================================================================
--- asterisk/trunk/tests/channels/SIP/message_send_ami/run-test (added)
+++ asterisk/trunk/tests/channels/SIP/message_send_ami/run-test Thu Apr 12 10:41:23 2012
@@ -1,0 +1,83 @@
+#!/usr/bin/env python
+# vim: sw=3 et:
+'''
+Copyright (C) 2012, 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 logging
+
+
+from twisted.internet import reactor
+
+sys.path.append("lib/python")
+
+from asterisk.sipp import SIPpScenario
+from asterisk.TestCase import TestCase
+
+"""
+The TestCase class will initialize the python logger - creating a
+logger here will log under the '__main__' namespace
+"""
+logger = logging.getLogger(__name__)
+
+TEST_DIR = os.path.dirname(os.path.realpath(__file__))
+
+class AMIActionMessageSend(TestCase):
+    """
+    Test handling of AMI MessageSend action sending SIP MESSAGE
+    """
+    def __init__(self):
+        super(AMIActionMessageSend, self).__init__()
+        self.create_asterisk()
+        self.passed = False     # This is the default but it does not hurt to be explicit.
+        sipp_scenario = { 'scenario':'message_recv.xml', '-p':'5062' }
+        self.scenario = SIPpScenario(TEST_DIR, sipp_scenario)
+
+    def run(self):
+        super(AMIActionMessageSend, self).run()
+        self.create_ami_factory()
+
+    def ami_connect(self, ami):
+        """
+        This method is called by the StarPY manager class when AMI connects to Asterisk
+
+        Keyword Arguments:
+        ami    -    The StarPY manager object that connected
+        """
+        def __check_result(result):
+            self.passed = result.passed
+            self.stop_reactor()
+
+        # There is a race between starting SIPp and sending the SIP MESSAGE
+        # being sent by MessageSend.  Fortunately, we don't care because SIP
+        # will retransmit the MESSAGE so SIPp can catch it on the next go
+        # round.
+        logger.debug("Starting SIP scenario")
+        deferred = self.scenario.run()
+        deferred.addCallback(__check_result)
+
+        logger.debug("Sending AMI action MessageSend")
+        ami_action = { "Action":"MessageSend", "To":"sip:user2", "From":"fred", "Variable":"X-Custom-Header=Custom shopping", "Body":"Watson, come here." }
+        ami.sendDeferred(ami_action).addCallback(ami.errorUnlessResponse)
+
+def main():
+    """
+    Main entry point for the test.
+    """
+
+    test = AMIActionMessageSend()
+    reactor.run()
+
+    if not test.passed:
+        return 1
+
+    return 0
+
+if __name__ == "__main__":
+   sys.exit(main() or 0)

Propchange: asterisk/trunk/tests/channels/SIP/message_send_ami/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/SIP/message_send_ami/run-test
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/tests/channels/SIP/message_send_ami/run-test
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/SIP/message_send_ami/run-test
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/SIP/message_send_ami/sipp/message_recv.xml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/message_send_ami/sipp/message_recv.xml?view=auto&rev=3177
==============================================================================
--- asterisk/trunk/tests/channels/SIP/message_send_ami/sipp/message_recv.xml (added)
+++ asterisk/trunk/tests/channels/SIP/message_send_ami/sipp/message_recv.xml Thu Apr 12 10:41:23 2012
@@ -1,0 +1,64 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Authenticated MESSAGE send and receive from Johnny Appleseed">
+  <recv request="MESSAGE" crlf="true">
+    <action>
+      <!-- Check that the From header is what we expect. -->
+      <!-- NOTE: The regexp action must assign_to a variable and that variable must be used. -->
+      <ereg regexp=".*" search_in="hdr" header="From:" check_it="true" assign_to="1" />
+      <log message="Received MESSAGE From header: [$1]." />
+      <ereg regexp=" \"Johnny Appleseed\" <sip:9876@" search_in="hdr" header="From:" check_it="true" assign_to="2" />
+      <log message="Using assigned value because I must: [$2]." />
+      <!-- Check that the X-Custom-Header header is what we expect. -->
+      <ereg regexp=".*" search_in="hdr" header="X-Custom-Header:" check_it="true" assign_to="1" />
+      <log message="Received MESSAGE X-Custom-Header header: [$1]." />
+      <ereg regexp="Custom shopping" search_in="hdr" header="X-Custom-Header:" check_it="true" assign_to="2" />
+      <log message="Using assigned value because I must: [$2]." />
+    </action>
+  </recv>
+
+  <send>
+    <![CDATA[
+      SIP/2.0 401 Unauthorized
+      [last_Via:]
+      [last_From:]
+      [last_To:];tag=[call_number]
+      [last_Call-ID:]
+      [last_CSeq:]
+      WWW-Authenticate: digest realm="test",stale=true
+
+    ]]>
+  </send>
+
+  <recv request="MESSAGE" crlf="true">
+    <action>
+      <!-- Check that the From header is what we expect. -->
+      <!-- NOTE: The regexp action must assign_to a variable and that variable must be used. -->
+      <ereg regexp=".*" search_in="hdr" header="From:" check_it="true" assign_to="1" />
+      <log message="Received MESSAGE From header: [$1]." />
+      <ereg regexp=" \"Johnny Appleseed\" <sip:9876@" search_in="hdr" header="From:" check_it="true" assign_to="2" />
+      <log message="Using assigned value because I must: [$2]." />
+      <!-- Check that the X-Custom-Header header is what we expect. -->
+      <ereg regexp=".*" search_in="hdr" header="X-Custom-Header:" check_it="true" assign_to="1" />
+      <log message="Received MESSAGE X-Custom-Header header: [$1]." />
+      <ereg regexp="Custom shopping" search_in="hdr" header="X-Custom-Header:" check_it="true" assign_to="2" />
+      <log message="Using assigned value because I must: [$2]." />
+    </action>
+  </recv>
+
+  <send>
+    <![CDATA[
+      SIP/2.0 202 Accepted
+      [last_Via:]
+      [last_From:]
+      [last_To:];tag=[call_number]
+      [last_Call-ID:]
+      [last_CSeq:]
+      Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
+      Supported: replaces, timer
+      Content-Length: 0
+
+    ]]>
+  </send>
+</scenario>

Propchange: asterisk/trunk/tests/channels/SIP/message_send_ami/sipp/message_recv.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/SIP/message_send_ami/sipp/message_recv.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/SIP/message_send_ami/sipp/message_recv.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/SIP/message_send_ami/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/message_send_ami/test-config.yaml?view=auto&rev=3177
==============================================================================
--- asterisk/trunk/tests/channels/SIP/message_send_ami/test-config.yaml (added)
+++ asterisk/trunk/tests/channels/SIP/message_send_ami/test-config.yaml Thu Apr 12 10:41:23 2012
@@ -1,0 +1,17 @@
+testinfo:
+    skip : 'Must wait until mmichelson's trunk-digiumphones branch is merged.'
+    summary: 'Test handling an AMI MessageSend action'
+    description: |
+        This tests the AMI action MessageSend to see if it sends a SIP MESSAGE.
+
+properties:
+    minversion: '11'
+    dependencies:
+        - sipp :
+            version : 'v3.0'
+    testconditions:
+        - name: 'threads'
+          ignoredThreads:
+            - 'autoservice_run'
+    tags:
+        - SIP

Propchange: asterisk/trunk/tests/channels/SIP/message_send_ami/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/SIP/message_send_ami/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/SIP/message_send_ami/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/trunk/tests/channels/SIP/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/tests.yaml?view=diff&rev=3177&r1=3176&r2=3177
==============================================================================
--- asterisk/trunk/tests/channels/SIP/tests.yaml (original)
+++ asterisk/trunk/tests/channels/SIP/tests.yaml Thu Apr 12 10:41:23 2012
@@ -28,6 +28,7 @@
     - test: 'message_unauth_from'
     - test: 'message_auth'
     - test: 'message_auth_cust_hdr'
+    - test: 'message_send_ami'
     - test: 'message_from_call'
     - test: 'handle_response_address_incomplete'
     - test: 'realtime_sipregs'




More information about the asterisk-commits mailing list