[svn-commits] gtjoseph: testsuite/asterisk/trunk r5691 - in /asterisk/trunk/tests: ./ phone...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Oct 9 13:03:05 CDT 2014


Author: gtjoseph
Date: Thu Oct  9 13:03:01 2014
New Revision: 5691

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=5691
Log:
testsuite: Initial test for res_phoneprov

This is the first test for res_phoneprov

Tested-by: George Joseph
Review: https://reviewboard.asterisk.org/r/4061/

Added:
    asterisk/trunk/tests/phoneprov/
    asterisk/trunk/tests/phoneprov/res_phoneprov/
    asterisk/trunk/tests/phoneprov/res_phoneprov/cfgbase.txt   (with props)
    asterisk/trunk/tests/phoneprov/res_phoneprov/cfgex.txt   (with props)
    asterisk/trunk/tests/phoneprov/res_phoneprov/configs/
    asterisk/trunk/tests/phoneprov/res_phoneprov/configs/ast1/
    asterisk/trunk/tests/phoneprov/res_phoneprov/configs/ast1/phoneprov.conf   (with props)
    asterisk/trunk/tests/phoneprov/res_phoneprov/configs/ast1/users.conf   (with props)
    asterisk/trunk/tests/phoneprov/res_phoneprov/run-test   (with props)
    asterisk/trunk/tests/phoneprov/res_phoneprov/test-config.yaml   (with props)
    asterisk/trunk/tests/phoneprov/tests.yaml   (with props)
Modified:
    asterisk/trunk/tests/tests.yaml

Added: asterisk/trunk/tests/phoneprov/res_phoneprov/cfgbase.txt
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/phoneprov/res_phoneprov/cfgbase.txt?view=auto&rev=5691
==============================================================================
--- asterisk/trunk/tests/phoneprov/res_phoneprov/cfgbase.txt (added)
+++ asterisk/trunk/tests/phoneprov/res_phoneprov/cfgbase.txt Thu Oct  9 13:03:01 2014
@@ -1,0 +1,15 @@
+profile_variable: ${PROFILE_VARIABLE}
+context: ${SIPPEER(${CALLERID},context)}
+mac: ${MAC}
+profile: ${PROFILE}
+username: ${USERNAME}
+display_name: ${DISPLAY_NAME}
+secret: ${SECRET}
+server: ${SERVER}
+server_port: ${SERVER_PORT}
+line: ${LINE}
+linekeys: ${LINEKEYS}
+timezone: ${TIMEZONE}
+tzoffset: ${TZOFFSET}
+extension_length: ${EXTENSION_LENGTH}
+${PP_EACH_EXTENSION(${MAC},cfgex.txt)}

Propchange: asterisk/trunk/tests/phoneprov/res_phoneprov/cfgbase.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/phoneprov/res_phoneprov/cfgbase.txt
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision URL

Propchange: asterisk/trunk/tests/phoneprov/res_phoneprov/cfgbase.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/phoneprov/res_phoneprov/cfgex.txt
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/phoneprov/res_phoneprov/cfgex.txt?view=auto&rev=5691
==============================================================================
--- asterisk/trunk/tests/phoneprov/res_phoneprov/cfgex.txt (added)
+++ asterisk/trunk/tests/phoneprov/res_phoneprov/cfgex.txt Thu Oct  9 13:03:01 2014
@@ -1,0 +1,3 @@
+username_${LINE}: ${USERNAME}
+display_name_${LINE}: ${DISPLAY_NAME}
+context_${LINE}: ${SIPPEER(${CALLERID},context)}

Propchange: asterisk/trunk/tests/phoneprov/res_phoneprov/cfgex.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/phoneprov/res_phoneprov/cfgex.txt
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision URL

