<p>Moritz Fain has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/testsuite/+/18418">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_ari_channels/res_pjsip: Added test for exposed protocol_id<br><br>This test checks whether the protocol_id is successfully exposed<br>and filled with a PJSIP style Call-ID.<br><br>ASTERISK-30027<br>Reported by: Moritz Fain<br><br>Change-Id: Ibc8a103b9e54d709aa39472fa2d77a969c1685ac<br>---<br>M addons/Makefile<br>A tests/rest_api/channels/originate_to_pjsip_endpoint/channel_originate.py<br>A tests/rest_api/channels/originate_to_pjsip_endpoint/configs/ast1/extensions.conf<br>A tests/rest_api/channels/originate_to_pjsip_endpoint/configs/ast1/pjsip.conf<br>A tests/rest_api/channels/originate_to_pjsip_endpoint/pjsip.conf<br>A tests/rest_api/channels/originate_to_pjsip_endpoint/test-config.yaml<br>M tests/rest_api/channels/tests.yaml<br>7 files changed, 175 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/18/18418/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/addons/Makefile b/addons/Makefile</span><br><span>index 2496d27..d4ea379 100644</span><br><span>--- a/addons/Makefile</span><br><span>+++ b/addons/Makefile</span><br><span>@@ -31,10 +31,10 @@</span><br><span> update:</span><br><span> @if [ -d starpy ]; then \</span><br><span> cd starpy; \</span><br><span style="color: hsl(0, 100%, 40%);">- if [ `git config --get remote.origin.url` = git://github.com/asterisk-org/starpy.git ]; then \</span><br><span style="color: hsl(0, 100%, 40%);">- git remote set-url origin git://github.com/asterisk/starpy.git git://github.com/asterisk-org/starpy.git; \</span><br><span style="color: hsl(120, 100%, 40%);">+ if [ `git config --get remote.origin.url` = https://github.com/asterisk/starpy ]; then \</span><br><span style="color: hsl(120, 100%, 40%);">+ git remote set-url origin https://github.com/asterisk/starpy; \</span><br><span> fi; \</span><br><span> git pull; \</span><br><span> else \</span><br><span style="color: hsl(0, 100%, 40%);">- git clone git://github.com/asterisk/starpy.git; \</span><br><span style="color: hsl(120, 100%, 40%);">+ git clone https://github.com/asterisk/starpy; \</span><br><span> fi</span><br><span>diff --git a/tests/rest_api/channels/originate_to_pjsip_endpoint/channel_originate.py b/tests/rest_api/channels/originate_to_pjsip_endpoint/channel_originate.py</span><br><span>new file mode 100644</span><br><span>index 0000000..241b2b2</span><br><span>--- /dev/null</span><br><span>+++ b/tests/rest_api/channels/originate_to_pjsip_endpoint/channel_originate.py</span><br><span>@@ -0,0 +1,40 @@</span><br><span style="color: hsl(120, 100%, 40%);">+'''</span><br><span style="color: hsl(120, 100%, 40%);">+Copyright (C) 2013, Digium, Inc.</span><br><span style="color: hsl(120, 100%, 40%);">+Joshua Colp <jcolp@digium.com></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+This program is free software, distributed under the terms of</span><br><span style="color: hsl(120, 100%, 40%);">+the GNU General Public License Version 2.</span><br><span style="color: hsl(120, 100%, 40%);">+'''</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+import logging</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+LOGGER = logging.getLogger(__name__)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+CHANNELS = 0</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+def on_kickoff_start(ari, event, test_object):</span><br><span style="color: hsl(120, 100%, 40%);">+ LOGGER.debug("on_kickoff_start(%r)" % event)</span><br><span style="color: hsl(120, 100%, 40%);">+ for x in xrange(15):</span><br><span style="color: hsl(120, 100%, 40%);">+ ari.post('channels',</span><br><span style="color: hsl(120, 100%, 40%);">+ endpoint='PJSIP/1000@endpoint1',</span><br><span style="color: hsl(120, 100%, 40%);">+ app='testsuite',</span><br><span style="color: hsl(120, 100%, 40%);">+ appArgs='blast')</span><br><span style="color: hsl(120, 100%, 40%);">+ ari.delete('channels', event['channel']['id'])</span><br><span style="color: hsl(120, 100%, 40%);">+ return True</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+def on_blast_start(ari, event, test_object):</span><br><span style="color: hsl(120, 100%, 40%);">+ LOGGER.debug("on_blast_start(%r)" % event)</span><br><span style="color: hsl(120, 100%, 40%);">+ return True</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+def on_channel_destroyed(ari, event, test_object):</span><br><span style="color: hsl(120, 100%, 40%);">+ global CHANNELS</span><br><span style="color: hsl(120, 100%, 40%);">+ LOGGER.debug("on_channel_destroyed: %s" % str(event.get('channel')))</span><br><span style="color: hsl(120, 100%, 40%);">+ CHANNELS += 1</span><br><span style="color: hsl(120, 100%, 40%);">+ if CHANNELS == 15:</span><br><span style="color: hsl(120, 100%, 40%);">+ LOGGER.info("All channels destroyed")</span><br><span style="color: hsl(120, 100%, 40%);">+ test_object.set_passed(True)</span><br><span style="color: hsl(120, 100%, 40%);">+ test_object.stop_reactor()</span><br><span style="color: hsl(120, 100%, 40%);">+ return True</span><br><span>diff --git a/tests/rest_api/channels/originate_to_pjsip_endpoint/configs/ast1/extensions.conf b/tests/rest_api/channels/originate_to_pjsip_endpoint/configs/ast1/extensions.conf</span><br><span>new file mode 100644</span><br><span>index 0000000..68e0987</span><br><span>--- /dev/null</span><br><span>+++ b/tests/rest_api/channels/originate_to_pjsip_endpoint/configs/ast1/extensions.conf</span><br><span>@@ -0,0 +1,13 @@</span><br><span style="color: hsl(120, 100%, 40%);">+[default]</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+exten => s,1,NoOp()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Answer()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Stasis(testsuite)</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Hangup()</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[default2]</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+exten => 1000,1,NoOp()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Answer()</span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,Hangup()</span><br><span>diff --git a/tests/rest_api/channels/originate_to_pjsip_endpoint/configs/ast1/pjsip.conf b/tests/rest_api/channels/originate_to_pjsip_endpoint/configs/ast1/pjsip.conf</span><br><span>new file mode 100644</span><br><span>index 0000000..f748994</span><br><span>--- /dev/null</span><br><span>+++ b/tests/rest_api/channels/originate_to_pjsip_endpoint/configs/ast1/pjsip.conf</span><br><span>@@ -0,0 +1,40 @@</span><br><span style="color: hsl(120, 100%, 40%);">+[global]</span><br><span style="color: hsl(120, 100%, 40%);">+debug=yes</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[transport1]</span><br><span style="color: hsl(120, 100%, 40%);">+type=transport</span><br><span style="color: hsl(120, 100%, 40%);">+protocol=udp</span><br><span style="color: hsl(120, 100%, 40%);">+bind=127.0.0.1:5060</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[endpoint1]</span><br><span style="color: hsl(120, 100%, 40%);">+type=endpoint</span><br><span style="color: hsl(120, 100%, 40%);">+context=default</span><br><span style="color: hsl(120, 100%, 40%);">+transport=transport1</span><br><span style="color: hsl(120, 100%, 40%);">+allow=!all,ulaw</span><br><span style="color: hsl(120, 100%, 40%);">+media_address=127.0.0.1</span><br><span style="color: hsl(120, 100%, 40%);">+direct_media=no</span><br><span style="color: hsl(120, 100%, 40%);">+aors=endpoint1_aor</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[endpoint1_aor]</span><br><span style="color: hsl(120, 100%, 40%);">+type=aor</span><br><span style="color: hsl(120, 100%, 40%);">+contact=sip:127.0.0.2:5060</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[transport2]</span><br><span style="color: hsl(120, 100%, 40%);">+type=transport</span><br><span style="color: hsl(120, 100%, 40%);">+protocol=udp</span><br><span style="color: hsl(120, 100%, 40%);">+bind=127.0.0.2:5060</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[endpoint2]</span><br><span style="color: hsl(120, 100%, 40%);">+type=endpoint</span><br><span style="color: hsl(120, 100%, 40%);">+context=default2</span><br><span style="color: hsl(120, 100%, 40%);">+transport=transport2</span><br><span style="color: hsl(120, 100%, 40%);">+allow=!all,ulaw</span><br><span style="color: hsl(120, 100%, 40%);">+media_address=127.0.0.2</span><br><span style="color: hsl(120, 100%, 40%);">+direct_media=no</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[endpoint2_identity]</span><br><span style="color: hsl(120, 100%, 40%);">+type=identify</span><br><span style="color: hsl(120, 100%, 40%);">+endpoint=endpoint2</span><br><span style="color: hsl(120, 100%, 40%);">+match=127.0.0.1</span><br><span>diff --git a/tests/rest_api/channels/originate_to_pjsip_endpoint/pjsip.conf b/tests/rest_api/channels/originate_to_pjsip_endpoint/pjsip.conf</span><br><span>new file mode 100644</span><br><span>index 0000000..f35f723</span><br><span>--- /dev/null</span><br><span>+++ b/tests/rest_api/channels/originate_to_pjsip_endpoint/pjsip.conf</span><br><span>@@ -0,0 +1,16 @@</span><br><span style="color: hsl(120, 100%, 40%);">+[global]</span><br><span style="color: hsl(120, 100%, 40%);">+debug=yes</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[transport-template](!)</span><br><span style="color: hsl(120, 100%, 40%);">+type=transport</span><br><span style="color: hsl(120, 100%, 40%);">+bind=127.0.0.1</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[transport-udp](transport-template)</span><br><span style="color: hsl(120, 100%, 40%);">+protocol=udp</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[endpoint-template](!)</span><br><span style="color: hsl(120, 100%, 40%);">+type=endpoint</span><br><span style="color: hsl(120, 100%, 40%);">+context=default</span><br><span style="color: hsl(120, 100%, 40%);">+allow=!all,ulaw</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[anonymous](endpoint-template)</span><br><span>diff --git a/tests/rest_api/channels/originate_to_pjsip_endpoint/test-config.yaml b/tests/rest_api/channels/originate_to_pjsip_endpoint/test-config.yaml</span><br><span>new file mode 100644</span><br><span>index 0000000..e689470</span><br><span>--- /dev/null</span><br><span>+++ b/tests/rest_api/channels/originate_to_pjsip_endpoint/test-config.yaml</span><br><span>@@ -0,0 +1,62 @@</span><br><span style="color: hsl(120, 100%, 40%);">+testinfo:</span><br><span style="color: hsl(120, 100%, 40%);">+ summary: Test originating calls to a Stasis application with PJSIP endpoint using ARI.</span><br><span style="color: hsl(120, 100%, 40%);">+ description: |</span><br><span style="color: hsl(120, 100%, 40%);">+ Originate a specific number of calls using ARI and verify they have a protocol_id set from PJSIP.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+test-modules:</span><br><span style="color: hsl(120, 100%, 40%);">+ add-test-to-search-path: True</span><br><span style="color: hsl(120, 100%, 40%);">+ test-object:</span><br><span style="color: hsl(120, 100%, 40%);">+ typename: ari.AriOriginateTestObject</span><br><span style="color: hsl(120, 100%, 40%);">+ config-section: test-config</span><br><span style="color: hsl(120, 100%, 40%);">+ modules:</span><br><span style="color: hsl(120, 100%, 40%);">+ -</span><br><span style="color: hsl(120, 100%, 40%);">+ config-section: ari-config</span><br><span style="color: hsl(120, 100%, 40%);">+ typename: ari.WebSocketEventModule</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+test-config:</span><br><span style="color: hsl(120, 100%, 40%);">+ stop-on-end: False</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ari-config:</span><br><span style="color: hsl(120, 100%, 40%);">+ apps: testsuite</span><br><span style="color: hsl(120, 100%, 40%);">+ events:</span><br><span style="color: hsl(120, 100%, 40%);">+ - conditions:</span><br><span style="color: hsl(120, 100%, 40%);">+ match:</span><br><span style="color: hsl(120, 100%, 40%);">+ type: StasisStart</span><br><span style="color: hsl(120, 100%, 40%);">+ application: testsuite</span><br><span style="color: hsl(120, 100%, 40%);">+ args: []</span><br><span style="color: hsl(120, 100%, 40%);">+ count: 1</span><br><span style="color: hsl(120, 100%, 40%);">+ callback:</span><br><span style="color: hsl(120, 100%, 40%);">+ module: channel_originate</span><br><span style="color: hsl(120, 100%, 40%);">+ method: on_kickoff_start</span><br><span style="color: hsl(120, 100%, 40%);">+ - conditions:</span><br><span style="color: hsl(120, 100%, 40%);">+ match:</span><br><span style="color: hsl(120, 100%, 40%);">+ type: StasisStart</span><br><span style="color: hsl(120, 100%, 40%);">+ application: testsuite</span><br><span style="color: hsl(120, 100%, 40%);">+ args: ['blast']</span><br><span style="color: hsl(120, 100%, 40%);">+ channel:</span><br><span style="color: hsl(120, 100%, 40%);">+ protocol_id: '^.{8}-.{4}-.{4}-.{4}-.{12}$'</span><br><span style="color: hsl(120, 100%, 40%);">+ count: 15</span><br><span style="color: hsl(120, 100%, 40%);">+ callback:</span><br><span style="color: hsl(120, 100%, 40%);">+ module: channel_originate</span><br><span style="color: hsl(120, 100%, 40%);">+ method: on_blast_start</span><br><span style="color: hsl(120, 100%, 40%);">+ - conditions:</span><br><span style="color: hsl(120, 100%, 40%);">+ match:</span><br><span style="color: hsl(120, 100%, 40%);">+ type: ChannelDestroyed</span><br><span style="color: hsl(120, 100%, 40%);">+ application: testsuite</span><br><span style="color: hsl(120, 100%, 40%);">+ count: 15</span><br><span style="color: hsl(120, 100%, 40%);">+ callback:</span><br><span style="color: hsl(120, 100%, 40%);">+ module: channel_originate</span><br><span style="color: hsl(120, 100%, 40%);">+ method: on_channel_destroyed</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+properties:</span><br><span style="color: hsl(120, 100%, 40%);">+ dependencies:</span><br><span style="color: hsl(120, 100%, 40%);">+ - python : autobahn.websocket</span><br><span style="color: hsl(120, 100%, 40%);">+ - python : requests</span><br><span style="color: hsl(120, 100%, 40%);">+ - python : twisted</span><br><span style="color: hsl(120, 100%, 40%);">+ - python : starpy</span><br><span style="color: hsl(120, 100%, 40%);">+ - asterisk : res_ari_channels</span><br><span style="color: hsl(120, 100%, 40%);">+ - asterisk : chan_pjsip</span><br><span style="color: hsl(120, 100%, 40%);">+ - asterisk : res_pjsip</span><br><span style="color: hsl(120, 100%, 40%);">+ tags:</span><br><span style="color: hsl(120, 100%, 40%);">+ - ARI</span><br><span style="color: hsl(120, 100%, 40%);">+ - PJSIP</span><br><span>diff --git a/tests/rest_api/channels/tests.yaml b/tests/rest_api/channels/tests.yaml</span><br><span>index b585099..9f2b4fd 100644</span><br><span>--- a/tests/rest_api/channels/tests.yaml</span><br><span>+++ b/tests/rest_api/channels/tests.yaml</span><br><span>@@ -4,6 +4,7 @@</span><br><span> - test: 'originate_with_id'</span><br><span> - test: 'originate_with_linkedid'</span><br><span> - test: 'originate_then_continue'</span><br><span style="color: hsl(120, 100%, 40%);">+ - test: 'originate_to_pjsip_endpoint'</span><br><span> - test: 'snoop_whisper'</span><br><span> - test: 'snoop_spy'</span><br><span> - test: 'snoop_id'</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/testsuite/+/18418">change 18418</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/testsuite/+/18418"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: testsuite </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ibc8a103b9e54d709aa39472fa2d77a969c1685ac </div>
<div style="display:none"> Gerrit-Change-Number: 18418 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Moritz Fain <moritz@fain.io> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>