From 82bcdba7f7ae383cd8322a6536690e8d391bd9fe Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 9 Dec 2024 18:55:32 +0800 Subject: [PATCH] pjsip/rest_api: Introduce a test for ChannelTransfer event Test that a SIP REFER is translated into a ChannelTransfer event when TRANSFERHANDLING=ari-only is set on the channel and that transfer_progress generates the necessary SIP NOTIFY messages. Be strict on the first ChannelTransfer event being received. Then only check that the transfer state is changing from not being present, to progress and finally answered. When answered delete all the channels and the bridge and the test wull succeed. --- .../configs/ast1/extensions.conf | 14 ++ .../configs/ast1/pjsip.conf | 12 ++ .../sipp/referee.xml | 126 +++++++++++++ .../sipp/referer.xml | 178 ++++++++++++++++++ .../test-config.yaml | 169 +++++++++++++++++ .../attended_transfer/tests.yaml | 2 +- 6 files changed, 500 insertions(+), 1 deletion(-) create mode 100644 tests/rest_api/external_interaction/attended_transfer/stasis_bridge_to_stasis_app_ari_only/configs/ast1/extensions.conf create mode 100644 tests/rest_api/external_interaction/attended_transfer/stasis_bridge_to_stasis_app_ari_only/configs/ast1/pjsip.conf create mode 100644 tests/rest_api/external_interaction/attended_transfer/stasis_bridge_to_stasis_app_ari_only/sipp/referee.xml create mode 100644 tests/rest_api/external_interaction/attended_transfer/stasis_bridge_to_stasis_app_ari_only/sipp/referer.xml create mode 100644 tests/rest_api/external_interaction/attended_transfer/stasis_bridge_to_stasis_app_ari_only/test-config.yaml diff --git a/tests/rest_api/external_interaction/attended_transfer/stasis_bridge_to_stasis_app_ari_only/configs/ast1/extensions.conf b/tests/rest_api/external_interaction/attended_transfer/stasis_bridge_to_stasis_app_ari_only/configs/ast1/extensions.conf new file mode 100644 index 000000000..46904d6e6 --- /dev/null +++ b/tests/rest_api/external_interaction/attended_transfer/stasis_bridge_to_stasis_app_ari_only/configs/ast1/extensions.conf @@ -0,0 +1,14 @@ +[default] + +exten => s,1,NoOp() + same => n,Answer() + same => n,Stasis(testsuite) + same => n,Hangup() + +exten => 1000,1,Answer + same => n,Stasis(testsuite,no_bridge) + same => n,Hangup + +exten => stasis,1,NoOp() + same => n,Answer() + same => n,Stasis(testsuite,test) diff --git a/tests/rest_api/external_interaction/attended_transfer/stasis_bridge_to_stasis_app_ari_only/configs/ast1/pjsip.conf b/tests/rest_api/external_interaction/attended_transfer/stasis_bridge_to_stasis_app_ari_only/configs/ast1/pjsip.conf new file mode 100644 index 000000000..3b49ddb7c --- /dev/null +++ b/tests/rest_api/external_interaction/attended_transfer/stasis_bridge_to_stasis_app_ari_only/configs/ast1/pjsip.conf @@ -0,0 +1,12 @@ +[local] +type=transport +protocol=udp +bind=127.0.0.1:5060 + +[bob] +type=endpoint +context=default +disallow=all +allow=ulaw +direct_media=no +set_var=PJSIP_TRANSFER_HANDLING=ari-only \ No newline at end of file diff --git a/tests/rest_api/external_interaction/attended_transfer/stasis_bridge_to_stasis_app_ari_only/sipp/referee.xml b/tests/rest_api/external_interaction/attended_transfer/stasis_bridge_to_stasis_app_ari_only/sipp/referee.xml new file mode 100644 index 000000000..1b9ed417e --- /dev/null +++ b/tests/rest_api/external_interaction/attended_transfer/stasis_bridge_to_stasis_app_ari_only/sipp/referee.xml @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ;tag=[call_number] + To: + Call-ID: [call_id] + CSeq: [cseq] INVITE + Contact: + Max-Forwards: 70 + Content-Type: application/sdp + Content-Length: [len] + + v=0 + o=- 1324901698 1324901698 IN IP[local_ip_type] [local_ip] + s=- + c=IN IP[media_ip_type] [media_ip] + t=0 0 + m=audio [media_port] RTP/AVP 0 101 + a=sendrecv + a=rtpmap:0 PCMU/8000 + a=rtpmap:101 telephone-event/8000 + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + Content-Length:0 + + ]]> + + + + + + + + + diff --git a/tests/rest_api/external_interaction/attended_transfer/stasis_bridge_to_stasis_app_ari_only/sipp/referer.xml b/tests/rest_api/external_interaction/attended_transfer/stasis_bridge_to_stasis_app_ari_only/sipp/referer.xml new file mode 100644 index 000000000..f9c890dd6 --- /dev/null +++ b/tests/rest_api/external_interaction/attended_transfer/stasis_bridge_to_stasis_app_ari_only/sipp/referer.xml @@ -0,0 +1,178 @@ + + + + + + + + + + + + + + + + + + + + + + + ;tag=[call_number] + To: + Call-ID: [call_id] + CSeq: [cseq] INVITE + Contact: + Content-Type: application/sdp + Max-Forwards: 70 + Content-Length: [len] + + v=0 + o=- 1324901698 1324901698 IN IP[local_ip_type] [local_ip] + s=- + c=IN IP[media_ip_type] [media_ip] + t=0 0 + m=audio [media_port] RTP/AVP 0 101 + a=sendrecv + a=rtpmap:0 PCMU/8000 + a=rtpmap:101 telephone-event/8000 + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + Max-Forwards: 70 + Refer-to: <[$remote_contact]?Replaces=REMOTE[$callid_chunk_1]%40[$callid_chunk_2]%3Bto-tag%3D[$remote_to_tag]%3Bfrom-tag%3D[$remote_from_tag]> + Referred-By: sip:bob@[local_ip] + Content-Length: 0 + + ]]> + + + + + + + Content-Length:0 + + ]]> + + + + + + Content-Length:0 + + ]]> + + + + ;tag=[call_number] + To: [peer_tag_param] + [last_Call-ID:] + CSeq: [cseq] BYE + Contact: sip:bob@[local_ip]:[local_port] + Max-Forwards: 70 + Subject: Performance Test + Content-Length: 0 + + ]]> + + + + + + + + + + diff --git a/tests/rest_api/external_interaction/attended_transfer/stasis_bridge_to_stasis_app_ari_only/test-config.yaml b/tests/rest_api/external_interaction/attended_transfer/stasis_bridge_to_stasis_app_ari_only/test-config.yaml new file mode 100644 index 000000000..2078c30b4 --- /dev/null +++ b/tests/rest_api/external_interaction/attended_transfer/stasis_bridge_to_stasis_app_ari_only/test-config.yaml @@ -0,0 +1,169 @@ +testinfo: + summary: | + "Verifies that appropriate ChannelTransfer, StasisStart, + and StasisEnd events are delivered when an ari-only transfer + occurs between a Stasis App and a Stasis Bridge." + description: | + "This test originates one call into Stasis(): + + Originated Channel -> Stasis(testsuite) + + It then starts two SIPp scenarios that call into the dialplan: + + SIPp #1 (referer.xml) -> Stasis(testsuite) + SIPp #2 (referee.xml) -> Stasis(testsuite,no_bridge) + + The two SIPp scenarios work together via 3PCC mode to pass + SIPp #2's call information back to SIPp #1 once both calls are up: + + SIPp #2 --3PCC(call information)-> SIPp #1 + + The test bridges the two channels in Stasis(testsuite): + + Originated Channel -> Stasis(testsuite) -> Bridge -> Stasis(testsuite) -> SIPp #1 + + SIPp #1 then performs an attended transfer using a REFER with + SIPp #2's call information which results in a ChannelTransferEvent with + the right information. + + Now that we have received the ChannelTransfer event we can delete the + channels and the test eneds." + +test-modules: + test-object: + typename: ari.AriTestObject + modules: + - + config-section: pluggable-config + typename: 'pluggable_modules.EventActionModule' + +pluggable-config: + - + ari-events: + match: + type: StasisStart + application: testsuite + args: [] + channel: + name: 'Local/s@default-.*' + count: 1 + ari-requests: + - + method: 'post' + uri: 'bridges/test_bridge' + - + method: 'post' + uri: 'bridges/test_bridge/addChannel' + params: + channel: '{channel.id}' + callback: + module: extension_bank + method: default_attended_transfer + - + ari-events: + match: + type: StasisStart + application: testsuite + args: ['test'] + count: 1 + ari-requests: + method: 'post' + uri: 'bridges/test_bridge/addChannel' + params: + channel: '{channel.id}' + - + ari-events: + match: + type: StasisStart + application: testsuite + args: ['no_bridge'] + count: 1 + - + ari-events: + match: + type: ChannelTransfer + refer_to: + destination_channel: + name: 'PJSIP/bob-.*' + dialplan: + app_data: 'testsuite,no_bridge' + app_name: 'Stasis' + context: 'default' + exten: '1000' + requested_destination: + destination: '1000' + protocol_id: 'REMOTE1-.*' + additional_protocol_params: + - parameter_name: 'from' + parameter_value: '1' + - parameter_name: 'to' + parameter_value: '.*' + referred_by: + bridge: + id: 'test_bridge' + connected_channel: + name: 'Local/s.*' + source_channel: + name: 'PJSIP/bob-.*' + dialplan: + app_data: 'testsuite,test' + nomatch: + state: 'channel.*' + count: 1 + ari-requests: + - + method: 'post' + uri: 'channels/{referred_by.source_channel.id}/transfer_progress' + params: + states: 'channel_progress' + - + ari-events: + match: + type: ChannelTransfer + refer_to: + requested_destination: + destination: '1000' + state: 'channel_progress' + count: 1 + ari-requests: + - + method: 'post' + uri: 'channels/{referred_by.source_channel.id}/transfer_progress' + params: + states: 'channel_answered' + - + ari-events: + match: + type: ChannelTransfer + refer_to: + requested_destination: + destination: '1000' + state: 'channel_answered' + count: 1 + ari-requests: + - + method: 'delete' + uri: 'channels/{referred_by.source_channel.id}' + - + method: 'delete' + uri: 'channels/{referred_by.connected_channel.id}' + - + method: 'delete' + uri: 'channels/{refer_to.destination_channel.id}' + - + method: 'delete' + uri: 'bridges/test_bridge' + +properties: + dependencies: + - python : autobahn.websocket + - python : requests + - python : twisted + - python : starpy + - asterisk : res_ari_channels + - asterisk : res_ari_bridges + - asterisk : chan_pjsip + tags: + - ARI + - pjsip + - refleaks diff --git a/tests/rest_api/external_interaction/attended_transfer/tests.yaml b/tests/rest_api/external_interaction/attended_transfer/tests.yaml index ea976609b..4feaadc7e 100644 --- a/tests/rest_api/external_interaction/attended_transfer/tests.yaml +++ b/tests/rest_api/external_interaction/attended_transfer/tests.yaml @@ -1,7 +1,7 @@ tests: - test: 'stasis_bridge_to_non_stasis_app' - test: 'stasis_bridge_to_stasis_app' + - test: 'stasis_bridge_to_stasis_app_ari_only' - test: 'non_stasis_app_to_stasis_bridge' - test: 'non_stasis_bridge_to_stasis_bridge' - dir: 'stasis_bridge_to_stasis_bridge' -