[Asterisk-code-review] res_pjsip_header_funcs: Add test for custom parameters. (testsuite[20])

Friendly Automation asteriskteam at digium.com
Fri Dec 9 09:27:48 CST 2022


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/testsuite/+/19687 )

Change subject: res_pjsip_header_funcs: Add test for custom parameters.
......................................................................

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
---
A tests/channels/pjsip/parameters/outgoing_uri/configs/ast1/extensions.conf
A tests/channels/pjsip/parameters/outgoing_uri/configs/ast1/pjsip.conf
A tests/channels/pjsip/parameters/outgoing_uri/test-config.yaml
A tests/channels/pjsip/parameters/tests.yaml
M tests/channels/pjsip/tests.yaml
5 files changed, 126 insertions(+), 0 deletions(-)

Approvals:
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit




diff --git a/tests/channels/pjsip/parameters/outgoing_uri/configs/ast1/extensions.conf b/tests/channels/pjsip/parameters/outgoing_uri/configs/ast1/extensions.conf
new file mode 100644
index 0000000..3a8dc1d
--- /dev/null
+++ b/tests/channels/pjsip/parameters/outgoing_uri/configs/ast1/extensions.conf
@@ -0,0 +1,30 @@
+
+[default]
+exten => s,1,NoOp(From header: ${PJSIP_HEADER(read,From,1)})
+	same => n,NoOp(${PJSIP_HEADER_PARAM(From,uri,isup-oli)} / ${PJSIP_HEADER_PARAM(From,uri,cpc)} / ${PJSIP_HEADER_PARAM(From,header,hdrtest)})
+	same => n,GotoIf($["${PJSIP_HEADER_PARAM(From,uri,isup-oli)}"!="27"]?fail,1)
+	same => n,GotoIf($["${PJSIP_HEADER_PARAM(From,uri,cpc)}"!="ordinary"]?fail,1)
+	same => n,GotoIf($["${PJSIP_HEADER_PARAM(From,header,hdrtest)}"!="hdrtestval"]?fail,1)
+	same => n,Answer()
+	same => n,UserEvent(TestSuccess,Result: Pass)
+	same => n,Hangup()
+exten => fail,1,UserEvent(TestFail,Result: Fail)
+	same => n,Hangup()
+
+[pre-dial]
+exten => s,1,Set(PJSIP_HEADER_PARAM(From,uri,isup-oli)=27) ; Manually set the ANI2 for the outgoing call
+	same => n,Set(PJSIP_HEADER_PARAM(From,uri,cpc)=ordinary)
+	same => n,Set(PJSIP_HEADER_PARAM(From,header,hdrtest)=hdrtestval)
+	same => n,Return()
+
+[dial]
+exten => s,1,Answer()
+	same => n,Set(CALLERID(num)=5552368)
+	same => n,Dial(PJSIP/loopback/sip:s at 127.0.0.1,,b(pre-dial^s^1)) ; loop a call back to ourself to test.
+	same => n,UserEvent(TestFail,Result: Fail) ; If we fall through, it didn't work.
+	same => n,Hangup()
+
+[nothing]
+exten => s,1,Answer()
+	same => n,Wait(10)
+	same => n,Hangup()
diff --git a/tests/channels/pjsip/parameters/outgoing_uri/configs/ast1/pjsip.conf b/tests/channels/pjsip/parameters/outgoing_uri/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..88d5e7e
--- /dev/null
+++ b/tests/channels/pjsip/parameters/outgoing_uri/configs/ast1/pjsip.conf
@@ -0,0 +1,20 @@
+[global]
+type = global
+endpoint_identifier_order = ip,username,anonymous
+
+[local-transport-udp]
+type=transport
+bind=127.0.0.1
+protocol=udp
+
+[loopback]
+type=identify
+match=127.0.0.1
+endpoint=loopback
+
+[loopback]
+type=endpoint
+identify_by=ip
+disallow=all
+allow=ulaw
+context=default
diff --git a/tests/channels/pjsip/parameters/outgoing_uri/test-config.yaml b/tests/channels/pjsip/parameters/outgoing_uri/test-config.yaml
new file mode 100644
index 0000000..de252b5
--- /dev/null
+++ b/tests/channels/pjsip/parameters/outgoing_uri/test-config.yaml
@@ -0,0 +1,58 @@
+testinfo:
+    summary: 'Ensure that custom parameters work correctly.'
+    description: |
+        'This tests that outgoing URI and header parameters can be set in
+        the PJSIP From header and ensuring they can be read on an incoming call.'
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'test_case.TestCaseModule'
+    modules:
+        -
+            config-section: caller-originator
+            typename: 'pluggable_modules.Originator'
+        -
+            config-section: hangup-monitor
+            typename: 'pluggable_modules.HangupMonitor'
+        -
+            config-section: ami-config
+            typename: 'pluggable_modules.EventActionModule'
+
+test-object-config:
+    connect-ami: True
+
+caller-originator:
+    channel: 'Local/s at dial'
+    context: 'nothing'
+    exten: 's'
+    priority: '1'
+    trigger: 'ami_connect'
+
+hangup-monitor:
+    ids: '0'
+
+ami-config:
+    -
+        ami-events:
+            conditions:
+                match:
+                    Event: 'UserEvent'
+                    UserEvent: 'TestSuccess'
+            requirements:
+                match:
+                    Result: 'Pass'
+            count: 1
+        stop_test:
+
+properties:
+    tags:
+        - dial
+        - channels
+    dependencies:
+        - python: 'twisted'
+        - python: 'starpy'
+        - asterisk: 'app_dial'
+        - asterisk: 'app_userevent'
+        - asterisk: 'chan_pjsip'
+        - asterisk: 'pbx_config'
diff --git a/tests/channels/pjsip/parameters/tests.yaml b/tests/channels/pjsip/parameters/tests.yaml
new file mode 100644
index 0000000..51602fb
--- /dev/null
+++ b/tests/channels/pjsip/parameters/tests.yaml
@@ -0,0 +1,3 @@
+# Enter tests here in the order they should be considered for execution:
+tests:
+    - test: 'outgoing_uri'
diff --git a/tests/channels/pjsip/tests.yaml b/tests/channels/pjsip/tests.yaml
index 858e063..92fbf5f 100644
--- a/tests/channels/pjsip/tests.yaml
+++ b/tests/channels/pjsip/tests.yaml
@@ -15,6 +15,7 @@
     - dir: 'message'
     - dir: 'nat'
     - dir: 'one_touch_recording'
+    - dir: 'parameters'
     - dir: 'publish'
     - dir: 'qualify'
     - dir: 'registration'

-- 
To view, visit https://gerrit.asterisk.org/c/testsuite/+/19687
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: 20
Gerrit-Change-Id: Ic897797c6f0abf92bf5c7ce1fe26ebc45b10a064
Gerrit-Change-Number: 19687
Gerrit-PatchSet: 1
Gerrit-Owner: N A <asterisk at phreaknet.org>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20221209/ab21d6ec/attachment-0001.html>


More information about the asterisk-code-review mailing list