[asterisk-commits] pjsip: Refactor out various AMISendTest implementations (testsuite[master])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Apr 22 06:24:54 CDT 2015
Matt Jordan has submitted this change and it was merged.
Change subject: pjsip: Refactor out various AMISendTest implementations
......................................................................
pjsip: Refactor out various AMISendTest implementations
There were several different versions of AMISendTest scattered throughout
test/channels/pjsip. They've all been refactored out by converting them
to either SIPpAMIActionTestCase or EventActionModule.
Change-Id: I0d3e5298114bd4eb676537a816bc6e437036642b
---
D tests/channels/pjsip/ami/pjsip_qualify/AMISendTest.py
M tests/channels/pjsip/ami/pjsip_qualify/test-config.yaml
D tests/channels/pjsip/ami/show_endpoint/AMISendTest.py
M tests/channels/pjsip/ami/show_endpoint/test-config.yaml
D tests/channels/pjsip/ami/show_endpoints/AMISendTest.py
M tests/channels/pjsip/ami/show_endpoints/test-config.yaml
D tests/channels/pjsip/ami/show_registrations_inbound/AMISendTest.py
M tests/channels/pjsip/ami/show_registrations_inbound/test-config.yaml
D tests/channels/pjsip/ami/show_registrations_outbound/AMISendTest.py
M tests/channels/pjsip/ami/show_registrations_outbound/test-config.yaml
D tests/channels/pjsip/ami/show_subscriptions/AMISendTest.py
M tests/channels/pjsip/ami/show_subscriptions/configs/ast1/extensions.conf
M tests/channels/pjsip/ami/show_subscriptions/configs/ast1/pjsip.conf
M tests/channels/pjsip/ami/show_subscriptions/configs/ast1/voicemail.conf
M tests/channels/pjsip/ami/show_subscriptions/sipp/subscribe.xml
M tests/channels/pjsip/ami/show_subscriptions/test-config.yaml
D tests/channels/pjsip/config_wizard/AMISendTest.py
M tests/channels/pjsip/config_wizard/hints/test-config.yaml
M tests/channels/pjsip/config_wizard/phone/test-config.yaml
M tests/channels/pjsip/config_wizard/registration/test-config.yaml
M tests/channels/pjsip/config_wizard/trunk/test-config.yaml
D tests/channels/pjsip/qualify/AMISendTest.py
M tests/channels/pjsip/qualify/no_qualify/test-config.yaml
23 files changed, 446 insertions(+), 515 deletions(-)
Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
Matt Jordan: Looks good to me, approved; Verified
diff --git a/tests/channels/pjsip/ami/pjsip_qualify/AMISendTest.py b/tests/channels/pjsip/ami/pjsip_qualify/AMISendTest.py
deleted file mode 100644
index 5498ea2..0000000
--- a/tests/channels/pjsip/ami/pjsip_qualify/AMISendTest.py
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/bin/env python
-'''
-Copyright (C) 2013-2014, Digium, Inc.
-Kevin Harwell <kharwell at digium.com>
-Modified by Scott Emidy <jemidy 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/asterisk")
-
-from twisted.internet import reactor
-from test_case import TestCase
-from sipp import SIPpScenario
-
-LOGGER = logging.getLogger(__name__)
-
-ACTION = {
- "Action": "PJSIPQualify",
- "Endpoint": "user1"
-}
-
-
-class AMISendTest(TestCase):
- """Sends the AMI Action PJSIPQualify"""
- def __init__(self, path=None, config=None):
- """Constructor """
- super(AMISendTest, self).__init__(path, config)
- self.create_asterisk()
- self.passed = False #This is default but it doesn't hurt to be explicit
-
- def run(self):
- super(AMISendTest, self).run()
- self.create_ami_factory()
-
- def ami_connect(self, ami):
- """Starts the PJSIPQualify scenario and Runs Through the XML"""
- super(AMISendTest, self).ami_connect(ami)
-
- def _ami_action():
- """ This Sends the PJSIPQualify Action """
- LOGGER.info('Sending PJSIPQualify Action...')
- ami.sendDeferred(ACTION).addCallback(ami.errorUnlessResponse)
-
- LOGGER.info('Starting PJSIPQualify scenario')
-
- sipp_options = (SIPpScenario(self.test_name,
- {'scenario': 'options.xml', '-p': '5062'}))
- sipp_options.run(self).addCallback(self.__on_return)
- reactor.callLater(1,_ami_action)
-
- def __on_return(self, result):
- """Stops and Passes the Test if it Ran Successfully"""
- self.passed = result.passed
- self.stop_reactor()
diff --git a/tests/channels/pjsip/ami/pjsip_qualify/test-config.yaml b/tests/channels/pjsip/ami/pjsip_qualify/test-config.yaml
index 70b6cc0..6869d3a 100644
--- a/tests/channels/pjsip/ami/pjsip_qualify/test-config.yaml
+++ b/tests/channels/pjsip/ami/pjsip_qualify/test-config.yaml
@@ -14,11 +14,19 @@
- pjsip
test-modules:
- # allow test_runner to find and run the local test
- add-test-to-search-path: 'True'
test-object:
- config-section: object-config
- typename: 'AMISendTest.AMISendTest'
+ config-section: sipp-config
+ typename: 'sipp.SIPpAMIActionTestCase'
-object-config:
+sipp-config:
reactor-timeout: 15
+ fail-on-any: True
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': {'scenario': 'options.xml', '-p': '5062'} }
+ ami-action:
+ delay: 1
+ args:
+ Action: "PJSIPQualify"
+ Endpoint: "user1"
diff --git a/tests/channels/pjsip/ami/show_endpoint/AMISendTest.py b/tests/channels/pjsip/ami/show_endpoint/AMISendTest.py
deleted file mode 100755
index 84a1c21..0000000
--- a/tests/channels/pjsip/ami/show_endpoint/AMISendTest.py
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/env python
-'''
-Copyright (C) 2013, Digium, Inc.
-Kevin Harwell <kharwell at digium.com>
-
-This program is free software, distributed under the terms of
-the GNU General Public License Version 2.
-'''
-
-import sys
-
-sys.path.append("lib/python/asterisk")
-
-from test_case import TestCase
-
-ACTION = {
- "Action": "PJSIPShowEndpoint",
- "ActionID": "12345",
- "Endpoint": "user1"
-}
-
-class AMISendTest(TestCase):
- def __init__(self, path=None, config=None):
- super(AMISendTest, self).__init__(path, config)
- self.create_asterisk()
-
- def run(self):
- super(AMISendTest, self).run()
- self.create_ami_factory()
-
- def ami_connect(self, ami):
- ami.sendDeferred(ACTION).addCallback(self.__on_response)
-
- def __on_response(self, result):
- # stop test since done
- self.stop_reactor()
-
diff --git a/tests/channels/pjsip/ami/show_endpoint/test-config.yaml b/tests/channels/pjsip/ami/show_endpoint/test-config.yaml
index 122e40b..bfc6b68 100644
--- a/tests/channels/pjsip/ami/show_endpoint/test-config.yaml
+++ b/tests/channels/pjsip/ami/show_endpoint/test-config.yaml
@@ -15,28 +15,34 @@
- pjsip
test-modules:
- # allow test_runner to find and run the local test
- add-test-to-search-path: 'True'
test-object:
config-section: object-config
- typename: 'AMISendTest.AMISendTest'
+ typename: 'test_case.TestCaseModule'
modules:
-
minversion: '12.0.0'
maxversion: '13.0.0'
config-section: 'ami-config'
- typename: 'ami.AMIEventModule'
+ typename: 'pluggable_modules.EventActionModule'
-
minversion: '13.0.0'
config-section: 'ami-config-13'
- typename: 'ami.AMIEventModule'
+ typename: 'pluggable_modules.EventActionModule'
object-config:
reactor-timeout: 15
+ connect-ami: True
ami-config:
- -
- type: 'headermatch'
+ -
+ ami-start:
+ ami-actions:
+ action:
+ Action: 'PJSIPShowEndpoint'
+ ActionID: '12345'
+ Endpoint: 'user1'
+ -
+ ami-events:
conditions:
match:
Event: 'EndpointDetail'
@@ -124,8 +130,8 @@
DeviceState: 'Invalid|Not in use|Unavailable'
ActiveChannels: ''
count: 1
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'AorDetail'
@@ -147,8 +153,8 @@
ContactsRegistered: '0'
EndpointName: 'user1'
count: 1
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'AuthDetail'
@@ -165,8 +171,8 @@
Username: 'user1'
EndpointName: 'user1'
count: 1
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'TransportDetail'
@@ -196,8 +202,8 @@
Protocol: 'udp'
EndpointName: 'user1'
count: 1
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'IdentifyDetail'
@@ -209,8 +215,8 @@
Endpoint: 'user1'
Match: '127.0.0.1/255.255.255.255'
count: 1
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'EndpointDetailComplete'
@@ -222,8 +228,15 @@
count: 1
ami-config-13:
- -
- type: 'headermatch'
+ -
+ ami-start:
+ ami-actions:
+ action:
+ Action: 'PJSIPShowEndpoint'
+ ActionID: '12345'
+ Endpoint: 'user1'
+ -
+ ami-events:
conditions:
match:
Event: 'EndpointDetail'
@@ -311,8 +324,8 @@
DeviceState: 'Invalid|Not in use|Unavailable'
ActiveChannels: ''
count: 1
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'AorDetail'
@@ -334,8 +347,8 @@
ContactsRegistered: '0'
EndpointName: 'user1'
count: 1
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'AuthDetail'
@@ -352,8 +365,8 @@
Username: 'user1'
EndpointName: 'user1'
count: 1
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'TransportDetail'
@@ -383,8 +396,8 @@
Protocol: 'udp'
EndpointName: 'user1'
count: 1
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'IdentifyDetail'
@@ -396,8 +409,8 @@
Endpoint: 'user1'
Match: '127.0.0.1/255.255.255.255'
count: 1
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'ContactStatusDetail'
@@ -409,8 +422,8 @@
RoundtripUsec: '(N/A|0)'
EndpointName: 'user1'
count: 2
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'EndpointDetailComplete'
@@ -420,3 +433,4 @@
EventList: 'Complete'
ListItems: '7'
count: 1
+ stop_test:
diff --git a/tests/channels/pjsip/ami/show_endpoints/AMISendTest.py b/tests/channels/pjsip/ami/show_endpoints/AMISendTest.py
deleted file mode 100755
index 5a8c102..0000000
--- a/tests/channels/pjsip/ami/show_endpoints/AMISendTest.py
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/env python
-'''
-Copyright (C) 2013, Digium, Inc.
-Kevin Harwell <kharwell at digium.com>
-
-This program is free software, distributed under the terms of
-the GNU General Public License Version 2.
-'''
-
-import sys
-
-sys.path.append("lib/python/asterisk")
-
-from test_case import TestCase
-
-ACTION = {
- "Action":"PJSIPShowEndpoints",
- "ActionID": "12345",
-}
-
-class AMISendTest(TestCase):
- def __init__(self, path=None, config=None):
- super(AMISendTest, self).__init__(path, config)
- self.create_asterisk()
-
- def run(self):
- super(AMISendTest, self).run()
- self.create_ami_factory()
-
- def ami_connect(self, ami):
- ami.sendDeferred(ACTION).addCallback(self.__on_response)
-
- def __on_response(self, result):
- # stop test since done
- self.stop_reactor()
-
diff --git a/tests/channels/pjsip/ami/show_endpoints/test-config.yaml b/tests/channels/pjsip/ami/show_endpoints/test-config.yaml
index 6870373..28e59f3 100644
--- a/tests/channels/pjsip/ami/show_endpoints/test-config.yaml
+++ b/tests/channels/pjsip/ami/show_endpoints/test-config.yaml
@@ -15,26 +15,32 @@
- pjsip
test-modules:
- # allow test_runner to find and run the local test
- add-test-to-search-path: 'True'
test-object:
config-section: object-config
- typename: 'AMISendTest.AMISendTest'
+ typename: 'test_case.TestCaseModule'
modules:
-
minversion: '12.0.0'
config-section: 'ami-config'
- typename: 'ami.AMIEventModule'
+ typename: 'pluggable_modules.EventActionModule'
object-config:
reactor-timeout: 15
+ connect-ami: True
ami-config:
- -
- type: 'headermatch'
+ -
+ ami-start:
+ ami-actions:
+ action:
+ Action: 'PJSIPShowEndpoints'
+ ActionID: '12345'
+ -
+ ami-events:
conditions:
match:
Event: 'EndpointList'
+ Contacts: user1/sip:user1 at 127.0.0.1:5062
requirements:
match:
ActionID: '12345'
@@ -44,12 +50,29 @@
Aor: 'user.*'
Auths: 'user.*'
OutboundAuths: ''
- Contacts: user1/sip:user1 at 127.0.0.1:5062|user2/sip:user2 at 127.0.0.1:5063
DeviceState: 'Invalid|Not in use|Unavailable'
ActiveChannels: ''
- count: 2
- -
- type: 'headermatch'
+ count: 1
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'EndpointList'
+ Contacts: user2/sip:user2 at 127.0.0.1:5063
+ requirements:
+ match:
+ ActionID: '12345'
+ ObjectType: 'endpoint'
+ ObjectName: 'user.*'
+ Transport: 'local'
+ Aor: 'user.*'
+ Auths: 'user.*'
+ OutboundAuths: ''
+ DeviceState: 'Invalid|Not in use|Unavailable'
+ ActiveChannels: ''
+ count: 1
+ -
+ ami-events:
conditions:
match:
Event: 'EndpointListComplete'
@@ -59,4 +82,4 @@
EventList: 'Complete'
ListItems: '2'
count: 1
-
+ stop_test:
diff --git a/tests/channels/pjsip/ami/show_registrations_inbound/AMISendTest.py b/tests/channels/pjsip/ami/show_registrations_inbound/AMISendTest.py
deleted file mode 100755
index e953238..0000000
--- a/tests/channels/pjsip/ami/show_registrations_inbound/AMISendTest.py
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/env python
-'''
-Copyright (C) 2013, Digium, Inc.
-Kevin Harwell <kharwell 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/asterisk")
-
-from test_case import TestCase
-from sipp import SIPpScenario
-
-LOGGER = logging.getLogger(__name__)
-
-ACTION = {
- "Action": "PJSIPShowRegistrationsInbound",
- "ActionID": "12345",
-}
-
-class AMISendTest(TestCase):
- def __init__(self, path=None, config=None):
- super(AMISendTest, self).__init__(path, config)
- self.create_asterisk()
-
- def run(self):
- super(AMISendTest, self).run()
- self.create_ami_factory()
-
- def ami_connect(self, ami):
- super(AMISendTest, self).ami_connect(ami)
-
- def _on_register(obj):
- LOGGER.info('Getting inbound registrations...')
- ami.sendDeferred(ACTION).addCallback(self.__on_response)
- return obj
-
- LOGGER.info('Starting inbound registration scenario')
-
- sipp = SIPpScenario(self.test_name,
- {'scenario':'register.xml', '-p':'5061' })
- sipp.run(self).addCallback(_on_register)
-
- def __on_response(self, result):
- # stop test since done
- self.stop_reactor()
diff --git a/tests/channels/pjsip/ami/show_registrations_inbound/test-config.yaml b/tests/channels/pjsip/ami/show_registrations_inbound/test-config.yaml
index aadfa55..6698dcf 100644
--- a/tests/channels/pjsip/ami/show_registrations_inbound/test-config.yaml
+++ b/tests/channels/pjsip/ami/show_registrations_inbound/test-config.yaml
@@ -7,6 +7,7 @@
properties:
minversion: '12.0.0'
dependencies:
+ - buildoption: 'TEST_FRAMEWORK'
- sipp :
version : 'v3.0'
- asterisk : 'res_pjsip'
@@ -15,26 +16,44 @@
- pjsip
test-modules:
- # allow test_runner to find and run the local test
- add-test-to-search-path: 'True'
test-object:
- config-section: object-config
- typename: 'AMISendTest.AMISendTest'
+ config-section: sipp-config
+ typename: 'sipp.SIPpTestCase'
modules:
-
minversion: '12.0.0'
config-section: 'ami-config'
- typename: 'ami.AMIEventModule'
+ typename: 'pluggable_modules.EventActionModule'
-object-config:
+sipp-config:
+ connect-ami: True
reactor-timeout: 15
+ fail-on-any: True
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': {'scenario': 'register.xml', '-p': '5061'} }
ami-config:
- -
- type: 'headermatch'
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'TestEvent'
+ State: 'AOR_CONTACT_ADDED'
+ requirements:
+ match:
+ AOR: 'user1'
+ ami-actions:
+ action:
+ Action: 'PJSIPShowRegistrationsInbound'
+ ActionID: '12345'
+ -
+ ami-events:
conditions:
match:
Event: 'InboundRegistrationDetail'
+ Contacts: user1/sip:user1 at 127.0.0.1:5061
requirements:
match:
ActionID: '12345'
@@ -48,10 +67,29 @@
DefaultExpiration: '3600'
MaximumExpiration: '7200'
MinimumExpiration: '60'
- Contacts: user1/sip:user1 at 127.0.0.1:5061|user2/sip:user2 at 127.0.0.1:5062
- count: 2
- -
- type: 'headermatch'
+ count: 1
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'InboundRegistrationDetail'
+ Contacts: user2/sip:user2 at 127.0.0.1:5062
+ requirements:
+ match:
+ ActionID: '12345'
+ ObjectType: 'aor'
+ ObjectName: 'user.*'
+ Mailboxes: ''
+ RemoveExisting: 'false'
+ MaxContacts: '1'
+ AuthenticateQualify: 'false'
+ QualifyFrequency: '0'
+ DefaultExpiration: '3600'
+ MaximumExpiration: '7200'
+ MinimumExpiration: '60'
+ count: 1
+ -
+ ami-events:
conditions:
match:
Event: 'InboundRegistrationDetailComplete'
@@ -61,5 +99,4 @@
EventList: 'Complete'
ListItems: '2'
count: 1
-
-
+ stop_test:
diff --git a/tests/channels/pjsip/ami/show_registrations_outbound/AMISendTest.py b/tests/channels/pjsip/ami/show_registrations_outbound/AMISendTest.py
deleted file mode 100755
index e705d2d..0000000
--- a/tests/channels/pjsip/ami/show_registrations_outbound/AMISendTest.py
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/usr/bin/env python
-'''
-Copyright (C) 2013, Digium, Inc.
-Kevin Harwell <kharwell at digium.com>
-
-This program is free software, distributed under the terms of
-the GNU General Public License Version 2.
-'''
-
-import sys
-
-sys.path.append("lib/python/asterisk")
-
-from test_case import TestCase
-
-ACTION = {
- "Action": "PJSIPShowRegistrationsOutbound",
- "ActionID": "12345",
-}
-
-class AMISendTest(TestCase):
- def __init__(self, path=None, config=None):
- super(AMISendTest, self).__init__(path, config)
- self.create_asterisk()
-
- def run(self):
- super(AMISendTest, self).run()
- self.create_ami_factory()
-
- def ami_connect(self, ami):
- # wait for asterisk to attempt registration
- ami.registerEvent('Registry', self.__on_registry)
-
- def __on_registry(self, ami, event):
- # asterisk attempted registration, so check details
- ami.deregisterEvent('Registry', None)
- ami.sendDeferred(ACTION).addCallback(self.__on_response)
-
- def __on_response(self, result):
- # stop test since done
- self.stop_reactor()
diff --git a/tests/channels/pjsip/ami/show_registrations_outbound/test-config.yaml b/tests/channels/pjsip/ami/show_registrations_outbound/test-config.yaml
index 6f160ee..1f780b8 100644
--- a/tests/channels/pjsip/ami/show_registrations_outbound/test-config.yaml
+++ b/tests/channels/pjsip/ami/show_registrations_outbound/test-config.yaml
@@ -15,31 +15,36 @@
- pjsip
test-modules:
- # allow test_runner to find and run the local test
- add-test-to-search-path: 'True'
test-object:
config-section: object-config
- typename: 'AMISendTest.AMISendTest'
+ typename: 'test_case.TestCaseModule'
modules:
-
minversion: '12.0.0'
config-section: 'ami-config'
- typename: 'ami.AMIEventModule'
+ typename: 'pluggable_modules.EventActionModule'
object-config:
reactor-timeout: 15
+ connect-ami: True
ami-config:
- -
- type: 'headermatch'
+ -
+ ami-start:
+ ami-actions:
+ action:
+ Action: 'PJSIPShowRegistrationsOutbound'
+ ActionID: '12345'
+ -
+ ami-events:
conditions:
match:
Event: 'OutboundRegistrationDetail'
+ ObjectName: 'user0'
requirements:
match:
ActionID: '12345'
ObjectType: 'registration'
- ObjectName: 'user.*'
OutboundAuth: 'reg-auth'
AuthRejectionPermanent: 'true'
MaxRetries: '10'
@@ -49,13 +54,109 @@
OutboundProxy: ''
Transport: 'local'
ContactUser: ''
- ClientUri: 'sip:user.*'
+ ClientUri: 'sip:user0'
ServerUri: 'sip:localhost'
Status: 'Unregistered|Rejected'
NextReg: '0'
- count: 5
- -
- type: 'headermatch'
+ count: 1
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'OutboundRegistrationDetail'
+ ObjectName: 'user1'
+ requirements:
+ match:
+ ActionID: '12345'
+ ObjectType: 'registration'
+ OutboundAuth: 'reg-auth'
+ AuthRejectionPermanent: 'true'
+ MaxRetries: '10'
+ ForbiddenRetryInterval: '0'
+ RetryInterval: '60'
+ Expiration: '3600'
+ OutboundProxy: ''
+ Transport: 'local'
+ ContactUser: ''
+ ClientUri: 'sip:user1'
+ ServerUri: 'sip:localhost'
+ Status: 'Unregistered|Rejected'
+ NextReg: '0'
+ count: 1
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'OutboundRegistrationDetail'
+ ObjectName: 'user2'
+ requirements:
+ match:
+ ActionID: '12345'
+ ObjectType: 'registration'
+ OutboundAuth: 'reg-auth'
+ AuthRejectionPermanent: 'true'
+ MaxRetries: '10'
+ ForbiddenRetryInterval: '0'
+ RetryInterval: '60'
+ Expiration: '3600'
+ OutboundProxy: ''
+ Transport: 'local'
+ ContactUser: ''
+ ClientUri: 'sip:user2'
+ ServerUri: 'sip:localhost'
+ Status: 'Unregistered|Rejected'
+ NextReg: '0'
+ count: 1
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'OutboundRegistrationDetail'
+ ObjectName: 'user3'
+ requirements:
+ match:
+ ActionID: '12345'
+ ObjectType: 'registration'
+ OutboundAuth: 'reg-auth'
+ AuthRejectionPermanent: 'true'
+ MaxRetries: '10'
+ ForbiddenRetryInterval: '0'
+ RetryInterval: '60'
+ Expiration: '3600'
+ OutboundProxy: ''
+ Transport: 'local'
+ ContactUser: ''
+ ClientUri: 'sip:user3'
+ ServerUri: 'sip:localhost'
+ Status: 'Unregistered|Rejected'
+ NextReg: '0'
+ count: 1
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'OutboundRegistrationDetail'
+ ObjectName: 'user4'
+ requirements:
+ match:
+ ActionID: '12345'
+ ObjectType: 'registration'
+ OutboundAuth: 'reg-auth'
+ AuthRejectionPermanent: 'true'
+ MaxRetries: '10'
+ ForbiddenRetryInterval: '0'
+ RetryInterval: '60'
+ Expiration: '3600'
+ OutboundProxy: ''
+ Transport: 'local'
+ ContactUser: ''
+ ClientUri: 'sip:user4'
+ ServerUri: 'sip:localhost'
+ Status: 'Unregistered|Rejected'
+ NextReg: '0'
+ count: 1
+ -
+ ami-events:
conditions:
match:
Event: 'AuthDetail'
@@ -72,8 +173,8 @@
Username: 'xxx'
count: 5
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'OutboundRegistrationDetailComplete'
@@ -84,3 +185,4 @@
Registered: '0'
NotRegistered: '5'
count: 1
+ stop_test:
diff --git a/tests/channels/pjsip/ami/show_subscriptions/AMISendTest.py b/tests/channels/pjsip/ami/show_subscriptions/AMISendTest.py
deleted file mode 100755
index d3a4b8c..0000000
--- a/tests/channels/pjsip/ami/show_subscriptions/AMISendTest.py
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env python
-'''
-Copyright (C) 2013, Digium, Inc.
-Kevin Harwell <kharwell 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/asterisk")
-
-from sipp import SIPpScenario
-from test_case import TestCase
-
-from twisted.internet import reactor
-
-LOGGER = logging.getLogger(__name__)
-
-ACTION = {
- "Action": "PJSIPShowSubscriptionsInbound",
- "ActionID": "12345",
-}
-
-class AMISendTest(TestCase):
- def __init__(self, path=None, config=None):
- self.updates_received = 0
- super(AMISendTest, self).__init__(path, config)
- self.create_asterisk()
-
- def run(self):
- super(AMISendTest, self).run()
- self.create_ami_factory()
-
- def ami_connect(self, ami):
- super(AMISendTest, self).ami_connect(ami)
-
- ami.registerEvent("TestEvent", self.test_event)
- LOGGER.info('Starting subscription scenario')
- sipp = SIPpScenario(self.test_name,
- {'scenario':'subscribe.xml', '-p':'5061' })
- sipp.run(self)
-
- def test_event(self, ami, event):
- if event['state'] != "SUBSCRIPTION_STATE_SET" \
- or event['statetext'] != "ACTIVE" \
- or event['endpoint'] != "user1":
- return
-
- self.updates_received += 1
- if self.updates_received != 2:
- return
-
- LOGGER.info('Getting inbound subscriptions...')
- ami.sendDeferred(ACTION).addCallback(ami.errorUnlessResponse)
- reactor.callLater(2, self.stop_reactor)
diff --git a/tests/channels/pjsip/ami/show_subscriptions/configs/ast1/extensions.conf b/tests/channels/pjsip/ami/show_subscriptions/configs/ast1/extensions.conf
index 9fde2d9..a660990 100644
--- a/tests/channels/pjsip/ami/show_subscriptions/configs/ast1/extensions.conf
+++ b/tests/channels/pjsip/ami/show_subscriptions/configs/ast1/extensions.conf
@@ -4,3 +4,5 @@
exten => user1,hint,PJSIP/user1
exten => user1,1,Noop
+exten => user2,hint,PJSIP/user2
+exten => user2,1,Noop
diff --git a/tests/channels/pjsip/ami/show_subscriptions/configs/ast1/pjsip.conf b/tests/channels/pjsip/ami/show_subscriptions/configs/ast1/pjsip.conf
index fd465b4..e36819c 100644
--- a/tests/channels/pjsip/ami/show_subscriptions/configs/ast1/pjsip.conf
+++ b/tests/channels/pjsip/ami/show_subscriptions/configs/ast1/pjsip.conf
@@ -26,3 +26,10 @@
[user1](endpoint_t)
aors=user1
+
+[user2](aor_t)
+contact=sip:user1 at 127.0.0.1:5061
+mailboxes=user2
+
+[user2](endpoint_t)
+aors=user2
diff --git a/tests/channels/pjsip/ami/show_subscriptions/configs/ast1/voicemail.conf b/tests/channels/pjsip/ami/show_subscriptions/configs/ast1/voicemail.conf
index 29cbe7d..ea9cc1f 100644
--- a/tests/channels/pjsip/ami/show_subscriptions/configs/ast1/voicemail.conf
+++ b/tests/channels/pjsip/ami/show_subscriptions/configs/ast1/voicemail.conf
@@ -10,3 +10,4 @@
[default]
user1 => 123,mailbox,user1 at user1.com
+user2 => 123,mailbox,user2 at user2.com
diff --git a/tests/channels/pjsip/ami/show_subscriptions/sipp/subscribe.xml b/tests/channels/pjsip/ami/show_subscriptions/sipp/subscribe.xml
index 2124588..c2ef4a6 100644
--- a/tests/channels/pjsip/ami/show_subscriptions/sipp/subscribe.xml
+++ b/tests/channels/pjsip/ami/show_subscriptions/sipp/subscribe.xml
@@ -42,13 +42,13 @@
<send retrans="500">
<![CDATA[
- SUBSCRIBE sip:user1@[remote_ip]:[remote_port] SIP/2.0
+ SUBSCRIBE sip:user2@[remote_ip]:[remote_port] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
- From: user1 <sip:user1@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
- To: user1 <sip:user1@[remote_ip]:[remote_port]>
+ From: user2 <sip:user2@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+ To: user2 <sip:user2@[remote_ip]:[remote_port]>
Call-ID: [call_id]
CSeq: 1 SUBSCRIBE
- Contact: sip:user1@[local_ip]:[local_port]
+ Contact: sip:user2@[local_ip]:[local_port]
Event: presence
Accept: application/pidf+xml
Expires: 3600
diff --git a/tests/channels/pjsip/ami/show_subscriptions/test-config.yaml b/tests/channels/pjsip/ami/show_subscriptions/test-config.yaml
index bac1942..a031ecd 100644
--- a/tests/channels/pjsip/ami/show_subscriptions/test-config.yaml
+++ b/tests/channels/pjsip/ami/show_subscriptions/test-config.yaml
@@ -15,42 +15,83 @@
- pjsip
test-modules:
- # allow test_runner to find and run the local test
- add-test-to-search-path: 'True'
test-object:
- config-section: object-config
- typename: 'AMISendTest.AMISendTest'
+ config-section: sipp-config
+ typename: 'sipp.SIPpTestCase'
modules:
-
minversion: '12.0.0'
config-section: 'ami-config'
- typename: 'ami.AMIEventModule'
+ typename: 'pluggable_modules.EventActionModule'
-object-config:
+sipp-config:
+ connect-ami: True
reactor-timeout: 15
+ fail-on-any: True
test-iterations:
-
- scenarios:
+ scenarios:
- { 'key-args': { 'scenario':'subscribe.xml', '-p':'5061' } }
ami-config:
- -
- type: 'headermatch'
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'TestEvent'
+ State: 'SUBSCRIPTION_STATE_SET'
+ Endpoint: 'user1'
+ requirements:
+ match:
+ StateText: 'ACTIVE'
+ count: 1
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'TestEvent'
+ State: 'SUBSCRIPTION_STATE_SET'
+ Endpoint: 'user2'
+ requirements:
+ match:
+ StateText: 'ACTIVE'
+ count: 1
+ ami-actions:
+ action:
+ Action: 'PJSIPShowSubscriptionsInbound'
+ ActionID: '12345'
+ -
+ ami-events:
conditions:
match:
Event: 'InboundSubscriptionDetail'
+ Endpoint: 'user1'
requirements:
match:
ActionID: '12345'
Role: Notifier
- Endpoint: 'user.*'
Callid: '.*'
State: 'ACTIVE'
Callerid: 'Unknown'
- SubscriptionType: mwi|extension_state
- count: 2
- -
- type: 'headermatch'
+ SubscriptionType: mwi
+ count: 1
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'InboundSubscriptionDetail'
+ Endpoint: 'user2'
+ requirements:
+ match:
+ ActionID: '12345'
+ Role: Notifier
+ Callid: '.*'
+ State: 'ACTIVE'
+ Callerid: 'Unknown'
+ SubscriptionType: extension_state
+ count: 1
+ -
+ ami-events:
conditions:
match:
Event: 'InboundSubscriptionDetailComplete'
@@ -60,3 +101,4 @@
EventList: 'Complete'
ListItems: '2'
count: 1
+ stop_test:
diff --git a/tests/channels/pjsip/config_wizard/AMISendTest.py b/tests/channels/pjsip/config_wizard/AMISendTest.py
deleted file mode 100644
index ead830c..0000000
--- a/tests/channels/pjsip/config_wizard/AMISendTest.py
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/env python
-'''
-Copyright (C) 2013, Digium, Inc.
-Kevin Harwell <kharwell at digium.com>
-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 sys
-
-sys.path.append("lib/python/asterisk")
-
-from test_case import TestCase
-
-class AMISendTest(TestCase):
- def __init__(self, path=None, config=None):
- super(AMISendTest, self).__init__(path, config)
- self.config = config
- self.action = config.get('ACTION')
- if not self.action:
- raise Exception('"ACTION" was not defined in test-config.yaml')
- self.create_asterisk()
-
- def run(self):
- super(AMISendTest, self).run()
- self.create_ami_factory()
-
- def ami_connect(self, ami):
- ami.sendDeferred(self.action).addCallback(self.__on_response)
-
- def __on_response(self, result):
- # stop test since done
- self.stop_reactor()
-
diff --git a/tests/channels/pjsip/config_wizard/hints/test-config.yaml b/tests/channels/pjsip/config_wizard/hints/test-config.yaml
index 7c76cba..91fd7d3 100644
--- a/tests/channels/pjsip/config_wizard/hints/test-config.yaml
+++ b/tests/channels/pjsip/config_wizard/hints/test-config.yaml
@@ -14,24 +14,29 @@
- pjsip
test-modules:
- # allow test_runner to find and run the local test
- add-test-to-search-path: 'True'
- add-relative-to-search-path: ['../']
test-object:
config-section: object-config
- typename: 'AMISendTest.AMISendTest'
+ typename: 'test_case.TestCaseModule'
modules:
-
config-section: 'ami-config'
- typename: 'ami.AMIEventModule'
+ typename: 'pluggable_modules.EventActionModule'
object-config:
reactor-timeout: 15
- ACTION: { "Action": "ShowDialPlan", "ActionID": "12345", "Context": "default_hints", "Extension": "9090" }
+ connect-ami: True
ami-config:
- -
- type: 'headermatch'
+ -
+ ami-start:
+ ami-actions:
+ action:
+ Action: 'ShowDialPlan'
+ ActionID: '12345'
+ Context: 'default_hints'
+ Extenxion: '9090'
+ -
+ ami-events:
conditions:
match:
Event: 'ListDialplan'
@@ -45,8 +50,8 @@
Application: 'PJSIP/phone1'
Registrar: 'res_pjsip_config_wizard'
count: 1
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'ListDialplan'
@@ -61,3 +66,4 @@
AppData: '\${HINT}/0000'
Registrar: 'res_pjsip_config_wizard'
count: 1
+ stop_test:
diff --git a/tests/channels/pjsip/config_wizard/phone/test-config.yaml b/tests/channels/pjsip/config_wizard/phone/test-config.yaml
index 848214e..48fedfd 100644
--- a/tests/channels/pjsip/config_wizard/phone/test-config.yaml
+++ b/tests/channels/pjsip/config_wizard/phone/test-config.yaml
@@ -14,24 +14,28 @@
- pjsip
test-modules:
- # allow test_runner to find and run the local test
- add-test-to-search-path: 'True'
- add-relative-to-search-path: ['../']
test-object:
config-section: object-config
- typename: 'AMISendTest.AMISendTest'
+ typename: 'test_case.TestCaseModule'
modules:
-
config-section: 'ami-config'
- typename: 'ami.AMIEventModule'
+ typename: 'pluggable_modules.EventActionModule'
object-config:
reactor-timeout: 15
- ACTION: { "Action": "PJSIPShowEndpoint", "ActionID": "12345", "Endpoint": "phone1" }
+ connect-ami: True
ami-config:
- -
- type: 'headermatch'
+ -
+ ami-start:
+ ami-actions:
+ action:
+ Action: 'PJSIPShowEndpoint'
+ ActionID: '12345'
+ Endpoint: 'phone1'
+ -
+ ami-events:
conditions:
match:
Event: 'EndpointDetail'
@@ -119,8 +123,8 @@
DeviceState: 'Invalid|Not in use|Unavailable'
ActiveChannels: ''
count: 1
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'AorDetail'
@@ -142,8 +146,8 @@
ContactsRegistered: '0'
EndpointName: 'phone1'
count: 1
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'AuthDetail'
@@ -160,8 +164,8 @@
Username: 'testuser'
EndpointName: 'phone1'
count: 1
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'TransportDetail'
@@ -191,8 +195,8 @@
Protocol: 'udp'
EndpointName: 'phone1'
count: 1
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'EndpointDetailComplete'
@@ -202,4 +206,4 @@
EventList: 'Complete'
ListItems: '4'
count: 1
-
+ stop_test:
diff --git a/tests/channels/pjsip/config_wizard/registration/test-config.yaml b/tests/channels/pjsip/config_wizard/registration/test-config.yaml
index 4894337..fc13e29 100644
--- a/tests/channels/pjsip/config_wizard/registration/test-config.yaml
+++ b/tests/channels/pjsip/config_wizard/registration/test-config.yaml
@@ -16,27 +16,31 @@
- pjsip
test-modules:
- # allow test_runner to find and run the local test
- add-test-to-search-path: 'True'
- add-relative-to-search-path: ['../']
test-object:
config-section: object-config
- typename: 'AMISendTest.AMISendTest'
+ typename: 'test_case.TestCaseModule'
modules:
-
config-section: 'ami-config'
- typename: 'ami.AMIEventModule'
+ typename: 'pluggable_modules.EventActionModule'
object-config:
reactor-timeout: 15
- ACTION: { "Action": "PJSIPShowRegistrationsOutbound", "ActionID": "12345" }
+ connect-ami: True
ami-config:
- -
- type: 'headermatch'
+ -
+ ami-start:
+ ami-actions:
+ action:
+ Action: 'PJSIPShowRegistrationsOutbound'
+ ActionID: '12345'
+ -
+ ami-events:
conditions:
match:
Event: 'OutboundRegistrationDetail'
+ ClientUri: 'sip:testuser at 127.0.0.5:41060'
requirements:
match:
ActionID: '12345'
@@ -51,13 +55,36 @@
OutboundProxy: ''
Transport: 'ipv4'
ContactUser: ''
- ClientUri: 'sip:testuser at 127.*'
ServerUri: 'sip:127.*'
Status: 'Unregistered|Rejected'
NextReg: '0'
- count: 2
- -
- type: 'headermatch'
+ count: 1
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'OutboundRegistrationDetail'
+ ClientUri: 'sip:testuser at 127.0.0.6:41070'
+ requirements:
+ match:
+ ActionID: '12345'
+ ObjectType: 'registration'
+ ObjectName: 'trunk1-reg-*'
+ OutboundAuth: 'trunk1-oauth'
+ AuthRejectionPermanent: 'true'
+ MaxRetries: '10'
+ ForbiddenRetryInterval: '0'
+ RetryInterval: '38'
+ Expiration: '3600'
+ OutboundProxy: ''
+ Transport: 'ipv4'
+ ContactUser: ''
+ ServerUri: 'sip:127.*'
+ Status: 'Unregistered|Rejected'
+ NextReg: '0'
+ count: 1
+ -
+ ami-events:
conditions:
match:
Event: 'AuthDetail'
@@ -74,8 +101,8 @@
Username: 'testuser'
count: 2
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'OutboundRegistrationDetailComplete'
@@ -86,3 +113,4 @@
Registered: '0'
NotRegistered: '2'
count: 1
+ stop_test:
diff --git a/tests/channels/pjsip/config_wizard/trunk/test-config.yaml b/tests/channels/pjsip/config_wizard/trunk/test-config.yaml
index cbb14eb..956e565 100644
--- a/tests/channels/pjsip/config_wizard/trunk/test-config.yaml
+++ b/tests/channels/pjsip/config_wizard/trunk/test-config.yaml
@@ -16,24 +16,28 @@
- pjsip
test-modules:
- # allow test_runner to find and run the local test
- add-test-to-search-path: 'True'
- add-relative-to-search-path: ['../']
test-object:
config-section: object-config
- typename: 'AMISendTest.AMISendTest'
+ typename: 'test_case.TestCaseModule'
modules:
-
config-section: 'ami-config'
- typename: 'ami.AMIEventModule'
+ typename: 'pluggable_modules.EventActionModule'
object-config:
reactor-timeout: 15
- ACTION: { "Action": "PJSIPShowEndpoint", "ActionID": "12345", "Endpoint": "trunk1" }
+ connect-ami: True
ami-config:
- -
- type: 'headermatch'
+ -
+ ami-start:
+ ami-actions:
+ action:
+ Action: 'PJSIPShowEndpoint'
+ ActionID: '12345'
+ Endpoint: 'trunk1'
+ -
+ ami-events:
conditions:
match:
Event: 'EndpointDetail'
@@ -121,8 +125,8 @@
DeviceState: 'Invalid|Not in use|Unavailable'
ActiveChannels: ''
count: 1
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'AorDetail'
@@ -144,8 +148,8 @@
ContactsRegistered: '0'
EndpointName: 'trunk1'
count: 1
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'ContactStatusDetail'
@@ -155,8 +159,8 @@
AOR: 'trunk1'
EndpointName: 'trunk1'
count: 2
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'AuthDetail'
@@ -173,8 +177,8 @@
Username: 'testuser'
EndpointName: 'trunk1'
count: 1
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'IdentifyDetail'
@@ -187,8 +191,8 @@
Endpoint: 'trunk1'
EndpointName: 'trunk1'
count: 1
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'TransportDetail'
@@ -218,8 +222,8 @@
Protocol: 'udp'
EndpointName: 'trunk'
count: 1
- -
- type: 'headermatch'
+ -
+ ami-events:
conditions:
match:
Event: 'EndpointDetailComplete'
@@ -229,4 +233,4 @@
EventList: 'Complete'
ListItems: '7'
count: 1
-
+ stop_test:
diff --git a/tests/channels/pjsip/qualify/AMISendTest.py b/tests/channels/pjsip/qualify/AMISendTest.py
deleted file mode 100644
index ead830c..0000000
--- a/tests/channels/pjsip/qualify/AMISendTest.py
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/env python
-'''
-Copyright (C) 2013, Digium, Inc.
-Kevin Harwell <kharwell at digium.com>
-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 sys
-
-sys.path.append("lib/python/asterisk")
-
-from test_case import TestCase
-
-class AMISendTest(TestCase):
- def __init__(self, path=None, config=None):
- super(AMISendTest, self).__init__(path, config)
- self.config = config
- self.action = config.get('ACTION')
- if not self.action:
- raise Exception('"ACTION" was not defined in test-config.yaml')
- self.create_asterisk()
-
- def run(self):
- super(AMISendTest, self).run()
- self.create_ami_factory()
-
- def ami_connect(self, ami):
- ami.sendDeferred(self.action).addCallback(self.__on_response)
-
- def __on_response(self, result):
- # stop test since done
- self.stop_reactor()
-
diff --git a/tests/channels/pjsip/qualify/no_qualify/test-config.yaml b/tests/channels/pjsip/qualify/no_qualify/test-config.yaml
index b9351d8..dd35507 100644
--- a/tests/channels/pjsip/qualify/no_qualify/test-config.yaml
+++ b/tests/channels/pjsip/qualify/no_qualify/test-config.yaml
@@ -13,24 +13,29 @@
- pjsip
test-modules:
- # allow test_runner to find and run the local test
- add-test-to-search-path: 'True'
- add-relative-to-search-path: ['../']
test-object:
config-section: object-config
- typename: 'AMISendTest.AMISendTest'
+ typename: 'test_case.TestCaseModule'
modules:
-
+ minversion: '12.0.0'
config-section: 'ami-config'
- typename: 'ami.AMIEventModule'
+ typename: 'pluggable_modules.EventActionModule'
object-config:
reactor-timeout: 15
- ACTION: { "Action": "PJSIPShowEndpoint", "ActionID": "12345", "Endpoint": "sipp" }
+ connect-ami: True
ami-config:
- -
- type: 'headermatch'
+ -
+ ami-start:
+ ami-actions:
+ action:
+ Action: 'PJSIPShowEndpoint'
+ ActionID: '12345'
+ Endpoint: 'sipp'
+ -
+ ami-events:
conditions:
match:
Event: 'EndpointDetail'
@@ -41,3 +46,4 @@
ObjectName: 'sipp'
DeviceState: 'Not in use'
count: 1
+ stop_test:
--
To view, visit https://gerrit.asterisk.org/153
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0d3e5298114bd4eb676537a816bc6e437036642b
Gerrit-PatchSet: 10
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: George Joseph <george.joseph at fairview5.com>
Gerrit-Reviewer: George Joseph <george.joseph at fairview5.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>
More information about the asterisk-commits
mailing list