Propchange: asterisk/trunk/tests/phoneprov/res_phoneprov/cfgex.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/phoneprov/res_phoneprov/configs/ast1/phoneprov.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/phoneprov/res_phoneprov/configs/ast1/phoneprov.conf?view=auto&rev=5691
==============================================================================
--- asterisk/trunk/tests/phoneprov/res_phoneprov/configs/ast1/phoneprov.conf (added)
+++ asterisk/trunk/tests/phoneprov/res_phoneprov/configs/ast1/phoneprov.conf Thu Oct  9 13:03:01 2014
@@ -1,0 +1,8 @@
+[general]
+serverport=41060
+default_profile=profile1
+
+[profile1]
+setvar = PROFILE_VARIABLE = this is a test
+setvar = TIMEZONE = America/Denver
+cfgbase${MAC}.txt => cfgbase.txt,text/plain

Propchange: asterisk/trunk/tests/phoneprov/res_phoneprov/configs/ast1/phoneprov.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/phoneprov/res_phoneprov/configs/ast1/phoneprov.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision URL

Propchange: asterisk/trunk/tests/phoneprov/res_phoneprov/configs/ast1/phoneprov.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/phoneprov/res_phoneprov/configs/ast1/users.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/phoneprov/res_phoneprov/configs/ast1/users.conf?view=auto&rev=5691
==============================================================================
--- asterisk/trunk/tests/phoneprov/res_phoneprov/configs/ast1/users.conf (added)
+++ asterisk/trunk/tests/phoneprov/res_phoneprov/configs/ast1/users.conf Thu Oct  9 13:03:01 2014
@@ -1,0 +1,42 @@
+[general]
+localextenlength = 3
+
+[6000]
+fullname = Joe User 6000
+username = 6000
+email = joe at foo.bar
+secret = 1234
+hasvoicemail = no
+vmsecret = 1234
+hassip = yes
+hasiax = no
+hash323 = no
+hasmanager = no
+callwaiting = no
+context = defctx1
+macaddress = 112233445566
+profile = profile1
+autoprov = yes
+LINEKEYS = 2
+linenumber = 1
+cid_number = 6000
+
+[6001]
+fullname = Joe User 6001
+username = 6001
+email = joe at foo.bar
+secret = 1234
+hasvoicemail = no
+vmsecret = 1234
+hassip = yes
+hasiax = no
+hash323 = no
+hasmanager = no
+callwaiting = no
+context = defctx2
+macaddress = 112233445566
+profile = profile1
+autoprov = yes
+LINEKEYS = 2
+linenumber = 2
+cid_number = 6001

Propchange: asterisk/trunk/tests/phoneprov/res_phoneprov/configs/ast1/users.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/phoneprov/res_phoneprov/configs/ast1/users.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision URL

Propchange: asterisk/trunk/tests/phoneprov/res_phoneprov/configs/ast1/users.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/phoneprov/res_phoneprov/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/phoneprov/res_phoneprov/run-test?view=auto&rev=5691
==============================================================================
--- asterisk/trunk/tests/phoneprov/res_phoneprov/run-test (added)
+++ asterisk/trunk/tests/phoneprov/res_phoneprov/run-test Thu Oct  9 13:03:01 2014
@@ -1,0 +1,78 @@
+#!/usr/bin/env python
+"""Test res_phoneprov basic ops
+
+Copyright (C) 2014, Fairview 5 Engineering, LLC
+George Joseph <george.joseph at fairview5.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+"""
+
+import os
+import sys
+import logging
+
+from twisted.internet import reactor
+from email.parser import HeaderParser
+from shutil import copy
+from httplib import *
+sys.path.append("lib/python")
+from asterisk.test_case import TestCase
+
+LOGGER = logging.getLogger(__name__)
+PATH = os.path.dirname(os.path.realpath(__file__))
+
+class ResPhoneprovTest(TestCase):
+    def __init__(self):
+        super(ResPhoneprovTest, self).__init__()
+        self.reactor_timeout = 15
+        self.create_asterisk()
+
+    def run(self):
+        super(ResPhoneprovTest, self).run()
+        self.passed = True
+
+        try:
+            copy("%s/cfgbase.txt" % PATH,
+                "%s/var/lib/asterisk/phoneprov/cfgbase.txt" % self.ast[0].base)
+            copy("%s/cfgex.txt" % PATH,
+                "%s/var/lib/asterisk/phoneprov/cfgex.txt" % self.ast[0].base)
+            self.con = HTTPConnection("127.0.0.1:8088")
+            self.con.request("GET", "/phoneprov/cfgbase112233445566.txt")
+            self.res = self.con.getresponse()
+            self.data = self.res.read()
+        except:
+            self.stop_reactor()
+            self.passed = False
+            raise
+
+        if self.res.status != 200:
+            LOGGER.error("Status code was %d\n%s." % (self.res.status, self.data))
+            self.passed = False
+            self.stop_reactor()
+            return
+
+        response = HeaderParser().parsestr(self.data)
+
+        for name, value in self.test_config.config['substitutions'].items():
+            if response.get(name) != value:
+                LOGGER.error("'%s' was '%s' instead of '%s'" % (name, response.get(name), value))
+                self.passed = False
+                break
+
+        if not self.passed:
+            LOGGER.error(response)
+
+        self.stop_reactor()
+
+def main():
+    test = ResPhoneprovTest()
+    reactor.run()
+
+    if not test.passed:
+        return 1
+
+    return 0
+
+if __name__ == "__main__":
+    sys.exit(main() or 0)

