[asterisk-commits] jrose: testsuite/asterisk/trunk r5977 - in /asterisk/trunk: lib/python/asteri...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Nov 20 10:34:48 CST 2014


Author: jrose
Date: Thu Nov 20 10:34:44 2014
New Revision: 5977

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=5977
Log:
Testsuite: Add contact_acl tests for PJSIP

AST-1418 #close
ASTERISK-24531 #close
Review: https://reviewboard.asterisk.org/r/4169/

Added:
    asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/
    asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/
    asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/configs/
    asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/configs/ast1/
    asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/configs/ast1/pjsip.conf   (with props)
    asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/scenario_generator.py   (with props)
    asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/sipp/
    asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/sipp/register-noauth-denied.xml   (with props)
    asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/sipp/register-noauth-permitted.xml   (with props)
    asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/test-config.yaml   (with props)
    asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/
    asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/configs/
    asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/configs/ast1/
    asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/configs/ast1/pjsip.conf   (with props)
    asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/scenario_generator.py   (with props)
    asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/sipp/
    asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/sipp/register-noauth-denied.xml   (with props)
    asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/sipp/register-noauth-permitted.xml   (with props)
    asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/test-config.yaml   (with props)
    asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/tests.yaml   (with props)
Modified:
    asterisk/trunk/lib/python/asterisk/sipp.py
    asterisk/trunk/lib/python/asterisk/test_config.py
    asterisk/trunk/lib/python/asterisk/test_suite_utils.py
    asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/tests.yaml

Modified: asterisk/trunk/lib/python/asterisk/sipp.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/sipp.py?view=diff&rev=5977&r1=5976&r2=5977
==============================================================================
--- asterisk/trunk/lib/python/asterisk/sipp.py (original)
+++ asterisk/trunk/lib/python/asterisk/sipp.py Thu Nov 20 10:34:44 2014
@@ -12,10 +12,39 @@
 import logging
 import test_suite_utils
 
+from abc import ABCMeta, abstractmethod
 from twisted.internet import reactor, defer, protocol, error
 from test_case import TestCase
 
 LOGGER = logging.getLogger(__name__)
+
+
+class ScenarioGenerator(object):
+    """Scenario Generators provide a generator function for creating scenario
+    sets for use by SIPpTestCase"""
+    __metaclass__ = ABCMeta
+
+    @abstractmethod
+    def generator(self):
+        pass
+
+
+class ConfigScenarioGenerator(ScenarioGenerator):
+    """Default SIPpTestCase Scenario Generator. The generator is initialized
+    with a list of scenarios provided by a list of dictionary objects.
+    """
+
+    def __init__(self, test_iterations):
+        self.test_iterations = test_iterations
+
+    def generator(self):
+        """Generatess scenarios sets by pulling them from the full scenario
+        set list one at a time.
+        """
+        for defined_scenario_set in self.test_iterations:
+            yield defined_scenario_set
+        return
+
 
 class SIPpTestCase(TestCase):
     """A SIPp test object for the pluggable framework.
@@ -55,6 +84,14 @@
         self._test_config = test_config
         self._current_test = 0
         self.scenarios = []
+
+        test_iterations = test_config.get('test-iterations')
+        if test_iterations:
+            self.scenario_generator = ConfigScenarioGenerator(test_iterations)
+        else:
+            # Scenario Generator should be provided by a pluggable module.
+            self.scenario_generator = None
+
         if 'fail-on-any' in self._test_config:
             self._fail_on_any = self._test_config['fail-on-any']
         else:
@@ -62,6 +99,14 @@
 
         self.register_intermediate_obverver(self._handle_scenario_finished)
         self.create_asterisk()
+
+    def register_scenario_generator(self, generator):
+        """Register a scenario generator object instead of using
+        ConfigScenarioGenerator
+
+        generator should be a concrete implementation of ScenarioGenerator
+        """
+        self.scenario_generator = generator
 
     def run(self):
         """Override of the run method.
@@ -156,7 +201,7 @@
             self.stop_reactor()
             return result
 
-        for defined_scenario_set in self._test_config['test-iterations']:
+        for defined_scenario_set in self.scenario_generator.generator():
             scenario_set = defined_scenario_set['scenarios']
             # Build a list of SIPpScenario objects to run in parallel from
             # each set of scenarios in the YAML config
@@ -175,6 +220,12 @@
                                                        target=target))
             self.scenarios.append(sipp_scenarios)
 
