[Asterisk-code-review] res_pjsip_aoc: Tests for AOC-D, AOC-E, AOC-S (testsuite[20])
Michael Kuron
asteriskteam at digium.com
Sun Nov 6 10:07:32 CST 2022
Michael Kuron has uploaded this change for review. ( https://gerrit.asterisk.org/c/testsuite/+/19538 )
Change subject: res_pjsip_aoc: Tests for AOC-D, AOC-E, AOC-S
......................................................................
res_pjsip_aoc: Tests for AOC-D, AOC-E, AOC-S
Also enable AMIPluggableActionModule to deal with a list of AMI headers
so that multiple of the same field can be supplied. AOC-S needs this,
but the Originate action also accepts multiple Variable headers.
ASTERISK-21502
Change-Id: I061a250b477593c4f07441a3d811e9981feb17b2
---
M configs/manager.conf
M lib/python/asterisk/ami.py
A tests/channels/pjsip/aoc/aoc_d_to_callee_in_200/configs/ast1/extensions.conf
A tests/channels/pjsip/aoc/aoc_d_to_callee_in_200/configs/ast1/pjsip.conf
A tests/channels/pjsip/aoc/aoc_d_to_callee_in_200/sipp/callee.xml
A tests/channels/pjsip/aoc/aoc_d_to_callee_in_200/test-config.yaml
A tests/channels/pjsip/aoc/aoc_d_to_callee_in_bye/configs/ast1/extensions.conf
A tests/channels/pjsip/aoc/aoc_d_to_callee_in_bye/configs/ast1/pjsip.conf
A tests/channels/pjsip/aoc/aoc_d_to_callee_in_bye/sipp/callee.xml
A tests/channels/pjsip/aoc/aoc_d_to_callee_in_bye/test-config.yaml
A tests/channels/pjsip/aoc/aoc_d_to_callee_in_info/configs/ast1/extensions.conf
A tests/channels/pjsip/aoc/aoc_d_to_callee_in_info/configs/ast1/pjsip.conf
A tests/channels/pjsip/aoc/aoc_d_to_callee_in_info/sipp/callee.xml
A tests/channels/pjsip/aoc/aoc_d_to_callee_in_info/test-config.yaml
A tests/channels/pjsip/aoc/aoc_d_to_caller_in_200/configs/ast1/extensions.conf
A tests/channels/pjsip/aoc/aoc_d_to_caller_in_200/configs/ast1/pjsip.conf
A tests/channels/pjsip/aoc/aoc_d_to_caller_in_200/sipp/caller.xml
A tests/channels/pjsip/aoc/aoc_d_to_caller_in_200/test-config.yaml
A tests/channels/pjsip/aoc/aoc_d_to_caller_in_bye/configs/ast1/extensions.conf
A tests/channels/pjsip/aoc/aoc_d_to_caller_in_bye/configs/ast1/pjsip.conf
A tests/channels/pjsip/aoc/aoc_d_to_caller_in_bye/sipp/caller.xml
A tests/channels/pjsip/aoc/aoc_d_to_caller_in_bye/test-config.yaml
A tests/channels/pjsip/aoc/aoc_d_to_caller_in_info/configs/ast1/extensions.conf
A tests/channels/pjsip/aoc/aoc_d_to_caller_in_info/configs/ast1/pjsip.conf
A tests/channels/pjsip/aoc/aoc_d_to_caller_in_info/sipp/caller.xml
A tests/channels/pjsip/aoc/aoc_d_to_caller_in_info/test-config.yaml
A tests/channels/pjsip/aoc/aoc_e_to_callee_in_200/configs/ast1/extensions.conf
A tests/channels/pjsip/aoc/aoc_e_to_callee_in_200/configs/ast1/pjsip.conf
A tests/channels/pjsip/aoc/aoc_e_to_callee_in_200/sipp/callee.xml
A tests/channels/pjsip/aoc/aoc_e_to_callee_in_200/test-config.yaml
A tests/channels/pjsip/aoc/aoc_e_to_callee_in_bye/configs/ast1/extensions.conf
A tests/channels/pjsip/aoc/aoc_e_to_callee_in_bye/configs/ast1/pjsip.conf
A tests/channels/pjsip/aoc/aoc_e_to_callee_in_bye/sipp/callee.xml
A tests/channels/pjsip/aoc/aoc_e_to_callee_in_bye/test-config.yaml
A tests/channels/pjsip/aoc/aoc_e_to_caller_in_200/configs/ast1/extensions.conf
A tests/channels/pjsip/aoc/aoc_e_to_caller_in_200/configs/ast1/pjsip.conf
A tests/channels/pjsip/aoc/aoc_e_to_caller_in_200/sipp/caller.xml
A tests/channels/pjsip/aoc/aoc_e_to_caller_in_200/test-config.yaml
A tests/channels/pjsip/aoc/aoc_e_to_caller_in_bye/configs/ast1/extensions.conf
A tests/channels/pjsip/aoc/aoc_e_to_caller_in_bye/configs/ast1/pjsip.conf
A tests/channels/pjsip/aoc/aoc_e_to_caller_in_bye/sipp/caller.xml
A tests/channels/pjsip/aoc/aoc_e_to_caller_in_bye/test-config.yaml
A tests/channels/pjsip/aoc/aoc_s_to_callee_in_info/configs/ast1/extensions.conf
A tests/channels/pjsip/aoc/aoc_s_to_callee_in_info/configs/ast1/pjsip.conf
A tests/channels/pjsip/aoc/aoc_s_to_callee_in_info/sipp/callee.xml
A tests/channels/pjsip/aoc/aoc_s_to_callee_in_info/test-config.yaml
A tests/channels/pjsip/aoc/aoc_s_to_caller_in_180/configs/ast1/extensions.conf
A tests/channels/pjsip/aoc/aoc_s_to_caller_in_180/configs/ast1/pjsip.conf
A tests/channels/pjsip/aoc/aoc_s_to_caller_in_180/sipp/caller.xml
A tests/channels/pjsip/aoc/aoc_s_to_caller_in_180/test-config.yaml
A tests/channels/pjsip/aoc/aoc_s_to_caller_in_183/configs/ast1/extensions.conf
A tests/channels/pjsip/aoc/aoc_s_to_caller_in_183/configs/ast1/pjsip.conf
A tests/channels/pjsip/aoc/aoc_s_to_caller_in_183/sipp/caller.xml
A tests/channels/pjsip/aoc/aoc_s_to_caller_in_183/test-config.yaml
A tests/channels/pjsip/aoc/aoc_s_to_caller_in_200/configs/ast1/extensions.conf
A tests/channels/pjsip/aoc/aoc_s_to_caller_in_200/configs/ast1/pjsip.conf
A tests/channels/pjsip/aoc/aoc_s_to_caller_in_200/sipp/caller.xml
A tests/channels/pjsip/aoc/aoc_s_to_caller_in_200/test-config.yaml
A tests/channels/pjsip/aoc/aoc_s_to_caller_in_info/configs/ast1/extensions.conf
A tests/channels/pjsip/aoc/aoc_s_to_caller_in_info/configs/ast1/pjsip.conf
A tests/channels/pjsip/aoc/aoc_s_to_caller_in_info/sipp/caller.xml
A tests/channels/pjsip/aoc/aoc_s_to_caller_in_info/test-config.yaml
A tests/channels/pjsip/aoc/tests.yaml
M tests/channels/pjsip/tests.yaml
64 files changed, 2,811 insertions(+), 1 deletion(-)
git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/38/19538/1
diff --git a/configs/manager.conf b/configs/manager.conf
index 993c8da..09cf8de 100644
--- a/configs/manager.conf
+++ b/configs/manager.conf
@@ -9,6 +9,6 @@
[user]
secret = mysecret
read = system,call,log,verbose,agent,user,config,dtmf,reporting,cdr,dialplan,test,agi
-write = system,call,agent,user,config,command,reporting,originate,agi,message
+write = system,call,agent,user,config,command,reporting,originate,agi,message,aoc
#include "manager.users.conf.inc"
diff --git a/lib/python/asterisk/ami.py b/lib/python/asterisk/ami.py
index 2e0fe4e..649d0c2 100644
--- a/lib/python/asterisk/ami.py
+++ b/lib/python/asterisk/ami.py
@@ -827,6 +827,13 @@
def replace_ami_vars(mydict, values):
+ if type(mydict) is list:
+ outlist = []
+ for item in mydict:
+ for key, value in item.items():
+ outlist.append((key, var_replace(value, values)))
+ return outlist
+
outdict = {}
for key, value in mydict.items():
outdict[key] = var_replace(value, values)
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_callee_in_200/configs/ast1/extensions.conf b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_200/configs/ast1/extensions.conf
new file mode 100644
index 0000000..af317af
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_200/configs/ast1/extensions.conf
@@ -0,0 +1,3 @@
+[default]
+exten => echo,1,Answer()
+same => n,Echo()
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_callee_in_200/configs/ast1/pjsip.conf b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_200/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..e7065cc
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_200/configs/ast1/pjsip.conf
@@ -0,0 +1,25 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local-transport-udp]
+type=transport
+bind=127.0.0.1
+protocol=udp
+
+[callee]
+type=endpoint
+aors=callee
+context=default
+allow=!all,ulaw
+rewrite_contact=yes
+direct_media=no
+send_aoc=yes
+
+[callee]
+type=aor
+max_contacts=1
+minimum_expiration=5
+default_expiration=30
+contact=sip:callee at 127.0.0.1:5062
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_callee_in_200/sipp/callee.xml b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_200/sipp/callee.xml
new file mode 100644
index 0000000..4dc58e3
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_200/sipp/callee.xml
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Receive AOC-D on inbound call hung up by us">
+ <Global variables="remote_tag" />
+ <recv request="INVITE" crlf="true">
+ <!-- Save the from tag. We'll need it when we send our BYE -->
+ <action>
+ <ereg regexp=".*(;tag=.*)"
+ header="From:"
+ search_in="hdr"
+ check_it="true"
+ assign_to="remote_tag"/>
+ </action>
+ </recv>
+
+ <send>
+ <![CDATA[
+ SIP/2.0 180 Ringing
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[pid]SIPpTag01[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <send retrans="500">
+ <![CDATA[
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[pid]SIPpTag01[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=user1 53655765 2353687637 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
+ a=rtpmap:0 PCMU/8000
+ ]]>
+ </send>
+
+ <recv request="ACK" />
+
+ <recv request="INFO">
+ </recv>
+
+ <send>
+ <![CDATA[
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ Call-ID: [call_id]
+ CSeq: [cseq] INFO
+ Contact: <sip:user1@[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <send retrans="500">
+ <![CDATA[
+ BYE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: callee <sip:callee@[local_ip]:[local_port]>;tag=[pid]SIPpTag01[call_number]
+ To:[$remote_tag]
+ [last_Call-ID:]
+ CSeq: [cseq] BYE
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <recv response="200" crlf="true">
+ <action>
+ <ereg regexp="application/vnd.etsi\.aoc\+xml" header="Content-Type:" search_in="hdr" check_it="true" assign_to="_"/>
+ <ereg regexp="<\?xml version="1\.0" encoding="UTF-8"\?>
+<aoc xmlns="http://uri\.etsi\.org/ngn/params/xml/simservs/aoc">
+ <aoc-d>
+ <charging-info>total</charging-info>
+ <recorded-charges>
+ <recorded-currency-units>
+ <currency-id>EUR</currency-id>
+ <currency-amount>0\.314</currency-amount>
+ </recorded-currency-units>
+ </recorded-charges>
+ </aoc-d>
+</aoc>" check_it="true" search_in="body" assign_to="_" />
+ </action>
+ </recv>
+
+</scenario>
\ No newline at end of file
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_callee_in_200/test-config.yaml b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_200/test-config.yaml
new file mode 100644
index 0000000..d291cc3
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_200/test-config.yaml
@@ -0,0 +1,68 @@
+info:
+ summary: 'Test AOC-D to callee who hangs up'
+ description: |
+ This uses an AOCMessage AMI to generate an AOC-D
+ event, adding to the 200 message sent in reply to
+ the callee's BYE message.
+
+test-modules:
+ test-object:
+ config-section: test-object-config
+ typename: sipp.SIPpTestCase
+ modules:
+ -
+ config-section: ami-config
+ typename: 'pluggable_modules.EventActionModule'
+
+test-object-config:
+ memcheck-delay-stop: 7
+ fail-on-any: True
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': { 'scenario': 'callee.xml', '-i': '127.0.0.1', '-p': '5062' } }
+
+ami-config:
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'FullyBooted'
+ ami-actions:
+ action:
+ Action: 'Originate'
+ ActionID: '1'
+ Channel: 'PJSIP/callee'
+ Exten: 'echo'
+ Context: 'default'
+ Priority: '1'
+ CallerID: 'echo <echo>'
+ -
+ ami-events:
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'Newexten'
+ Channel: 'PJSIP/callee-.*'
+ Application: 'Echo'
+ ami-actions:
+ action:
+ Action: 'AOCMessage'
+ Channel: '{channel}'
+ MsgType: 'D'
+ ChargeType: 'Currency'
+ CurrencyAmount: 314
+ CurrencyName: 'EUR'
+ CurrencyMultiplier: 'OneThousandth'
+ TotalType: 'SubTotal'
+
+properties:
+ dependencies:
+ - sipp :
+ version : 'v3.0'
+ - asterisk : 'chan_pjsip'
+ - asterisk : 'res_pjsip_aoc'
+ - asterisk : 'app_dial'
+ tags:
+ - PJSIP
+
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_callee_in_bye/configs/ast1/extensions.conf b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_bye/configs/ast1/extensions.conf
new file mode 100644
index 0000000..f7b9b0e
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_bye/configs/ast1/extensions.conf
@@ -0,0 +1,4 @@
+[default]
+exten => echo,1,Answer()
+same => n,Wait(2)
+same => n,Echo()
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_callee_in_bye/configs/ast1/pjsip.conf b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_bye/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..e7065cc
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_bye/configs/ast1/pjsip.conf
@@ -0,0 +1,25 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local-transport-udp]
+type=transport
+bind=127.0.0.1
+protocol=udp
+
+[callee]
+type=endpoint
+aors=callee
+context=default
+allow=!all,ulaw
+rewrite_contact=yes
+direct_media=no
+send_aoc=yes
+
+[callee]
+type=aor
+max_contacts=1
+minimum_expiration=5
+default_expiration=30
+contact=sip:callee at 127.0.0.1:5062
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_callee_in_bye/sipp/callee.xml b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_bye/sipp/callee.xml
new file mode 100644
index 0000000..2892cf6
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_bye/sipp/callee.xml
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Receive AOC-D on inbound call hung up by the other side">
+ <Global variables="remote_tag" />
+ <recv request="INVITE" crlf="true">
+ <!-- Save the from tag. We'll need it when we send our BYE -->
+ <action>
+ <ereg regexp=".*(;tag=.*)"
+ header="From:"
+ search_in="hdr"
+ check_it="true"
+ assign_to="remote_tag"/>
+ </action>
+ </recv>
+
+ <send>
+ <![CDATA[
+ SIP/2.0 180 Ringing
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[pid]SIPpTag01[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <send retrans="500">
+ <![CDATA[
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[pid]SIPpTag01[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=user1 53655765 2353687637 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
+ a=rtpmap:0 PCMU/8000
+ ]]>
+ </send>
+
+ <recv request="ACK" />
+
+ <recv request="INFO">
+ </recv>
+
+ <send>
+ <![CDATA[
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ Call-ID: [call_id]
+ CSeq: [cseq] INFO
+ Contact: <sip:user1@[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <recv request="BYE">
+ <action>
+ <ereg regexp="application/vnd.etsi\.aoc\+xml" header="Content-Type:" search_in="hdr" check_it="true" assign_to="_"/>
+ <ereg regexp="<\?xml version="1\.0" encoding="UTF-8"\?>
+<aoc xmlns="http://uri\.etsi\.org/ngn/params/xml/simservs/aoc">
+ <aoc-d>
+ <charging-info>total</charging-info>
+ <recorded-charges>
+ <free-charge />
+ </recorded-charges>
+ </aoc-d>
+</aoc>" check_it="true" search_in="body" assign_to="_" />
+ </action>
+ </recv>
+
+ <send retrans="500">
+ <![CDATA[
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[pid]SIPpTag01[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+</scenario>
\ No newline at end of file
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_callee_in_bye/test-config.yaml b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_bye/test-config.yaml
new file mode 100644
index 0000000..198dc03
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_bye/test-config.yaml
@@ -0,0 +1,76 @@
+info:
+ summary: 'Test AOC-D to callee after caller hangs up'
+ description: |
+ This uses an AOCMessage AMI to generate an AOC-D
+ event, adding to the BYE message sent to the callee.
+
+test-modules:
+ test-object:
+ config-section: test-object-config
+ typename: sipp.SIPpTestCase
+ modules:
+ -
+ config-section: ami-config
+ typename: 'pluggable_modules.EventActionModule'
+
+test-object-config:
+ memcheck-delay-stop: 7
+ fail-on-any: True
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': { 'scenario': 'callee.xml', '-i': '127.0.0.1', '-p': '5062' } }
+
+ami-config:
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'FullyBooted'
+ ami-actions:
+ action:
+ Action: 'Originate'
+ ActionID: '1'
+ Channel: 'PJSIP/callee'
+ Exten: 'echo'
+ Context: 'default'
+ Priority: '1'
+ CallerID: 'echo <echo>'
+ -
+ ami-events:
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'Newexten'
+ Channel: 'PJSIP/callee-.*'
+ Application: 'Wait'
+ ami-actions:
+ action:
+ Action: 'AOCMessage'
+ Channel: '{channel}'
+ MsgType: 'D'
+ ChargeType: 'Free'
+ TotalType: 'SubTotal'
+ -
+ ami-events:
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'Newexten'
+ Channel: 'PJSIP/callee-.*'
+ Application: 'Echo'
+ ami-actions:
+ action:
+ Action: 'Hangup'
+ Channel: '{channel}'
+
+properties:
+ dependencies:
+ - sipp :
+ version : 'v3.0'
+ - asterisk : 'chan_pjsip'
+ - asterisk : 'res_pjsip_aoc'
+ - asterisk : 'app_dial'
+ tags:
+ - PJSIP
+
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_callee_in_info/configs/ast1/extensions.conf b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_info/configs/ast1/extensions.conf
new file mode 100644
index 0000000..af317af
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_info/configs/ast1/extensions.conf
@@ -0,0 +1,3 @@
+[default]
+exten => echo,1,Answer()
+same => n,Echo()
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_callee_in_info/configs/ast1/pjsip.conf b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_info/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..e7065cc
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_info/configs/ast1/pjsip.conf
@@ -0,0 +1,25 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local-transport-udp]
+type=transport
+bind=127.0.0.1
+protocol=udp
+
+[callee]
+type=endpoint
+aors=callee
+context=default
+allow=!all,ulaw
+rewrite_contact=yes
+direct_media=no
+send_aoc=yes
+
+[callee]
+type=aor
+max_contacts=1
+minimum_expiration=5
+default_expiration=30
+contact=sip:callee at 127.0.0.1:5062
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_callee_in_info/sipp/callee.xml b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_info/sipp/callee.xml
new file mode 100644
index 0000000..13d8eaa
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_info/sipp/callee.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Receive AOC-D on inbound call">
+ <Global variables="remote_tag" />
+ <recv request="INVITE" crlf="true">
+ <!-- Save the from tag. We'll need it when we send our BYE -->
+ <action>
+ <ereg regexp=".*(;tag=.*)"
+ header="From:"
+ search_in="hdr"
+ check_it="true"
+ assign_to="remote_tag"/>
+ </action>
+ </recv>
+
+ <send>
+ <![CDATA[
+ SIP/2.0 180 Ringing
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[pid]SIPpTag01[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <send retrans="500">
+ <![CDATA[
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[pid]SIPpTag01[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=user1 53655765 2353687637 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
+ a=rtpmap:0 PCMU/8000
+ ]]>
+ </send>
+
+ <recv request="ACK" />
+
+ <recv request="INFO">
+ <action>
+ <ereg regexp="application/vnd.etsi\.aoc\+xml" header="Content-Type:" search_in="hdr" check_it="true" assign_to="_"/>
+ <ereg regexp="<\?xml version="1\.0" encoding="UTF-8"\?>
+<aoc xmlns="http://uri\.etsi\.org/ngn/params/xml/simservs/aoc">
+ <aoc-d>
+ <charging-info>subtotal</charging-info>
+ <recorded-charges>
+ <recorded-currency-units>
+ <currency-id>EUR</currency-id>
+ <currency-amount>0\.042</currency-amount>
+ </recorded-currency-units>
+ </recorded-charges>
+ </aoc-d>
+</aoc>" check_it="true" search_in="body" assign_to="_" />
+ </action>
+ </recv>
+
+ <send>
+ <![CDATA[
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ Call-ID: [call_id]
+ CSeq: [cseq] INFO
+ Contact: <sip:user1@[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <send retrans="500">
+ <![CDATA[
+ BYE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: callee <sip:callee@[local_ip]:[local_port]>;tag=[pid]SIPpTag01[call_number]
+ To:[$remote_tag]
+ [last_Call-ID:]
+ CSeq: [cseq] BYE
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <recv response="200" />
+
+</scenario>
\ No newline at end of file
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_callee_in_info/test-config.yaml b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_info/test-config.yaml
new file mode 100644
index 0000000..ccab6b4
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_callee_in_info/test-config.yaml
@@ -0,0 +1,68 @@
+info:
+ summary: 'Test AOC-D to callee'
+ description: |
+ This uses an AOCMessage AMI to generate an AOC-D
+ event, generating a SIP INFO message sent to the
+ callee.
+
+test-modules:
+ test-object:
+ config-section: test-object-config
+ typename: sipp.SIPpTestCase
+ modules:
+ -
+ config-section: ami-config
+ typename: 'pluggable_modules.EventActionModule'
+
+test-object-config:
+ memcheck-delay-stop: 7
+ fail-on-any: True
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': { 'scenario': 'callee.xml', '-i': '127.0.0.1', '-p': '5062' } }
+
+ami-config:
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'FullyBooted'
+ ami-actions:
+ action:
+ Action: 'Originate'
+ ActionID: '1'
+ Channel: 'PJSIP/callee'
+ Exten: 'echo'
+ Context: 'default'
+ Priority: '1'
+ CallerID: 'echo <echo>'
+ -
+ ami-events:
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'Newexten'
+ Channel: 'PJSIP/callee-.*'
+ Application: 'Echo'
+ ami-actions:
+ action:
+ Action: 'AOCMessage'
+ Channel: '{channel}'
+ MsgType: 'D'
+ ChargeType: 'Currency'
+ CurrencyAmount: 42
+ CurrencyName: 'EUR'
+ CurrencyMultiplier: 'OneThousandth'
+ TotalType: 'SubTotal'
+
+properties:
+ dependencies:
+ - sipp :
+ version : 'v3.0'
+ - asterisk : 'chan_pjsip'
+ - asterisk : 'res_pjsip_aoc'
+ - asterisk : 'app_dial'
+ tags:
+ - PJSIP
+
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_caller_in_200/configs/ast1/extensions.conf b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_200/configs/ast1/extensions.conf
new file mode 100644
index 0000000..af317af
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_200/configs/ast1/extensions.conf
@@ -0,0 +1,3 @@
+[default]
+exten => echo,1,Answer()
+same => n,Echo()
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_caller_in_200/configs/ast1/pjsip.conf b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_200/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..feb5ba0
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_200/configs/ast1/pjsip.conf
@@ -0,0 +1,25 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local-transport-udp]
+type=transport
+bind=127.0.0.1
+protocol=udp
+
+[caller]
+type=endpoint
+aors=caller
+context=default
+allow=!all,ulaw
+rewrite_contact=yes
+direct_media=no
+send_aoc=yes
+
+[caller]
+type=aor
+max_contacts=1
+minimum_expiration=5
+default_expiration=30
+contact=sip:caller at 127.0.0.1:5062
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_caller_in_200/sipp/caller.xml b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_200/sipp/caller.xml
new file mode 100644
index 0000000..2cfdc28
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_200/sipp/caller.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Receive AOC-D on outbound call hung up by us">
+ <send retrans="500">
+ <![CDATA[
+ INVITE sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:caller@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>
+ Call-ID: [call_id]
+ CSeq: 1 INVITE
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=phoneA 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+ s=-
+ c=IN IP[media_ip_type] [media_ip]
+ t=0 0
+ m=audio 6000 RTP/AVP 0
+ a=rtpmap:0 PCMU/8000
+ ]]>
+ </send>
+
+ <recv response="100" optional="true">
+ </recv>
+
+ <recv response="180" optional="true">
+ </recv>
+
+ <recv response="200" rtd="true">
+ </recv>
+
+ <send>
+ <![CDATA[
+ ACK sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:caller@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>[peer_tag_param]
+ Call-ID: [call_id]
+ CSeq: 1 ACK
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <recv request="INFO">
+ </recv>
+
+ <send>
+ <![CDATA[
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ Call-ID: [call_id]
+ CSeq: [cseq] INFO
+ Contact: <sip:user1@[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <send retrans="500">
+ <![CDATA[
+ BYE sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:[service]@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>[peer_tag_param]
+ Call-ID: [call_id]
+ CSeq: 2 BYE
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Subject: Test
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <recv response="200" crlf="true">
+ <action>
+ <ereg regexp="application/vnd.etsi\.aoc\+xml" header="Content-Type:" search_in="hdr" check_it="true" assign_to="_"/>
+ <ereg regexp="<\?xml version="1\.0" encoding="UTF-8"\?>
+<aoc xmlns="http://uri\.etsi\.org/ngn/params/xml/simservs/aoc">
+ <aoc-d>
+ <charging-info>total</charging-info>
+ <recorded-charges>
+ <recorded-currency-units>
+ <currency-id>UNIT</currency-id>
+ <currency-amount>314</currency-amount>
+ </recorded-currency-units>
+ </recorded-charges>
+ </aoc-d>
+</aoc>" check_it="true" search_in="body" assign_to="_" />
+ </action>
+ </recv>
+
+</scenario>
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_caller_in_200/test-config.yaml b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_200/test-config.yaml
new file mode 100644
index 0000000..da5c429
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_200/test-config.yaml
@@ -0,0 +1,52 @@
+info:
+ summary: 'Test AOC-D to caller who hangs up'
+ description: |
+ This uses an AOCMessage AMI to generate an AOC-D
+ event, adding to the 200 message sent in reply to
+ the caller's BYE message.
+
+test-modules:
+ test-object:
+ config-section: test-object-config
+ typename: sipp.SIPpTestCase
+ modules:
+ -
+ config-section: ami-config
+ typename: 'pluggable_modules.EventActionModule'
+
+test-object-config:
+ memcheck-delay-stop: 7
+ fail-on-any: True
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': { 'scenario': 'caller.xml', '-i': '127.0.0.1', '-p': '5062' } }
+
+ami-config:
+ -
+ ami-events:
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'Newexten'
+ Channel: 'PJSIP/caller-.*'
+ Application: 'Echo'
+ ami-actions:
+ action:
+ Action: 'AOCMessage'
+ Channel: '{channel}'
+ MsgType: 'D'
+ ChargeType: 'Unit'
+ 'UnitAmount(0)': 314
+ TotalType: 'SubTotal'
+
+properties:
+ dependencies:
+ - sipp :
+ version : 'v3.0'
+ - asterisk : 'chan_pjsip'
+ - asterisk : 'res_pjsip_aoc'
+ - asterisk : 'app_dial'
+ tags:
+ - PJSIP
+
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_caller_in_bye/configs/ast1/extensions.conf b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_bye/configs/ast1/extensions.conf
new file mode 100644
index 0000000..f7b9b0e
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_bye/configs/ast1/extensions.conf
@@ -0,0 +1,4 @@
+[default]
+exten => echo,1,Answer()
+same => n,Wait(2)
+same => n,Echo()
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_caller_in_bye/configs/ast1/pjsip.conf b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_bye/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..feb5ba0
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_bye/configs/ast1/pjsip.conf
@@ -0,0 +1,25 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local-transport-udp]
+type=transport
+bind=127.0.0.1
+protocol=udp
+
+[caller]
+type=endpoint
+aors=caller
+context=default
+allow=!all,ulaw
+rewrite_contact=yes
+direct_media=no
+send_aoc=yes
+
+[caller]
+type=aor
+max_contacts=1
+minimum_expiration=5
+default_expiration=30
+contact=sip:caller at 127.0.0.1:5062
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_caller_in_bye/sipp/caller.xml b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_bye/sipp/caller.xml
new file mode 100644
index 0000000..d96dcc4
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_bye/sipp/caller.xml
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Receive AOC-D on outbound call hung up by the other side">
+ <send retrans="500">
+ <![CDATA[
+ INVITE sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:caller@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>
+ Call-ID: [call_id]
+ CSeq: 1 INVITE
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=phoneA 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+ s=-
+ c=IN IP[media_ip_type] [media_ip]
+ t=0 0
+ m=audio 6000 RTP/AVP 0
+ a=rtpmap:0 PCMU/8000
+ ]]>
+ </send>
+
+ <recv response="100" optional="true">
+ </recv>
+
+ <recv response="180" optional="true">
+ </recv>
+
+ <recv response="200" rtd="true">
+ </recv>
+
+ <send>
+ <![CDATA[
+ ACK sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:caller@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>[peer_tag_param]
+ Call-ID: [call_id]
+ CSeq: 1 ACK
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <recv request="INFO">
+ </recv>
+
+ <send>
+ <![CDATA[
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ Call-ID: [call_id]
+ CSeq: [cseq] INFO
+ Contact: <sip:user1@[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <recv request="BYE">
+ <action>
+ <ereg regexp="application/vnd.etsi\.aoc\+xml" header="Content-Type:" search_in="hdr" check_it="true" assign_to="_"/>
+ <ereg regexp="<\?xml version="1\.0" encoding="UTF-8"\?>
+<aoc xmlns="http://uri\.etsi\.org/ngn/params/xml/simservs/aoc">
+ <aoc-d>
+ <charging-info>total</charging-info>
+ <recorded-charges>
+ <recorded-currency-units>
+ <currency-id>EUR</currency-id>
+ <currency-amount>0\.3</currency-amount>
+ </recorded-currency-units>
+ </recorded-charges>
+ </aoc-d>
+</aoc>" check_it="true" search_in="body" assign_to="_" />
+ </action>
+ </recv>
+
+ <send retrans="500">
+ <![CDATA[
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[pid]SIPpTag01[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+</scenario>
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_caller_in_bye/test-config.yaml b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_bye/test-config.yaml
new file mode 100644
index 0000000..270a7ba
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_bye/test-config.yaml
@@ -0,0 +1,67 @@
+info:
+ summary: 'Test AOC-D to caller after callee hangs up'
+ description: |
+ This uses an AOCMessage AMI to generate an AOC-D
+ event, adding to the BYE message sent to the caller'.
+
+test-modules:
+ test-object:
+ config-section: test-object-config
+ typename: sipp.SIPpTestCase
+ modules:
+ -
+ config-section: ami-config
+ typename: 'pluggable_modules.EventActionModule'
+
+test-object-config:
+ memcheck-delay-stop: 7
+ fail-on-any: True
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': { 'scenario': 'caller.xml', '-i': '127.0.0.1', '-p': '5062' } }
+
+ami-config:
+ -
+ ami-events:
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'Newexten'
+ Channel: 'PJSIP/caller-.*'
+ Application: 'Wait'
+ ami-actions:
+ action:
+ Action: 'AOCMessage'
+ Channel: '{channel}'
+ MsgType: 'D'
+ ChargeType: 'Currency'
+ CurrencyAmount: 3
+ CurrencyName: 'EUR'
+ CurrencyMultiplier: 'OneTenth'
+ TotalType: 'SubTotal'
+ expected:
+ Response: 'Success'
+ -
+ ami-events:
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'Newexten'
+ Channel: 'PJSIP/caller-.*'
+ Application: 'Echo'
+ ami-actions:
+ action:
+ Action: 'Hangup'
+ Channel: '{channel}'
+
+properties:
+ dependencies:
+ - sipp :
+ version : 'v3.0'
+ - asterisk : 'chan_pjsip'
+ - asterisk : 'res_pjsip_aoc'
+ - asterisk : 'app_dial'
+ tags:
+ - PJSIP
+
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_caller_in_info/configs/ast1/extensions.conf b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_info/configs/ast1/extensions.conf
new file mode 100644
index 0000000..af317af
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_info/configs/ast1/extensions.conf
@@ -0,0 +1,3 @@
+[default]
+exten => echo,1,Answer()
+same => n,Echo()
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_caller_in_info/configs/ast1/pjsip.conf b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_info/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..feb5ba0
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_info/configs/ast1/pjsip.conf
@@ -0,0 +1,25 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local-transport-udp]
+type=transport
+bind=127.0.0.1
+protocol=udp
+
+[caller]
+type=endpoint
+aors=caller
+context=default
+allow=!all,ulaw
+rewrite_contact=yes
+direct_media=no
+send_aoc=yes
+
+[caller]
+type=aor
+max_contacts=1
+minimum_expiration=5
+default_expiration=30
+contact=sip:caller at 127.0.0.1:5062
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_caller_in_info/sipp/caller.xml b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_info/sipp/caller.xml
new file mode 100644
index 0000000..9461260
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_info/sipp/caller.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Receive AOC-D on outbound call">
+ <send retrans="500">
+ <![CDATA[
+ INVITE sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:caller@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>
+ Call-ID: [call_id]
+ CSeq: 1 INVITE
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=phoneA 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+ s=-
+ c=IN IP[media_ip_type] [media_ip]
+ t=0 0
+ m=audio 6000 RTP/AVP 0
+ a=rtpmap:0 PCMU/8000
+ ]]>
+ </send>
+
+ <recv response="100" optional="true">
+ </recv>
+
+ <recv response="180" optional="true">
+ </recv>
+
+ <recv response="200" rtd="true">
+ </recv>
+
+ <send>
+ <![CDATA[
+ ACK sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:caller@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>[peer_tag_param]
+ Call-ID: [call_id]
+ CSeq: 1 ACK
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <recv request="INFO">
+ <action>
+ <ereg regexp="application/vnd.etsi\.aoc\+xml" header="Content-Type:" search_in="hdr" check_it="true" assign_to="_"/>
+ <ereg regexp="<\?xml version="1\.0" encoding="UTF-8"\?>
+<aoc xmlns="http://uri\.etsi\.org/ngn/params/xml/simservs/aoc">
+ <aoc-d>
+ <charging-info>subtotal</charging-info>
+ <recorded-charges>
+ <free-charge />
+ </recorded-charges>
+ </aoc-d>
+</aoc>" check_it="true" search_in="body" assign_to="_" />
+ </action>
+ </recv>
+
+ <send>
+ <![CDATA[
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ Call-ID: [call_id]
+ CSeq: [cseq] INFO
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <send retrans="500">
+ <![CDATA[
+ BYE sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:[service]@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>[peer_tag_param]
+ Call-ID: [call_id]
+ CSeq: 2 BYE
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Subject: Test
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <recv response="200" crlf="true">
+ </recv>
+
+</scenario>
diff --git a/tests/channels/pjsip/aoc/aoc_d_to_caller_in_info/test-config.yaml b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_info/test-config.yaml
new file mode 100644
index 0000000..e406cd6
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_d_to_caller_in_info/test-config.yaml
@@ -0,0 +1,51 @@
+info:
+ summary: 'Test AOC-D to caller'
+ description: |
+ This uses an AOCMessage AMI to generate an AOC-D
+ event, generating a SIP INFO message sent to the
+ caller.
+
+test-modules:
+ test-object:
+ config-section: test-object-config
+ typename: sipp.SIPpTestCase
+ modules:
+ -
+ config-section: ami-config
+ typename: 'pluggable_modules.EventActionModule'
+
+test-object-config:
+ memcheck-delay-stop: 7
+ fail-on-any: True
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': { 'scenario': 'caller.xml', '-i': '127.0.0.1', '-p': '5062' } }
+
+ami-config:
+ -
+ ami-events:
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'Newexten'
+ Channel: 'PJSIP/caller-.*'
+ Application: 'Echo'
+ ami-actions:
+ action:
+ Action: 'AOCMessage'
+ Channel: '{channel}'
+ MsgType: 'D'
+ ChargeType: 'Free'
+ TotalType: 'SubTotal'
+
+properties:
+ dependencies:
+ - sipp :
+ version : 'v3.0'
+ - asterisk : 'chan_pjsip'
+ - asterisk : 'res_pjsip_aoc'
+ - asterisk : 'app_dial'
+ tags:
+ - PJSIP
+
diff --git a/tests/channels/pjsip/aoc/aoc_e_to_callee_in_200/configs/ast1/extensions.conf b/tests/channels/pjsip/aoc/aoc_e_to_callee_in_200/configs/ast1/extensions.conf
new file mode 100644
index 0000000..af317af
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_e_to_callee_in_200/configs/ast1/extensions.conf
@@ -0,0 +1,3 @@
+[default]
+exten => echo,1,Answer()
+same => n,Echo()
diff --git a/tests/channels/pjsip/aoc/aoc_e_to_callee_in_200/configs/ast1/pjsip.conf b/tests/channels/pjsip/aoc/aoc_e_to_callee_in_200/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..e7065cc
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_e_to_callee_in_200/configs/ast1/pjsip.conf
@@ -0,0 +1,25 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local-transport-udp]
+type=transport
+bind=127.0.0.1
+protocol=udp
+
+[callee]
+type=endpoint
+aors=callee
+context=default
+allow=!all,ulaw
+rewrite_contact=yes
+direct_media=no
+send_aoc=yes
+
+[callee]
+type=aor
+max_contacts=1
+minimum_expiration=5
+default_expiration=30
+contact=sip:callee at 127.0.0.1:5062
diff --git a/tests/channels/pjsip/aoc/aoc_e_to_callee_in_200/sipp/callee.xml b/tests/channels/pjsip/aoc/aoc_e_to_callee_in_200/sipp/callee.xml
new file mode 100644
index 0000000..c5b2013
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_e_to_callee_in_200/sipp/callee.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Receive AOC-E on inbound call hung up by us">
+ <Global variables="remote_tag" />
+ <recv request="INVITE" crlf="true">
+ <!-- Save the from tag. We'll need it when we send our BYE -->
+ <action>
+ <ereg regexp=".*(;tag=.*)"
+ header="From:"
+ search_in="hdr"
+ check_it="true"
+ assign_to="remote_tag"/>
+ </action>
+ </recv>
+
+ <send>
+ <![CDATA[
+ SIP/2.0 180 Ringing
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[pid]SIPpTag01[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <send retrans="500">
+ <![CDATA[
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[pid]SIPpTag01[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=user1 53655765 2353687637 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
+ a=rtpmap:0 PCMU/8000
+ ]]>
+ </send>
+
+ <recv request="ACK" />
+
+ <pause milliseconds="2000"/>
+
+ <send retrans="500">
+ <![CDATA[
+ BYE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: callee <sip:callee@[local_ip]:[local_port]>;tag=[pid]SIPpTag01[call_number]
+ To:[$remote_tag]
+ [last_Call-ID:]
+ CSeq: [cseq] BYE
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <recv response="200" crlf="true">
+ <action>
+ <ereg regexp="application/vnd.etsi\.aoc\+xml" header="Content-Type:" search_in="hdr" check_it="true" assign_to="_"/>
+ <ereg regexp="<\?xml version="1\.0" encoding="UTF-8"\?>
+<aoc xmlns="http://uri\.etsi\.org/ngn/params/xml/simservs/aoc">
+ <aoc-e>
+ <recorded-charges>
+ <recorded-currency-units>
+ <currency-id>EUR</currency-id>
+ <currency-amount>0\.314</currency-amount>
+ </recorded-currency-units>
+ </recorded-charges>
+ </aoc-e>
+</aoc>" check_it="true" search_in="body" assign_to="_" />
+ </action>
+ </recv>
+
+</scenario>
\ No newline at end of file
diff --git a/tests/channels/pjsip/aoc/aoc_e_to_callee_in_200/test-config.yaml b/tests/channels/pjsip/aoc/aoc_e_to_callee_in_200/test-config.yaml
new file mode 100644
index 0000000..a3fc31c
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_e_to_callee_in_200/test-config.yaml
@@ -0,0 +1,67 @@
+info:
+ summary: 'Test AOC-E to callee who hangs up'
+ description: |
+ This uses an AOCMessage AMI to generate an AOC-E
+ event, adding to the 200 message sent in reply to
+ the callee's BYE message.
+
+test-modules:
+ test-object:
+ config-section: test-object-config
+ typename: sipp.SIPpTestCase
+ modules:
+ -
+ config-section: ami-config
+ typename: 'pluggable_modules.EventActionModule'
+
+test-object-config:
+ memcheck-delay-stop: 7
+ fail-on-any: True
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': { 'scenario': 'callee.xml', '-i': '127.0.0.1', '-p': '5062' } }
+
+ami-config:
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'FullyBooted'
+ ami-actions:
+ action:
+ Action: 'Originate'
+ ActionID: '1'
+ Channel: 'PJSIP/callee'
+ Exten: 'echo'
+ Context: 'default'
+ Priority: '1'
+ CallerID: 'echo <echo>'
+ -
+ ami-events:
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'Newexten'
+ Channel: 'PJSIP/callee-.*'
+ Application: 'Echo'
+ ami-actions:
+ action:
+ Action: 'AOCMessage'
+ Channel: '{channel}'
+ MsgType: 'E'
+ ChargeType: 'Currency'
+ CurrencyAmount: 314
+ CurrencyName: 'EUR'
+ CurrencyMultiplier: 'OneThousandth'
+
+properties:
+ dependencies:
+ - sipp :
+ version : 'v3.0'
+ - asterisk : 'chan_pjsip'
+ - asterisk : 'res_pjsip_aoc'
+ - asterisk : 'app_dial'
+ tags:
+ - PJSIP
+
diff --git a/tests/channels/pjsip/aoc/aoc_e_to_callee_in_bye/configs/ast1/extensions.conf b/tests/channels/pjsip/aoc/aoc_e_to_callee_in_bye/configs/ast1/extensions.conf
new file mode 100644
index 0000000..f7b9b0e
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_e_to_callee_in_bye/configs/ast1/extensions.conf
@@ -0,0 +1,4 @@
+[default]
+exten => echo,1,Answer()
+same => n,Wait(2)
+same => n,Echo()
diff --git a/tests/channels/pjsip/aoc/aoc_e_to_callee_in_bye/configs/ast1/pjsip.conf b/tests/channels/pjsip/aoc/aoc_e_to_callee_in_bye/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..e7065cc
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_e_to_callee_in_bye/configs/ast1/pjsip.conf
@@ -0,0 +1,25 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local-transport-udp]
+type=transport
+bind=127.0.0.1
+protocol=udp
+
+[callee]
+type=endpoint
+aors=callee
+context=default
+allow=!all,ulaw
+rewrite_contact=yes
+direct_media=no
+send_aoc=yes
+
+[callee]
+type=aor
+max_contacts=1
+minimum_expiration=5
+default_expiration=30
+contact=sip:callee at 127.0.0.1:5062
diff --git a/tests/channels/pjsip/aoc/aoc_e_to_callee_in_bye/sipp/callee.xml b/tests/channels/pjsip/aoc/aoc_e_to_callee_in_bye/sipp/callee.xml
new file mode 100644
index 0000000..8a24ec7
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_e_to_callee_in_bye/sipp/callee.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Receive AOC-E on inbound call hung up by the other side">
+ <Global variables="remote_tag" />
+ <recv request="INVITE" crlf="true">
+ <!-- Save the from tag. We'll need it when we send our BYE -->
+ <action>
+ <ereg regexp=".*(;tag=.*)"
+ header="From:"
+ search_in="hdr"
+ check_it="true"
+ assign_to="remote_tag"/>
+ </action>
+ </recv>
+
+ <send>
+ <![CDATA[
+ SIP/2.0 180 Ringing
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[pid]SIPpTag01[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <send retrans="500">
+ <![CDATA[
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[pid]SIPpTag01[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=user1 53655765 2353687637 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
+ a=rtpmap:0 PCMU/8000
+ ]]>
+ </send>
+
+ <recv request="ACK" />
+
+ <recv request="BYE">
+ <action>
+ <ereg regexp="application/vnd.etsi\.aoc\+xml" header="Content-Type:" search_in="hdr" check_it="true" assign_to="_"/>
+ <ereg regexp="<\?xml version="1\.0" encoding="UTF-8"\?>
+<aoc xmlns="http://uri\.etsi\.org/ngn/params/xml/simservs/aoc">
+ <aoc-e>
+ <recorded-charges>
+ <free-charge />
+ </recorded-charges>
+ </aoc-e>
+</aoc>" check_it="true" search_in="body" assign_to="_" />
+ </action>
+ </recv>
+
+ <send retrans="500">
+ <![CDATA[
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[pid]SIPpTag01[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+</scenario>
\ No newline at end of file
diff --git a/tests/channels/pjsip/aoc/aoc_e_to_callee_in_bye/test-config.yaml b/tests/channels/pjsip/aoc/aoc_e_to_callee_in_bye/test-config.yaml
new file mode 100644
index 0000000..3d98952
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_e_to_callee_in_bye/test-config.yaml
@@ -0,0 +1,75 @@
+info:
+ summary: 'Test AOC-E to callee after caller hangs up'
+ description: |
+ This uses an AOCMessage AMI to generate an AOC-E
+ event, adding to the BYE message sent to the callee.
+
+test-modules:
+ test-object:
+ config-section: test-object-config
+ typename: sipp.SIPpTestCase
+ modules:
+ -
+ config-section: ami-config
+ typename: 'pluggable_modules.EventActionModule'
+
+test-object-config:
+ memcheck-delay-stop: 7
+ fail-on-any: True
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': { 'scenario': 'callee.xml', '-i': '127.0.0.1', '-p': '5062' } }
+
+ami-config:
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'FullyBooted'
+ ami-actions:
+ action:
+ Action: 'Originate'
+ ActionID: '1'
+ Channel: 'PJSIP/callee'
+ Exten: 'echo'
+ Context: 'default'
+ Priority: '1'
+ CallerID: 'echo <echo>'
+ -
+ ami-events:
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'Newexten'
+ Channel: 'PJSIP/callee-.*'
+ Application: 'Wait'
+ ami-actions:
+ action:
+ Action: 'AOCMessage'
+ Channel: '{channel}'
+ MsgType: 'E'
+ ChargeType: 'Free'
+ -
+ ami-events:
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'Newexten'
+ Channel: 'PJSIP/callee-.*'
+ Application: 'Echo'
+ ami-actions:
+ action:
+ Action: 'Hangup'
+ Channel: '{channel}'
+
+properties:
+ dependencies:
+ - sipp :
+ version : 'v3.0'
+ - asterisk : 'chan_pjsip'
+ - asterisk : 'res_pjsip_aoc'
+ - asterisk : 'app_dial'
+ tags:
+ - PJSIP
+
diff --git a/tests/channels/pjsip/aoc/aoc_e_to_caller_in_200/configs/ast1/extensions.conf b/tests/channels/pjsip/aoc/aoc_e_to_caller_in_200/configs/ast1/extensions.conf
new file mode 100644
index 0000000..af317af
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_e_to_caller_in_200/configs/ast1/extensions.conf
@@ -0,0 +1,3 @@
+[default]
+exten => echo,1,Answer()
+same => n,Echo()
diff --git a/tests/channels/pjsip/aoc/aoc_e_to_caller_in_200/configs/ast1/pjsip.conf b/tests/channels/pjsip/aoc/aoc_e_to_caller_in_200/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..feb5ba0
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_e_to_caller_in_200/configs/ast1/pjsip.conf
@@ -0,0 +1,25 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local-transport-udp]
+type=transport
+bind=127.0.0.1
+protocol=udp
+
+[caller]
+type=endpoint
+aors=caller
+context=default
+allow=!all,ulaw
+rewrite_contact=yes
+direct_media=no
+send_aoc=yes
+
+[caller]
+type=aor
+max_contacts=1
+minimum_expiration=5
+default_expiration=30
+contact=sip:caller at 127.0.0.1:5062
diff --git a/tests/channels/pjsip/aoc/aoc_e_to_caller_in_200/sipp/caller.xml b/tests/channels/pjsip/aoc/aoc_e_to_caller_in_200/sipp/caller.xml
new file mode 100644
index 0000000..1357fc9
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_e_to_caller_in_200/sipp/caller.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Receive AOC-E on outbound call hung up by us">
+ <send retrans="500">
+ <![CDATA[
+ INVITE sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:caller@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>
+ Call-ID: [call_id]
+ CSeq: 1 INVITE
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=phoneA 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+ s=-
+ c=IN IP[media_ip_type] [media_ip]
+ t=0 0
+ m=audio 6000 RTP/AVP 0
+ a=rtpmap:0 PCMU/8000
+ ]]>
+ </send>
+
+ <recv response="100" optional="true">
+ </recv>
+
+ <recv response="180" optional="true">
+ </recv>
+
+ <recv response="200" rtd="true">
+ </recv>
+
+ <send>
+ <![CDATA[
+ ACK sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:caller@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>[peer_tag_param]
+ Call-ID: [call_id]
+ CSeq: 1 ACK
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <pause milliseconds="2000"/>
+
+ <send retrans="500">
+ <![CDATA[
+ BYE sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:[service]@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>[peer_tag_param]
+ Call-ID: [call_id]
+ CSeq: 2 BYE
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Subject: Test
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <recv response="200" crlf="true">
+ <action>
+ <ereg regexp="application/vnd.etsi\.aoc\+xml" header="Content-Type:" search_in="hdr" check_it="true" assign_to="_"/>
+ <ereg regexp="<\?xml version="1\.0" encoding="UTF-8"\?>
+<aoc xmlns="http://uri\.etsi\.org/ngn/params/xml/simservs/aoc">
+ <aoc-e>
+ <recorded-charges>
+ <recorded-currency-units>
+ <currency-id>UNIT</currency-id>
+ <currency-amount>314</currency-amount>
+ </recorded-currency-units>
+ </recorded-charges>
+ </aoc-e>
+</aoc>" check_it="true" search_in="body" assign_to="_" />
+ </action>
+ </recv>
+
+</scenario>
diff --git a/tests/channels/pjsip/aoc/aoc_e_to_caller_in_200/test-config.yaml b/tests/channels/pjsip/aoc/aoc_e_to_caller_in_200/test-config.yaml
new file mode 100644
index 0000000..7fd2076
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_e_to_caller_in_200/test-config.yaml
@@ -0,0 +1,51 @@
+info:
+ summary: 'Test AOC-E to caller who hangs up'
+ description: |
+ This uses an AOCMessage AMI to generate an AOC-E
+ event, adding to the 200 message sent in reply to
+ the caller's BYE message.
+
+test-modules:
+ test-object:
+ config-section: test-object-config
+ typename: sipp.SIPpTestCase
+ modules:
+ -
+ config-section: ami-config
+ typename: 'pluggable_modules.EventActionModule'
+
+test-object-config:
+ memcheck-delay-stop: 7
+ fail-on-any: True
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': { 'scenario': 'caller.xml', '-i': '127.0.0.1', '-p': '5062' } }
+
+ami-config:
+ -
+ ami-events:
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'Newexten'
+ Channel: 'PJSIP/caller-.*'
+ Application: 'Echo'
+ ami-actions:
+ action:
+ Action: 'AOCMessage'
+ Channel: '{channel}'
+ MsgType: 'E'
+ ChargeType: 'Unit'
+ 'UnitAmount(0)': 314
+
+properties:
+ dependencies:
+ - sipp :
+ version : 'v3.0'
+ - asterisk : 'chan_pjsip'
+ - asterisk : 'res_pjsip_aoc'
+ - asterisk : 'app_dial'
+ tags:
+ - PJSIP
+
diff --git a/tests/channels/pjsip/aoc/aoc_e_to_caller_in_bye/configs/ast1/extensions.conf b/tests/channels/pjsip/aoc/aoc_e_to_caller_in_bye/configs/ast1/extensions.conf
new file mode 100644
index 0000000..f7b9b0e
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_e_to_caller_in_bye/configs/ast1/extensions.conf
@@ -0,0 +1,4 @@
+[default]
+exten => echo,1,Answer()
+same => n,Wait(2)
+same => n,Echo()
diff --git a/tests/channels/pjsip/aoc/aoc_e_to_caller_in_bye/configs/ast1/pjsip.conf b/tests/channels/pjsip/aoc/aoc_e_to_caller_in_bye/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..feb5ba0
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_e_to_caller_in_bye/configs/ast1/pjsip.conf
@@ -0,0 +1,25 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local-transport-udp]
+type=transport
+bind=127.0.0.1
+protocol=udp
+
+[caller]
+type=endpoint
+aors=caller
+context=default
+allow=!all,ulaw
+rewrite_contact=yes
+direct_media=no
+send_aoc=yes
+
+[caller]
+type=aor
+max_contacts=1
+minimum_expiration=5
+default_expiration=30
+contact=sip:caller at 127.0.0.1:5062
diff --git a/tests/channels/pjsip/aoc/aoc_e_to_caller_in_bye/sipp/caller.xml b/tests/channels/pjsip/aoc/aoc_e_to_caller_in_bye/sipp/caller.xml
new file mode 100644
index 0000000..7da0a3c
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_e_to_caller_in_bye/sipp/caller.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Receive AOC-E on outbound call hung up by the other side">
+ <send retrans="500">
+ <![CDATA[
+ INVITE sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:caller@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>
+ Call-ID: [call_id]
+ CSeq: 1 INVITE
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=phoneA 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+ s=-
+ c=IN IP[media_ip_type] [media_ip]
+ t=0 0
+ m=audio 6000 RTP/AVP 0
+ a=rtpmap:0 PCMU/8000
+ ]]>
+ </send>
+
+ <recv response="100" optional="true">
+ </recv>
+
+ <recv response="180" optional="true">
+ </recv>
+
+ <recv response="200" rtd="true">
+ </recv>
+
+ <send>
+ <![CDATA[
+ ACK sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:caller@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>[peer_tag_param]
+ Call-ID: [call_id]
+ CSeq: 1 ACK
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <recv request="BYE">
+ <action>
+ <ereg regexp="application/vnd.etsi\.aoc\+xml" header="Content-Type:" search_in="hdr" check_it="true" assign_to="_"/>
+ <ereg regexp="<\?xml version="1\.0" encoding="UTF-8"\?>
+<aoc xmlns="http://uri\.etsi\.org/ngn/params/xml/simservs/aoc">
+ <aoc-e>
+ <recorded-charges>
+ <recorded-currency-units>
+ <currency-id>EUR</currency-id>
+ <currency-amount>0\.3</currency-amount>
+ </recorded-currency-units>
+ </recorded-charges>
+ </aoc-e>
+</aoc>" check_it="true" search_in="body" assign_to="_" />
+ </action>
+ </recv>
+
+ <send retrans="500">
+ <![CDATA[
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[pid]SIPpTag01[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+</scenario>
diff --git a/tests/channels/pjsip/aoc/aoc_e_to_caller_in_bye/test-config.yaml b/tests/channels/pjsip/aoc/aoc_e_to_caller_in_bye/test-config.yaml
new file mode 100644
index 0000000..c18e939
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_e_to_caller_in_bye/test-config.yaml
@@ -0,0 +1,66 @@
+info:
+ summary: 'Test AOC-E to caller after callee hangs up'
+ description: |
+ This uses an AOCMessage AMI to generate an AOC-E
+ event, adding to the BYE message sent to the caller'.
+
+test-modules:
+ test-object:
+ config-section: test-object-config
+ typename: sipp.SIPpTestCase
+ modules:
+ -
+ config-section: ami-config
+ typename: 'pluggable_modules.EventActionModule'
+
+test-object-config:
+ memcheck-delay-stop: 7
+ fail-on-any: True
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': { 'scenario': 'caller.xml', '-i': '127.0.0.1', '-p': '5062' } }
+
+ami-config:
+ -
+ ami-events:
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'Newexten'
+ Channel: 'PJSIP/caller-.*'
+ Application: 'Wait'
+ ami-actions:
+ action:
+ Action: 'AOCMessage'
+ Channel: '{channel}'
+ MsgType: 'E'
+ ChargeType: 'Currency'
+ CurrencyAmount: 3
+ CurrencyName: 'EUR'
+ CurrencyMultiplier: 'OneTenth'
+ expected:
+ Response: 'Success'
+ -
+ ami-events:
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'Newexten'
+ Channel: 'PJSIP/caller-.*'
+ Application: 'Echo'
+ ami-actions:
+ action:
+ Action: 'Hangup'
+ Channel: '{channel}'
+
+properties:
+ dependencies:
+ - sipp :
+ version : 'v3.0'
+ - asterisk : 'chan_pjsip'
+ - asterisk : 'res_pjsip_aoc'
+ - asterisk : 'app_dial'
+ tags:
+ - PJSIP
+
diff --git a/tests/channels/pjsip/aoc/aoc_s_to_callee_in_info/configs/ast1/extensions.conf b/tests/channels/pjsip/aoc/aoc_s_to_callee_in_info/configs/ast1/extensions.conf
new file mode 100644
index 0000000..af317af
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_s_to_callee_in_info/configs/ast1/extensions.conf
@@ -0,0 +1,3 @@
+[default]
+exten => echo,1,Answer()
+same => n,Echo()
diff --git a/tests/channels/pjsip/aoc/aoc_s_to_callee_in_info/configs/ast1/pjsip.conf b/tests/channels/pjsip/aoc/aoc_s_to_callee_in_info/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..e7065cc
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_s_to_callee_in_info/configs/ast1/pjsip.conf
@@ -0,0 +1,25 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local-transport-udp]
+type=transport
+bind=127.0.0.1
+protocol=udp
+
+[callee]
+type=endpoint
+aors=callee
+context=default
+allow=!all,ulaw
+rewrite_contact=yes
+direct_media=no
+send_aoc=yes
+
+[callee]
+type=aor
+max_contacts=1
+minimum_expiration=5
+default_expiration=30
+contact=sip:callee at 127.0.0.1:5062
diff --git a/tests/channels/pjsip/aoc/aoc_s_to_callee_in_info/sipp/callee.xml b/tests/channels/pjsip/aoc/aoc_s_to_callee_in_info/sipp/callee.xml
new file mode 100644
index 0000000..9501896
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_s_to_callee_in_info/sipp/callee.xml
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Receive AOC-S on inbound call">
+ <Global variables="remote_tag" />
+ <recv request="INVITE" crlf="true">
+ <!-- Save the from tag. We'll need it when we send our BYE -->
+ <action>
+ <ereg regexp=".*(;tag=.*)"
+ header="From:"
+ search_in="hdr"
+ check_it="true"
+ assign_to="remote_tag"/>
+ </action>
+ </recv>
+
+ <send>
+ <![CDATA[
+ SIP/2.0 180 Ringing
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[pid]SIPpTag01[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <send retrans="500">
+ <![CDATA[
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[pid]SIPpTag01[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=user1 53655765 2353687637 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
+ a=rtpmap:0 PCMU/8000
+ ]]>
+ </send>
+
+ <recv request="ACK" />
+
+ <recv request="INFO">
+ <action>
+ <ereg regexp="application/vnd.etsi\.aoc\+xml" header="Content-Type:" search_in="hdr" check_it="true" assign_to="_"/>
+ <ereg regexp="<\?xml version="1\.0" encoding="UTF-8"\?>
+<aoc xmlns="http://uri\.etsi\.org/ngn/params/xml/simservs/aoc">
+ <aoc-s>
+ <charged-items>
+ <basic>
+ <price-time>
+ <currency-id>EUR</currency-id>
+ <currency-amount>1\.337</currency-amount>
+ <length-time-unit>
+ <time-unit>1</time-unit>
+ <scale>one-hour</scale>
+ </length-time-unit>
+ <charging-type>step-function</charging-type>
+ </price-time>
+ </basic>
+ </charged-items>
+ </aoc-s>
+</aoc>" check_it="true" search_in="body" assign_to="_" />
+ </action>
+ </recv>
+
+ <send>
+ <![CDATA[
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ Call-ID: [call_id]
+ CSeq: [cseq] INFO
+ Contact: <sip:user1@[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <send retrans="500">
+ <![CDATA[
+ BYE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: callee <sip:callee@[local_ip]:[local_port]>;tag=[pid]SIPpTag01[call_number]
+ To:[$remote_tag]
+ [last_Call-ID:]
+ CSeq: [cseq] BYE
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <recv response="200" />
+
+</scenario>
diff --git a/tests/channels/pjsip/aoc/aoc_s_to_callee_in_info/test-config.yaml b/tests/channels/pjsip/aoc/aoc_s_to_callee_in_info/test-config.yaml
new file mode 100644
index 0000000..83cc2e9
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_s_to_callee_in_info/test-config.yaml
@@ -0,0 +1,71 @@
+info:
+ summary: 'Test AOC-S to callee'
+ description: |
+ This uses an AOCMessage AMI to generate an AOC-S
+ event, generating a SIP INFO message sent to the
+ callee.
+
+test-modules:
+ test-object:
+ config-section: test-object-config
+ typename: sipp.SIPpTestCase
+ modules:
+ -
+ config-section: ami-config
+ typename: 'pluggable_modules.EventActionModule'
+
+test-object-config:
+ memcheck-delay-stop: 7
+ fail-on-any: True
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': { 'scenario': 'callee.xml', '-i': '127.0.0.1', '-p': '5062' } }
+
+ami-config:
+ -
+ ami-events:
+ conditions:
+ match:
+ Event: 'FullyBooted'
+ ami-actions:
+ action:
+ Action: 'Originate'
+ ActionID: '1'
+ Channel: 'PJSIP/callee'
+ Exten: 'echo'
+ Context: 'default'
+ Priority: '1'
+ CallerID: 'echo <echo>'
+ -
+ ami-events:
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'Newexten'
+ Channel: 'PJSIP/callee-.*'
+ Application: 'Echo'
+ ami-actions:
+ action:
+ Action: 'AOCMessage'
+ Channel: '{channel}'
+ MsgType: 'S'
+ ChargedItem: 'BasicCommunication'
+ RateType: 'Duration'
+ CurrencyAmount: 1337
+ CurrencyName: 'EUR'
+ CurrencyMultiplier: 'OneThousandth'
+ TimeScale: 'Hour'
+ Time: 1
+ ChargingType: 'StepFunction'
+
+properties:
+ dependencies:
+ - sipp :
+ version : 'v3.0'
+ - asterisk : 'chan_pjsip'
+ - asterisk : 'res_pjsip_aoc'
+ - asterisk : 'app_dial'
+ tags:
+ - PJSIP
+
diff --git a/tests/channels/pjsip/aoc/aoc_s_to_caller_in_180/configs/ast1/extensions.conf b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_180/configs/ast1/extensions.conf
new file mode 100644
index 0000000..6a08c91
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_180/configs/ast1/extensions.conf
@@ -0,0 +1,5 @@
+[default]
+exten => echo,1,Wait(2)
+same => n,Ringing()
+same => n,Answer()
+same => n,Echo()
diff --git a/tests/channels/pjsip/aoc/aoc_s_to_caller_in_180/configs/ast1/pjsip.conf b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_180/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..feb5ba0
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_180/configs/ast1/pjsip.conf
@@ -0,0 +1,25 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local-transport-udp]
+type=transport
+bind=127.0.0.1
+protocol=udp
+
+[caller]
+type=endpoint
+aors=caller
+context=default
+allow=!all,ulaw
+rewrite_contact=yes
+direct_media=no
+send_aoc=yes
+
+[caller]
+type=aor
+max_contacts=1
+minimum_expiration=5
+default_expiration=30
+contact=sip:caller at 127.0.0.1:5062
diff --git a/tests/channels/pjsip/aoc/aoc_s_to_caller_in_180/sipp/caller.xml b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_180/sipp/caller.xml
new file mode 100644
index 0000000..5098af0
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_180/sipp/caller.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Receive AOC-S on outbound call with ringing">
+ <send retrans="500">
+ <![CDATA[
+ INVITE sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:caller@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>
+ Call-ID: [call_id]
+ CSeq: 1 INVITE
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=phoneA 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+ s=-
+ c=IN IP[media_ip_type] [media_ip]
+ t=0 0
+ m=audio 6000 RTP/AVP 0
+ a=rtpmap:0 PCMU/8000
+ ]]>
+ </send>
+
+ <recv response="100" optional="true">
+ </recv>
+
+ <recv response="180">
+ <action>
+ <ereg regexp="multipart/mixed" header="Content-Type:" search_in="hdr" check_it="true" assign_to="_"/>
+ <ereg regexp="application/vnd.etsi\.aoc\+xml" search_in="body" check_it="true" assign_to="_"/>
+ <ereg regexp="<\?xml version="1\.0" encoding="UTF-8"\?>
+<aoc xmlns="http://uri\.etsi\.org/ngn/params/xml/simservs/aoc">
+ <aoc-s>
+ <charged-items>
+ <basic>
+ <free-charge />
+ </basic>
+ </charged-items>
+ </aoc-s>
+</aoc>" check_it="true" search_in="body" assign_to="_" />
+ </action>
+ </recv>
+
+ <recv response="183" optional="true">
+ </recv>
+
+ <recv response="200" rtd="true">
+ </recv>
+
+ <send>
+ <![CDATA[
+ ACK sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:caller@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>[peer_tag_param]
+ Call-ID: [call_id]
+ CSeq: 1 ACK
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <send retrans="500">
+ <![CDATA[
+ BYE sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:[service]@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>[peer_tag_param]
+ Call-ID: [call_id]
+ CSeq: 2 BYE
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Subject: Test
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <recv response="200" />
+
+</scenario>
diff --git a/tests/channels/pjsip/aoc/aoc_s_to_caller_in_180/test-config.yaml b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_180/test-config.yaml
new file mode 100644
index 0000000..a304067
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_180/test-config.yaml
@@ -0,0 +1,51 @@
+info:
+ summary: 'Test AOC-S to caller in ringing'
+ description: |
+ This uses an AOCMessage AMI to generate an AOC-S
+ event, adding to the 180 message sent in reply to
+ the caller's INVITE message.
+
+test-modules:
+ test-object:
+ config-section: test-object-config
+ typename: sipp.SIPpTestCase
+ modules:
+ -
+ config-section: ami-config
+ typename: 'pluggable_modules.EventActionModule'
+
+test-object-config:
+ memcheck-delay-stop: 7
+ fail-on-any: True
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': { 'scenario': 'caller.xml', '-i': '127.0.0.1', '-p': '5062' } }
+
+ami-config:
+ -
+ ami-events:
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'Newexten'
+ Channel: 'PJSIP/caller-.*'
+ Application: 'Wait'
+ ami-actions:
+ action:
+ Action: 'AOCMessage'
+ Channel: '{channel}'
+ MsgType: 'S'
+ ChargedItem: 'BasicCommunication'
+ RateType: 'Free'
+
+properties:
+ dependencies:
+ - sipp :
+ version : 'v3.0'
+ - asterisk : 'chan_pjsip'
+ - asterisk : 'res_pjsip_aoc'
+ - asterisk : 'app_dial'
+ tags:
+ - PJSIP
+
diff --git a/tests/channels/pjsip/aoc/aoc_s_to_caller_in_183/configs/ast1/extensions.conf b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_183/configs/ast1/extensions.conf
new file mode 100644
index 0000000..ec6d21d
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_183/configs/ast1/extensions.conf
@@ -0,0 +1,5 @@
+[default]
+exten => echo,1,Wait(2)
+same => n,Progress()
+same => n,Answer()
+same => n,Echo()
diff --git a/tests/channels/pjsip/aoc/aoc_s_to_caller_in_183/configs/ast1/pjsip.conf b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_183/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..feb5ba0
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_183/configs/ast1/pjsip.conf
@@ -0,0 +1,25 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local-transport-udp]
+type=transport
+bind=127.0.0.1
+protocol=udp
+
+[caller]
+type=endpoint
+aors=caller
+context=default
+allow=!all,ulaw
+rewrite_contact=yes
+direct_media=no
+send_aoc=yes
+
+[caller]
+type=aor
+max_contacts=1
+minimum_expiration=5
+default_expiration=30
+contact=sip:caller at 127.0.0.1:5062
diff --git a/tests/channels/pjsip/aoc/aoc_s_to_caller_in_183/sipp/caller.xml b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_183/sipp/caller.xml
new file mode 100644
index 0000000..1a055fa
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_183/sipp/caller.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Receive AOC-S on outbound with early media">
+ <send retrans="500">
+ <![CDATA[
+ INVITE sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:caller@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>
+ Call-ID: [call_id]
+ CSeq: 1 INVITE
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=phoneA 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+ s=-
+ c=IN IP[media_ip_type] [media_ip]
+ t=0 0
+ m=audio 6000 RTP/AVP 0
+ a=rtpmap:0 PCMU/8000
+ ]]>
+ </send>
+
+ <recv response="100" optional="true">
+ </recv>
+
+ <recv response="180" optional="true">
+ </recv>
+
+ <recv response="183">
+ <action>
+ <ereg regexp="multipart/mixed" header="Content-Type:" search_in="hdr" check_it="true" assign_to="_"/>
+ <ereg regexp="application/vnd.etsi\.aoc\+xml" search_in="body" check_it="true" assign_to="_"/>
+ <ereg regexp="<\?xml version="1\.0" encoding="UTF-8"\?>
+<aoc xmlns="http://uri\.etsi\.org/ngn/params/xml/simservs/aoc">
+ <aoc-s>
+ <charged-items>
+ <basic>
+ <flat-rate>
+ <currency-id>EUR</currency-id>
+ <currency-amount>1\.337</currency-amount>
+ </flat-rate>
+ </basic>
+ </charged-items>
+ </aoc-s>
+</aoc>" check_it="true" search_in="body" assign_to="_" />
+ </action>
+ </recv>
+
+ <recv response="200" rtd="true">
+ </recv>
+
+ <send>
+ <![CDATA[
+ ACK sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:caller@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>[peer_tag_param]
+ Call-ID: [call_id]
+ CSeq: 1 ACK
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <send retrans="500">
+ <![CDATA[
+ BYE sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:[service]@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>[peer_tag_param]
+ Call-ID: [call_id]
+ CSeq: 2 BYE
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Subject: Test
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <recv response="200" />
+
+</scenario>
diff --git a/tests/channels/pjsip/aoc/aoc_s_to_caller_in_183/test-config.yaml b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_183/test-config.yaml
new file mode 100644
index 0000000..13f8fbd
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_183/test-config.yaml
@@ -0,0 +1,54 @@
+info:
+ summary: 'Test AOC-S to caller in early media'
+ description: |
+ This uses an AOCMessage AMI to generate an AOC-S
+ event, adding to the 183 message sent in reply to
+ the caller's INVITE message.
+
+test-modules:
+ test-object:
+ config-section: test-object-config
+ typename: sipp.SIPpTestCase
+ modules:
+ -
+ config-section: ami-config
+ typename: 'pluggable_modules.EventActionModule'
+
+test-object-config:
+ memcheck-delay-stop: 7
+ fail-on-any: True
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': { 'scenario': 'caller.xml', '-i': '127.0.0.1', '-p': '5062' } }
+
+ami-config:
+ -
+ ami-events:
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'Newexten'
+ Channel: 'PJSIP/caller-.*'
+ Application: 'Wait'
+ ami-actions:
+ action:
+ Action: 'AOCMessage'
+ Channel: '{channel}'
+ MsgType: 'S'
+ ChargedItem: 'BasicCommunication'
+ RateType: 'Flat'
+ CurrencyAmount: 1337
+ CurrencyName: 'EUR'
+ CurrencyMultiplier: 'OneThousandth'
+
+properties:
+ dependencies:
+ - sipp :
+ version : 'v3.0'
+ - asterisk : 'chan_pjsip'
+ - asterisk : 'res_pjsip_aoc'
+ - asterisk : 'app_dial'
+ tags:
+ - PJSIP
+
diff --git a/tests/channels/pjsip/aoc/aoc_s_to_caller_in_200/configs/ast1/extensions.conf b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_200/configs/ast1/extensions.conf
new file mode 100644
index 0000000..045b637
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_200/configs/ast1/extensions.conf
@@ -0,0 +1,4 @@
+[default]
+exten => echo,1,Wait(2)
+same => n,Answer()
+same => n,Echo()
diff --git a/tests/channels/pjsip/aoc/aoc_s_to_caller_in_200/configs/ast1/pjsip.conf b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_200/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..feb5ba0
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_200/configs/ast1/pjsip.conf
@@ -0,0 +1,25 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local-transport-udp]
+type=transport
+bind=127.0.0.1
+protocol=udp
+
+[caller]
+type=endpoint
+aors=caller
+context=default
+allow=!all,ulaw
+rewrite_contact=yes
+direct_media=no
+send_aoc=yes
+
+[caller]
+type=aor
+max_contacts=1
+minimum_expiration=5
+default_expiration=30
+contact=sip:caller at 127.0.0.1:5062
diff --git a/tests/channels/pjsip/aoc/aoc_s_to_caller_in_200/sipp/caller.xml b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_200/sipp/caller.xml
new file mode 100644
index 0000000..7bd5edc
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_200/sipp/caller.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Receive AOC-S on outbound call">
+ <send retrans="500">
+ <![CDATA[
+ INVITE sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:caller@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>
+ Call-ID: [call_id]
+ CSeq: 1 INVITE
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=phoneA 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+ s=-
+ c=IN IP[media_ip_type] [media_ip]
+ t=0 0
+ m=audio 6000 RTP/AVP 0
+ a=rtpmap:0 PCMU/8000
+ ]]>
+ </send>
+
+ <recv response="100" optional="true">
+ </recv>
+
+ <recv response="180" optional="true">
+ </recv>
+
+ <recv response="183" optional="true">
+ </recv>
+
+ <recv response="200">
+ <action>
+ <ereg regexp="multipart/mixed" header="Content-Type:" search_in="hdr" check_it="true" assign_to="_"/>
+ <ereg regexp="application/vnd.etsi\.aoc\+xml" search_in="body" check_it="true" assign_to="_"/>
+ <ereg regexp="<\?xml version="1\.0" encoding="UTF-8"\?>
+<aoc xmlns="http://uri\.etsi\.org/ngn/params/xml/simservs/aoc">
+ <aoc-s>
+ <charged-items>
+ <communication-attempt>
+ <flat-rate>
+ <currency-id>EUR</currency-id>
+ <currency-amount>1\.337</currency-amount>
+ </flat-rate>
+ </communication-attempt>
+ </charged-items>
+ </aoc-s>
+</aoc>" check_it="true" search_in="body" assign_to="_" />
+ </action>
+ </recv>
+
+ <send>
+ <![CDATA[
+ ACK sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:caller@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>[peer_tag_param]
+ Call-ID: [call_id]
+ CSeq: 1 ACK
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <send retrans="500">
+ <![CDATA[
+ BYE sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:[service]@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>[peer_tag_param]
+ Call-ID: [call_id]
+ CSeq: 2 BYE
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Subject: Test
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <recv response="200" />
+
+</scenario>
diff --git a/tests/channels/pjsip/aoc/aoc_s_to_caller_in_200/test-config.yaml b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_200/test-config.yaml
new file mode 100644
index 0000000..97ecb04
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_200/test-config.yaml
@@ -0,0 +1,54 @@
+info:
+ summary: 'Test AOC-S to caller in answer'
+ description: |
+ This uses an AOCMessage AMI to generate an AOC-S
+ event, adding to the 200 message sent in reply to
+ the caller's INVITE message.
+
+test-modules:
+ test-object:
+ config-section: test-object-config
+ typename: sipp.SIPpTestCase
+ modules:
+ -
+ config-section: ami-config
+ typename: 'pluggable_modules.EventActionModule'
+
+test-object-config:
+ memcheck-delay-stop: 7
+ fail-on-any: True
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': { 'scenario': 'caller.xml', '-i': '127.0.0.1', '-p': '5062' } }
+
+ami-config:
+ -
+ ami-events:
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'Newexten'
+ Channel: 'PJSIP/caller-.*'
+ Application: 'Wait'
+ ami-actions:
+ action:
+ Action: 'AOCMessage'
+ Channel: '{channel}'
+ MsgType: 'S'
+ ChargedItem: 'CallAttempt'
+ RateType: 'Flat'
+ CurrencyAmount: 1337
+ CurrencyName: 'EUR'
+ CurrencyMultiplier: 'OneThousandth'
+
+properties:
+ dependencies:
+ - sipp :
+ version : 'v3.0'
+ - asterisk : 'chan_pjsip'
+ - asterisk : 'res_pjsip_aoc'
+ - asterisk : 'app_dial'
+ tags:
+ - PJSIP
+
diff --git a/tests/channels/pjsip/aoc/aoc_s_to_caller_in_info/configs/ast1/extensions.conf b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_info/configs/ast1/extensions.conf
new file mode 100644
index 0000000..af317af
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_info/configs/ast1/extensions.conf
@@ -0,0 +1,3 @@
+[default]
+exten => echo,1,Answer()
+same => n,Echo()
diff --git a/tests/channels/pjsip/aoc/aoc_s_to_caller_in_info/configs/ast1/pjsip.conf b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_info/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..feb5ba0
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_info/configs/ast1/pjsip.conf
@@ -0,0 +1,25 @@
+[system]
+type=system
+timer_t1=100
+timer_b=6400
+
+[local-transport-udp]
+type=transport
+bind=127.0.0.1
+protocol=udp
+
+[caller]
+type=endpoint
+aors=caller
+context=default
+allow=!all,ulaw
+rewrite_contact=yes
+direct_media=no
+send_aoc=yes
+
+[caller]
+type=aor
+max_contacts=1
+minimum_expiration=5
+default_expiration=30
+contact=sip:caller at 127.0.0.1:5062
diff --git a/tests/channels/pjsip/aoc/aoc_s_to_caller_in_info/sipp/caller.xml b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_info/sipp/caller.xml
new file mode 100644
index 0000000..1a9ea05
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_info/sipp/caller.xml
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="Receive AOC-S on outbound call after answer">
+ <send retrans="500">
+ <![CDATA[
+ INVITE sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:caller@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>
+ Call-ID: [call_id]
+ CSeq: 1 INVITE
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Content-Type: application/sdp
+ Content-Length: [len]
+
+ v=0
+ o=phoneA 53655765 2353687637 IN IP[local_ip_type] [local_ip]
+ s=-
+ c=IN IP[media_ip_type] [media_ip]
+ t=0 0
+ m=audio 6000 RTP/AVP 0
+ a=rtpmap:0 PCMU/8000
+ ]]>
+ </send>
+
+ <recv response="100" optional="true">
+ </recv>
+
+ <recv response="180" optional="true">
+ </recv>
+
+ <recv response="183" optional="true">
+ </recv>
+
+ <recv response="200">
+ </recv>
+
+ <send>
+ <![CDATA[
+ ACK sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:caller@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>[peer_tag_param]
+ Call-ID: [call_id]
+ CSeq: 1 ACK
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <recv request="INFO">
+ <action>
+ <ereg regexp="application/vnd.etsi\.aoc\+xml" header="Content-Type:" search_in="hdr" check_it="true" assign_to="_"/>
+ <ereg regexp="<\?xml version="1\.0" encoding="UTF-8"\?>
+<aoc xmlns="http://uri\.etsi\.org/ngn/params/xml/simservs/aoc">
+ <aoc-s>
+ <charged-items>
+ <basic>
+ <price-time>
+ <currency-id>UNIT</currency-id>
+ <currency-amount>133\.7</currency-amount>
+ <length-time-unit>
+ <time-unit>10</time-unit>
+ <scale>one-minute</scale>
+ </length-time-unit>
+ <charging-type>continuous</charging-type>
+ </price-time>
+ </basic>
+ <communication-attempt>
+ <flat-rate>
+ <currency-id>UNIT</currency-id>
+ <currency-amount>0\.42</currency-amount>
+ </flat-rate>
+ </communication-attempt>
+ </charged-items>
+ </aoc-s>
+</aoc>" check_it="true" search_in="body" assign_to="_" />
+ </action>
+ </recv>
+
+ <send>
+ <![CDATA[
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:]
+ Call-ID: [call_id]
+ CSeq: [cseq] INFO
+ Contact: <sip:user1@[local_ip]:[local_port];transport=[transport]>
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <send retrans="500">
+ <![CDATA[
+ BYE sip:echo@[remote_ip]:[remote_port] SIP/2.0
+ Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+ From: caller <sip:[service]@[local_ip]:[local_port]>;tag=[call_number]
+ To: echo <sip:echo@[remote_ip]:[remote_port]>[peer_tag_param]
+ Call-ID: [call_id]
+ CSeq: 2 BYE
+ Contact: <sip:caller@[local_ip]:[local_port];transport=[transport]>
+ Max-Forwards: 70
+ Subject: Test
+ Content-Length: 0
+ ]]>
+ </send>
+
+ <recv response="200" />
+
+</scenario>
diff --git a/tests/channels/pjsip/aoc/aoc_s_to_caller_in_info/test-config.yaml b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_info/test-config.yaml
new file mode 100644
index 0000000..897fd63
--- /dev/null
+++ b/tests/channels/pjsip/aoc/aoc_s_to_caller_in_info/test-config.yaml
@@ -0,0 +1,62 @@
+info:
+ summary: 'Test AOC-S to caller after answer'
+ description: |
+ This uses an AOCMessage AMI to generate an AOC-S
+ event, generating a SIP INFO message sent to the
+ caller.
+
+test-modules:
+ test-object:
+ config-section: test-object-config
+ typename: sipp.SIPpTestCase
+ modules:
+ -
+ config-section: ami-config
+ typename: 'pluggable_modules.EventActionModule'
+
+test-object-config:
+ memcheck-delay-stop: 7
+ fail-on-any: True
+ test-iterations:
+ -
+ scenarios:
+ - { 'key-args': { 'scenario': 'caller.xml', '-i': '127.0.0.1', '-p': '5062' } }
+
+ami-config:
+ -
+ ami-events:
+ type: 'headermatch'
+ conditions:
+ match:
+ Event: 'Newexten'
+ Channel: 'PJSIP/caller-.*'
+ Application: 'Answer'
+ ami-actions:
+ action:
+ - Action: 'AOCMessage'
+ - Channel: '{channel}'
+ - MsgType: 'S'
+ - ChargedItem: 'BasicCommunication'
+ - RateType: 'Duration'
+ - CurrencyAmount: 1337
+ - CurrencyName: 'UNIT'
+ - CurrencyMultiplier: 'OneTenth'
+ - TimeScale: 'Minute'
+ - Time: 10
+ - ChargingType: 'ContinuousCharging'
+ - ChargedItem: 'CallAttempt'
+ - RateType: 'Flat'
+ - CurrencyAmount: 42
+ - CurrencyName: 'UNIT'
+ - CurrencyMultiplier: 'OneHundredth'
+
+properties:
+ dependencies:
+ - sipp :
+ version : 'v3.0'
+ - asterisk : 'chan_pjsip'
+ - asterisk : 'res_pjsip_aoc'
+ - asterisk : 'app_dial'
+ tags:
+ - PJSIP
+
diff --git a/tests/channels/pjsip/aoc/tests.yaml b/tests/channels/pjsip/aoc/tests.yaml
new file mode 100644
index 0000000..a418077
--- /dev/null
+++ b/tests/channels/pjsip/aoc/tests.yaml
@@ -0,0 +1,17 @@
+# Enter tests here in the order they should be considered for execution:
+tests:
+ - test: 'aoc_d_to_callee_in_200'
+ - test: 'aoc_d_to_callee_in_bye'
+ - test: 'aoc_d_to_callee_in_info'
+ - test: 'aoc_d_to_caller_in_200'
+ - test: 'aoc_d_to_caller_in_bye'
+ - test: 'aoc_d_to_caller_in_info'
+ - test: 'aoc_e_to_callee_in_200'
+ - test: 'aoc_e_to_callee_in_bye'
+ - test: 'aoc_e_to_caller_in_200'
+ - test: 'aoc_e_to_caller_in_bye'
+ - test: 'aoc_s_to_callee_in_info'
+ - test: 'aoc_s_to_caller_in_180'
+ - test: 'aoc_s_to_caller_in_183'
+ - test: 'aoc_s_to_caller_in_200'
+ - test: 'aoc_s_to_caller_in_info'
diff --git a/tests/channels/pjsip/tests.yaml b/tests/channels/pjsip/tests.yaml
index 858e063..2b8be77 100644
--- a/tests/channels/pjsip/tests.yaml
+++ b/tests/channels/pjsip/tests.yaml
@@ -2,6 +2,7 @@
tests:
- dir: 'allow_sending_180_after_183'
- dir: 'ami'
+ - dir: 'aoc'
- dir: 'auth'
- dir: 'basic_calls'
- dir: 'config_wizard'
--
To view, visit https://gerrit.asterisk.org/c/testsuite/+/19538
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: testsuite
Gerrit-Branch: 20
Gerrit-Change-Id: I061a250b477593c4f07441a3d811e9981feb17b2
Gerrit-Change-Number: 19538
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Kuron <m.kuron at gmx.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20221106/242f522b/attachment-0001.html>
More information about the asterisk-code-review
mailing list