Propchange: asterisk/trunk/tests/phoneprov/res_phoneprov/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/phoneprov/res_phoneprov/run-test
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision URL

Propchange: asterisk/trunk/tests/phoneprov/res_phoneprov/run-test
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/phoneprov/res_phoneprov/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/phoneprov/res_phoneprov/test-config.yaml?view=auto&rev=5691
==============================================================================
--- asterisk/trunk/tests/phoneprov/res_phoneprov/test-config.yaml (added)
+++ asterisk/trunk/tests/phoneprov/res_phoneprov/test-config.yaml Thu Oct  9 13:03:01 2014
@@ -1,0 +1,27 @@
+testinfo:
+    summary:     'Test res_phoneprov basic ops'
+    description: |
+        'Test res_phoneprov basic ops by setting up a user in users.conf and insuring
+        that proper template substitution is done.
+
+properties:
+    minversion: '12.7.0'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+        - python : 'httplib'
+        - python : 'email'
+        - asterisk : 'chan_sip'
+        - asterisk : 'res_phoneprov'
+
+substitutions:
+    profile_variable: "this is a test"
+    context: "defctx1"
+    username: "6000"
+    server: "127.0.0.1"
+    server_port: "41060"
+    extension_length: "3"
+    timezone: "America/Denver"
+    tzoffset: "-25200"
+    context_1: "defctx1"
+    context_2: "defctx2"

Propchange: asterisk/trunk/tests/phoneprov/res_phoneprov/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/phoneprov/res_phoneprov/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision URL

Propchange: asterisk/trunk/tests/phoneprov/res_phoneprov/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/phoneprov/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/phoneprov/tests.yaml?view=auto&rev=5691
==============================================================================
--- asterisk/trunk/tests/phoneprov/tests.yaml (added)
+++ asterisk/trunk/tests/phoneprov/tests.yaml Thu Oct  9 13:03:01 2014
@@ -1,0 +1,3 @@
+# Enter tests here in the order they should be considered for execution:
+tests:
+    - test: 'res_phoneprov'

Propchange: asterisk/trunk/tests/phoneprov/tests.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/phoneprov/tests.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision URL

Propchange: asterisk/trunk/tests/phoneprov/tests.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/trunk/tests/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/tests.yaml?view=diff&rev=5691&r1=5690&r2=5691
==============================================================================
--- asterisk/trunk/tests/tests.yaml (original)
+++ asterisk/trunk/tests/tests.yaml Thu Oct  9 13:03:01 2014
@@ -18,6 +18,7 @@
     - dir: 'agi'
     - dir: 'asyncagi'
     - dir: 'pbx'
+    - dir: 'phoneprov'
     - test: 'predial'
     - dir: 'hangup'
     - dir: 'fax'




More information about the svn-commits mailing list