+        if len(self.scenarios) == 0:
+            LOGGER.error("No scenarios registered. Test Failed.")
+            self.set_passed(False)
+            self.stop_reactor()
+            return
+
         final_deferred = defer.Deferred()
         final_deferred.addCallback(_final_deferred_callback)
         final_deferred.addCallback(_finish_test)

Modified: asterisk/trunk/lib/python/asterisk/test_config.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/test_config.py?view=diff&rev=5977&r1=5976&r2=5977
==============================================================================
--- asterisk/trunk/lib/python/asterisk/test_config.py (original)
+++ asterisk/trunk/lib/python/asterisk/test_config.py Thu Nov 20 10:34:44 2014
@@ -165,6 +165,21 @@
         except:
             return False
 
+    def depend_ipv4addr(self):
+        """Check that an interface has a bindable ipv4 address (not loopback)
+        """
+        if test_suite_utils.get_bindable_ipv4_addr():
+            return True
+        return False
+
+    def depend_ipv6addr(self):
+        """Check that an interface has a bindable ipv6 address (not loopback,
+           not link-local)
+        """
+        if test_suite_utils.get_bindable_ipv6_addr():
+            return True
+        return False
+
     def depend_pjsuav6(self):
         """This tests if pjsua was compiled with IPv6 support.
 

Modified: asterisk/trunk/lib/python/asterisk/test_suite_utils.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/test_suite_utils.py?view=diff&rev=5977&r1=5976&r2=5977
==============================================================================
--- asterisk/trunk/lib/python/asterisk/test_suite_utils.py (original)
+++ asterisk/trunk/lib/python/asterisk/test_suite_utils.py Thu Nov 20 10:34:44 2014
@@ -109,4 +109,63 @@
         # Integers are literal matches
         return pattern == message
     else:
-        LOGGER.error("Unhandled pattern type %s" % type(pattern))
+        LOGGER.error("Unhandled pattern type %s" % type(pattern))
+
+
+def get_bindable_ipv4_addr():
+    """Attempts to obtain a bindable IPv4 address that isn't loopback
+    """
+    try:
+        import netifaces
+    except:
+        return None
+
+    interfaces = netifaces.interfaces()
+    for interface in interfaces:
+        ifaddresses = netifaces.ifaddresses(interface)
+        ifaddress4 = ifaddresses.get(netifaces.AF_INET)
+
+        if not ifaddress4:
+            continue
+
+        for address in ifaddress4:
+            if address.get('broadcast'):
+                return address.get('addr')
+
+    return None
+
+
+def get_bindable_ipv6_addr():
+    """Attempts to obtain a bindable IPv6 address that isn't loopback
+    or link local
+    """
+    try:
+        import netifaces
+    except:
+        return None
+
+    interfaces = netifaces.interfaces()
+    for interface in interfaces:
+        ifaddresses = netifaces.ifaddresses(interface)
+        ifaddress6 = ifaddresses.get(netifaces.AF_INET6)
+
+        if not ifaddress6:
+            continue
+
+        for address in ifaddress6:
+            addr = address.get('addr')
+            if not addr:
+                continue
+
+            # skip anything containing zone marker (link local)
+            if '%' in addr:
+                continue
+
+            #skip loopback address
+            if addr == '::1':
+                continue
+
+            return addr
+
+    return None
+

Added: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/configs/ast1/pjsip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/configs/ast1/pjsip.conf?view=auto&rev=5977
==============================================================================
--- asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/configs/ast1/pjsip.conf (added)
+++ asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/configs/ast1/pjsip.conf Thu Nov 20 10:34:44 2014
@@ -1,0 +1,90 @@
+[local-transport-template](!)
+type=transport
+bind=127.0.0.1
+
+[local-transport-udp](local-transport-template)
+protocol=udp
+
+[local-transport-tcp](local-transport-template)
+protocol=tcp
+
+[endpoint-template](!)
+type=endpoint
+context=default
+allow=!all,ulaw
+
+[aor-template](!)
+type=aor
+max_contacts=1
+minimum_expiration=5
+default_expiration=30
+
+[alice](endpoint-template)
+aors=alice
+
+[alice](aor-template)
+
+[bob](endpoint-template)
+aors=bob
+
+[bob](aor-template)
+
+[charlie](endpoint-template)
+aors=charlie
+
+[charlie](aor-template)
+
+[carol](endpoint-template)
+aors=carol
+
+[carol](aor-template)
+
+[acl]
+type=acl
+contact_permit=0.0.0.0/0
+contact_deny=127.0.0.1   ; block only the default loopback address
+[local-transport-template](!)
+type=transport
+bind=127.0.0.1
+
+[local-transport-udp](local-transport-template)
+protocol=udp
+
+[local-transport-tcp](local-transport-template)
+protocol=tcp
+
+[endpoint-template](!)
+type=endpoint
+context=default
+allow=!all,ulaw
+
+[aor-template](!)
+type=aor
+max_contacts=1
+minimum_expiration=5
+default_expiration=30
+
+[alice](endpoint-template)
+aors=alice
+
+[alice](aor-template)
+
+[bob](endpoint-template)
+aors=bob
+
+[bob](aor-template)
+
+[charlie](endpoint-template)
+aors=charlie
+
+[charlie](aor-template)
+
+[carol](endpoint-template)
+aors=carol
+
+[carol](aor-template)
+
+[acl]
+type=acl
+contact_permit=0.0.0.0/0
+contact_deny=127.0.0.1   ; block only the default loopback address

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/configs/ast1/pjsip.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/configs/ast1/pjsip.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/configs/ast1/pjsip.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/scenario_generator.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/scenario_generator.py?view=auto&rev=5977
==============================================================================
--- asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/scenario_generator.py (added)
+++ asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/scenario_generator.py Thu Nov 20 10:34:44 2014
@@ -1,0 +1,82 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2014, Digium, Inc.
+Jonathan Rose <jrose at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import logging
+
+sys.path.append("lib/python")
+
+import test_suite_utils
+from sipp import ScenarioGenerator
+
+LOGGER = logging.getLogger(__name__)
+
+
+class IPv4ScenarioGenerator(ScenarioGenerator):
+    """SIPp Scenario Generator - Creates scenarios that originate from an IPv4
+    loopback address and a broadcast capable IPv4 address using UDP and TCP
+    """
+
+    def generator(self):
+        """Determines bindable address and yields the scenario list
+        """
+        using_addr = test_suite_utils.get_bindable_ipv4_addr()
+
+        if not using_addr:
+            LOGGER.error("Failed to find a suitable IPv4 address.")
+            return
+
+        LOGGER.info("Selected ipv4 address: %s" % using_addr)
+
+        yield {'scenarios': [
+            {
+                'key-args': {
+                    'scenario': 'register-noauth-permitted.xml',
+                    '-i': using_addr,
+                    '-p': '5061',
+                    '-s': 'alice'
+                }
+            },
+            {
+                'key-args': {
+                    'scenario': 'register-noauth-permitted.xml',
+                    '-i': using_addr,
+                    '-p': '5062',
+                    '-s': 'bob', '-t': 't1'
+                }
+            },
+            {
+                'key-args': {
+                    'scenario': 'register-noauth-denied.xml',
+                    '-i': '127.0.0.1',
+                    '-p': '5063',
+                    '-s': 'charlie'
+                }
+            },
+            {
+                'key-args': {
+                    'scenario': 'register-noauth-denied.xml',
+                    '-i': '127.0.0.1',
+                    '-p': '5064',
+                    '-s': 'carol', '-t': 't1'
+                }
+            }
+        ]}
+
+        return
+
+
+class ScenarioGeneratorModule(object):
+    """Pluggable module for SIPpTestCase to set the scenario
+    generator to the one provided for this test.
+    """
+    def __init__(self, module_config, test_object):
+        scenario_generator = IPv4ScenarioGenerator()
+        test_object.register_scenario_generator(scenario_generator)
+

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/scenario_generator.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/scenario_generator.py
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/scenario_generator.py
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/scenario_generator.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/sipp/register-noauth-denied.xml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/sipp/register-noauth-denied.xml?view=auto&rev=5977
==============================================================================
--- asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/sipp/register-noauth-denied.xml (added)
+++ asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/sipp/register-noauth-denied.xml Thu Nov 20 10:34:44 2014
@@ -1,0 +1,24 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Basic Sipstone UAC">
+    <send retrans="500">
+        <![CDATA[
+
+        REGISTER sip:[remote_ip]:[remote_port] SIP/2.0
+        Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+        From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+        To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+        Call-ID: [call_id]
+        CSeq: 1 REGISTER
+        Max-Forwards: 70
+        Contact: <sip:[service]@[local_ip]:[local_port]>;transport=[transport]
+        Subject: Performance Test
+        Content-Length: 0
+
+        ]]>
+    </send>
+
+    <recv response="403" rtd="true">
+    </recv>
+</scenario>

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/sipp/register-noauth-denied.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/sipp/register-noauth-denied.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/sipp/register-noauth-denied.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/sipp/register-noauth-permitted.xml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/sipp/register-noauth-permitted.xml?view=auto&rev=5977
==============================================================================
--- asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/sipp/register-noauth-permitted.xml (added)
+++ asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/sipp/register-noauth-permitted.xml Thu Nov 20 10:34:44 2014
@@ -1,0 +1,24 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Basic Sipstone UAC">
+    <send retrans="500">
+        <![CDATA[
+
+        REGISTER sip:[remote_ip]:[remote_port] SIP/2.0
+        Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+        From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+        To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+        Call-ID: [call_id]
+        CSeq: 1 REGISTER
+        Max-Forwards: 70
+        Contact: <sip:[service]@[local_ip]:[local_port]>;transport=[transport]
+        Subject: Performance Test
+        Content-Length: 0
+
+        ]]>
+    </send>
+
+    <recv response="200" rtd="true">
+    </recv>
+</scenario>

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/sipp/register-noauth-permitted.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/sipp/register-noauth-permitted.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/sipp/register-noauth-permitted.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/test-config.yaml?view=auto&rev=5977
==============================================================================
--- asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/test-config.yaml (added)
+++ asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/test-config.yaml Thu Nov 20 10:34:44 2014
@@ -1,0 +1,66 @@
+testinfo:
+    summary: 'Test PJSIP registration from IPV4 addresses when using ACLs'
+    description: |
+        'Tests permit and deny acls against local loopback as well as an
+         address picked from available interfaces provided that one exists.
+         The local loopback address is explicitly denied while other
+         addresses are permitted. This variant of the test uses ipv4.'
+
+test-modules:
+    add-test-to-search-path: 'True'
+    test-object:
+        typename: 'sipp.SIPpTestCase'
+        config-section: test-object-config
+    modules:
+        -
+            typename: 'scenario_generator.ScenarioGeneratorModule'
+        -
+            config-section: 'ami-config'
+            typename: 'ami.AMIEventModule'
+
+test-object-config:
+    fail-on-any: True
+    reactor-timeout: 10
+
+ami-config:
+    -
+        type: 'headermatch' # one for alice
+        id: '0'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'AOR_CONTACT_ADDED'
+                AOR: 'alice'
+        count: '1'
+    -
+        type: 'headermatch' # one for bob
+        id: '0'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'AOR_CONTACT_ADDED'
+                AOR: 'bob'
+        count: '1'
+    -
+        type: 'headermatch' # two total and not more.
+        id: '0'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'AOR_CONTACT_ADDED'
+        count: '2'
+
+properties:
+    minversion: '12.0.0'
+    dependencies:
+        - buildoption: 'TEST_FRAMEWORK'
+        - python: 'twisted'
+        - python: 'starpy'
+        - python: 'netifaces'
+        - sipp:
+            version: 'v3.3'
+        - asterisk: 'res_pjsip'
+        - custom: 'ipv4addr'
+    tags:
+        - pjsip
+        - ACL

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv4/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/configs/ast1/pjsip.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/configs/ast1/pjsip.conf?view=auto&rev=5977
==============================================================================
--- asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/configs/ast1/pjsip.conf (added)
+++ asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/configs/ast1/pjsip.conf Thu Nov 20 10:34:44 2014
@@ -1,0 +1,90 @@
+[local-transport6-template](!)
+type=transport
+bind=[::1]
+
+[local-transport-udp6](local-transport6-template)
+protocol=udp
+
+[local-transport-tcp6](local-transport6-template)
+protocol=tcp
+
+[endpoint-template](!)
+type=endpoint
+context=default
+allow=!all,ulaw
+
+[aor-template](!)
+type=aor
+max_contacts=1
+minimum_expiration=5
+default_expiration=30
+
+[alice](endpoint-template)
+aors=alice
+
+[alice](aor-template)
+
+[bob](endpoint-template)
+aors=bob
+
+[bob](aor-template)
+
+[charlie](endpoint-template)
+aors=charlie
+
+[charlie](aor-template)
+
+[carol](endpoint-template)
+aors=carol
+
+[carol](aor-template)
+
+[acl]
+type=acl
+contact_permit=::0/0
+contact_deny=::1     ; block only the default loopback address
+[local-transport6-template](!)
+type=transport
+bind=[::1]
+
+[local-transport-udp6](local-transport6-template)
+protocol=udp
+
+[local-transport-tcp6](local-transport6-template)
+protocol=tcp
+
+[endpoint-template](!)
+type=endpoint
+context=default
+allow=!all,ulaw
+
+[aor-template](!)
+type=aor
+max_contacts=1
+minimum_expiration=5
+default_expiration=30
+
+[alice](endpoint-template)
+aors=alice
+
+[alice](aor-template)
+
+[bob](endpoint-template)
+aors=bob
+
+[bob](aor-template)
+
+[charlie](endpoint-template)
+aors=charlie
+
+[charlie](aor-template)
+
+[carol](endpoint-template)
+aors=carol
+
+[carol](aor-template)
+
+[acl]
+type=acl
+contact_permit=::0/0
+contact_deny=::1     ; block only the default loopback address

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/configs/ast1/pjsip.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/configs/ast1/pjsip.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/configs/ast1/pjsip.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/scenario_generator.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/scenario_generator.py?view=auto&rev=5977
==============================================================================
--- asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/scenario_generator.py (added)
+++ asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/scenario_generator.py Thu Nov 20 10:34:44 2014
@@ -1,0 +1,90 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2014, Digium, Inc.
+Jonathan Rose <jrose at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import logging
+
+sys.path.append("lib/python")
+
+import test_suite_utils
+from sipp import ScenarioGenerator
+
+LOGGER = logging.getLogger(__name__)
+
+
+class IPv6ScenarioGenerator(ScenarioGenerator):
+    """SIPp Scenario Generator - Creates scenarios that originate from an IPv6
+    loopback address and a bindable non Link-Local address using UDP and TCP
+    """
+
+    def generator(self):
+        """Determines bindable address and yields the scenario list
+        """
+        using_addr = test_suite_utils.get_bindable_ipv6_addr()
+
+        if not using_addr:
+            LOGGER.error("Failed to find a usable address for the test.")
+            return
+
+        using_addr = "[%s]" % using_addr
+
+        LOGGER.info("Selected ipv6 address: %s" % using_addr)
+
+        yield {'scenarios': [
+            {
+                'key-args': {
+                    'scenario': 'register-noauth-permitted.xml',
+                    '-i': using_addr,
+                    '-p': '5061',
+                    '-s': 'alice',
+                    'target': '[::1]'
+                }
+            },
+            {
+                'key-args': {
+                    'scenario': 'register-noauth-permitted.xml',
+                    '-i': using_addr,
+                    '-p': '5062',
+                    '-s': 'bob',
+                    '-t': 't1',
+                    'target': '[::1]'
+                }
+            },
+            {
+                'key-args': {
+                    'scenario': 'register-noauth-denied.xml',
+                    '-i': '[::1]',
+                    '-p': '5063',
+                    '-s': 'charlie',
+                    'target': '[::1]'
+                }
+            },
+            {
+                'key-args': {
+                    'scenario': 'register-noauth-denied.xml',
+                    '-i': '[::1]',
+                    '-p': '5064',
+                    '-s': 'carol',
+                    '-t': 't1',
+                    'target': '[::1]'
+                }
+            }
+        ]}
+
+        return
+
+
+class ScenarioGeneratorModule(object):
+    """Pluggable module for SIPpTestCase to set the scenario
+    generator to the one provided for this test.
+    """
+    def __init__(self, module_config, test_object):
+        scenario_generator = IPv6ScenarioGenerator()
+        test_object.register_scenario_generator(scenario_generator)
+

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/scenario_generator.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/scenario_generator.py
------------------------------------------------------------------------------
    svn:executable = *

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/scenario_generator.py
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/scenario_generator.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/sipp/register-noauth-denied.xml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/sipp/register-noauth-denied.xml?view=auto&rev=5977
==============================================================================
--- asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/sipp/register-noauth-denied.xml (added)
+++ asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/sipp/register-noauth-denied.xml Thu Nov 20 10:34:44 2014
@@ -1,0 +1,24 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Basic Sipstone UAC">
+    <send retrans="500">
+        <![CDATA[
+
+        REGISTER sip:[remote_ip]:[remote_port] SIP/2.0
+        Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+        From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+        To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+        Call-ID: [call_id]
+        CSeq: 1 REGISTER
+        Max-Forwards: 70
+        Contact: <sip:[service]@[local_ip]:[local_port]>;transport=[transport]
+        Subject: Performance Test
+        Content-Length: 0
+
+        ]]>
+    </send>
+
+    <recv response="403" rtd="true">
+    </recv>
+</scenario>

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/sipp/register-noauth-denied.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/sipp/register-noauth-denied.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/sipp/register-noauth-denied.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/sipp/register-noauth-permitted.xml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/sipp/register-noauth-permitted.xml?view=auto&rev=5977
==============================================================================
--- asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/sipp/register-noauth-permitted.xml (added)
+++ asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/sipp/register-noauth-permitted.xml Thu Nov 20 10:34:44 2014
@@ -1,0 +1,24 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Basic Sipstone UAC">
+    <send retrans="500">
+        <![CDATA[
+
+        REGISTER sip:[remote_ip]:[remote_port] SIP/2.0
+        Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+        From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+        To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+        Call-ID: [call_id]
+        CSeq: 1 REGISTER
+        Max-Forwards: 70
+        Contact: <sip:[service]@[local_ip]:[local_port]>;transport=[transport]
+        Subject: Performance Test
+        Content-Length: 0
+
+        ]]>
+    </send>
+
+    <recv response="200" rtd="true">
+    </recv>
+</scenario>

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/sipp/register-noauth-permitted.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/sipp/register-noauth-permitted.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/sipp/register-noauth-permitted.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/test-config.yaml?view=auto&rev=5977
==============================================================================
--- asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/test-config.yaml (added)
+++ asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/test-config.yaml Thu Nov 20 10:34:44 2014
@@ -1,0 +1,66 @@
+testinfo:
+    summary: 'Test PJSIP registration from IPV6 addresses when using ACLs'
+    description: |
+        'Tests permit and deny acls against local loopback as well as an
+         address picked from available interfaces provided that one exists.
+         The local loopback address is explicitly denied while other
+         addresses are permitted. This variant of the test uses ipv6.'
+
+test-modules:
+    add-test-to-search-path: 'True'
+    test-object:
+        typename: 'sipp.SIPpTestCase'
+        config-section: test-object-config
+    modules:
+        -
+            typename: 'scenario_generator.ScenarioGeneratorModule'
+        -
+            config-section: 'ami-config'
+            typename: 'ami.AMIEventModule'
+
+test-object-config:
+    fail-on-any: True
+    reactor-timeout: 10
+
+ami-config:
+    -
+        type: 'headermatch' # one for alice
+        id: '0'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'AOR_CONTACT_ADDED'
+                AOR: 'alice'
+        count: '1'
+    -
+        type: 'headermatch' # one for bob
+        id: '0'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'AOR_CONTACT_ADDED'
+                AOR: 'bob'
+        count: '1'
+    -
+        type: 'headermatch' # two total and not more.
+        id: '0'
+        conditions:
+            match:
+                Event: 'TestEvent'
+                State: 'AOR_CONTACT_ADDED'
+        count: '2'
+
+properties:
+    minversion: '12.0.0'
+    dependencies:
+        - buildoption: 'TEST_FRAMEWORK'
+        - python: 'twisted'
+        - python: 'starpy'
+        - python: 'netifaces'
+        - sipp:
+            version: 'v3.3'
+        - asterisk: 'res_pjsip'
+        - custom: 'ipv6addr'
+    tags:
+        - pjsip
+        - ACL

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/ipv6/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/tests.yaml?view=auto&rev=5977
==============================================================================
--- asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/tests.yaml (added)
+++ asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/tests.yaml Thu Nov 20 10:34:44 2014
@@ -1,0 +1,4 @@
+# Enter tests here in the order they should be considered for execution:
+tests:
+    - test: 'ipv4'
+    - test: 'ipv6'

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/tests.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/tests.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/contact_acl/tests.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/tests.yaml?view=diff&rev=5977&r1=5976&r2=5977
==============================================================================
--- asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/tests.yaml (original)
+++ asterisk/trunk/tests/channels/pjsip/registration/inbound/nominal/tests.yaml Thu Nov 20 10:34:44 2014
@@ -5,5 +5,7 @@
     - dir: 'multiple_contacts'

[... 7 lines stripped ...]



More information about the asterisk-commits mailing list