Skip to content

Commit 86bc96d

Browse files
InterLinked1Friendly Automation
authored and
Friendly Automation
committed
res_pjsip_header_funcs: Add test for custom parameters.
Adds a test suite case for ensuring that custom parameters can be set and read using PJSIP_HEADER_PARAM correctly. ASTERISK_30150 Change-Id: Ic897797c6f0abf92bf5c7ce1fe26ebc45b10a064
1 parent 825c123 commit 86bc96d

File tree

5 files changed

+112
-0
lines changed

5 files changed

+112
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
[default]
3+
exten => s,1,NoOp(From header: ${PJSIP_HEADER(read,From,1)})
4+
same => n,NoOp(${PJSIP_HEADER_PARAM(From,uri,isup-oli)} / ${PJSIP_HEADER_PARAM(From,uri,cpc)} / ${PJSIP_HEADER_PARAM(From,header,hdrtest)})
5+
same => n,GotoIf($["${PJSIP_HEADER_PARAM(From,uri,isup-oli)}"!="27"]?fail,1)
6+
same => n,GotoIf($["${PJSIP_HEADER_PARAM(From,uri,cpc)}"!="ordinary"]?fail,1)
7+
same => n,GotoIf($["${PJSIP_HEADER_PARAM(From,header,hdrtest)}"!="hdrtestval"]?fail,1)
8+
same => n,Answer()
9+
same => n,UserEvent(TestSuccess,Result: Pass)
10+
same => n,Hangup()
11+
exten => fail,1,UserEvent(TestFail,Result: Fail)
12+
same => n,Hangup()
13+
14+
[pre-dial]
15+
exten => s,1,Set(PJSIP_HEADER_PARAM(From,uri,isup-oli)=27) ; Manually set the ANI2 for the outgoing call
16+
same => n,Set(PJSIP_HEADER_PARAM(From,uri,cpc)=ordinary)
17+
same => n,Set(PJSIP_HEADER_PARAM(From,header,hdrtest)=hdrtestval)
18+
same => n,Return()
19+
20+
[dial]
21+
exten => s,1,Answer()
22+
same => n,Set(CALLERID(num)=5552368)
23+
same => n,Dial(PJSIP/loopback/sip:s@127.0.0.1,,b(pre-dial^s^1)) ; loop a call back to ourself to test.
24+
same => n,UserEvent(TestFail,Result: Fail) ; If we fall through, it didn't work.
25+
same => n,Hangup()
26+
27+
[nothing]
28+
exten => s,1,Answer()
29+
same => n,Wait(10)
30+
same => n,Hangup()
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[global]
2+
type = global
3+
endpoint_identifier_order = ip,username,anonymous
4+
5+
[local-transport-udp]
6+
type=transport
7+
bind=127.0.0.1
8+
protocol=udp
9+
10+
[loopback]
11+
type=identify
12+
match=127.0.0.1
13+
endpoint=loopback
14+
15+
[loopback]
16+
type=endpoint
17+
identify_by=ip
18+
disallow=all
19+
allow=ulaw
20+
context=default
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
testinfo:
2+
summary: 'Ensure that custom parameters work correctly.'
3+
description: |
4+
'This tests that outgoing URI and header parameters can be set in
5+
the PJSIP From header and ensuring they can be read on an incoming call.'
6+
7+
test-modules:
8+
test-object:
9+
config-section: test-object-config
10+
typename: 'test_case.TestCaseModule'
11+
modules:
12+
-
13+
config-section: caller-originator
14+
typename: 'pluggable_modules.Originator'
15+
-
16+
config-section: hangup-monitor
17+
typename: 'pluggable_modules.HangupMonitor'
18+
-
19+
config-section: ami-config
20+
typename: 'pluggable_modules.EventActionModule'
21+
22+
test-object-config:
23+
connect-ami: True
24+
25+
caller-originator:
26+
channel: 'Local/s@dial'
27+
context: 'nothing'
28+
exten: 's'
29+
priority: '1'
30+
trigger: 'ami_connect'
31+
32+
hangup-monitor:
33+
ids: '0'
34+
35+
ami-config:
36+
-
37+
ami-events:
38+
conditions:
39+
match:
40+
Event: 'UserEvent'
41+
UserEvent: 'TestSuccess'
42+
requirements:
43+
match:
44+
Result: 'Pass'
45+
count: 1
46+
stop_test:
47+
48+
properties:
49+
tags:
50+
- dial
51+
- channels
52+
dependencies:
53+
- python: 'twisted'
54+
- python: 'starpy'
55+
- asterisk: 'app_dial'
56+
- asterisk: 'app_userevent'
57+
- asterisk: 'chan_pjsip'
58+
- asterisk: 'pbx_config'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Enter tests here in the order they should be considered for execution:
2+
tests:
3+
- test: 'outgoing_uri'

tests/channels/pjsip/tests.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ tests:
1515
- dir: 'message'
1616
- dir: 'nat'
1717
- dir: 'one_touch_recording'
18+
- dir: 'parameters'
1819
- dir: 'publish'
1920
- dir: 'qualify'
2021
- dir: 'registration'

0 commit comments

Comments
 (0)