[Asterisk-code-review] pjsip: New function PJSIP PARSE URI to parse URI and return ... (testsuite[13])

Jenkins2 asteriskteam at digium.com
Sun Nov 18 16:20:25 CST 2018


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/10591 )

Change subject: pjsip: New function PJSIP_PARSE_URI to parse URI and return part of URI
......................................................................

pjsip: New function PJSIP_PARSE_URI to parse URI and return part of URI

Added tests to parse pre-defined URIs and extract specified part of the URI
using the PJSIP_PARSE_URI function.

Test examples taken from the pjproject source
pjsip/src/test/uri_test.c

ASTERISK-28144 #close

Change-Id: Iea0d8bbd4bf96ad68dbd6395ca80905d19924771
---
A tests/channels/pjsip/dialplan_functions/pjsip_parse_uri/configs/ast1/extensions.conf
A tests/channels/pjsip/dialplan_functions/pjsip_parse_uri/configs/ast1/manager.users.conf.inc
A tests/channels/pjsip/dialplan_functions/pjsip_parse_uri/configs/ast1/pjsip.conf
A tests/channels/pjsip/dialplan_functions/pjsip_parse_uri/test-config.yaml
M tests/channels/pjsip/dialplan_functions/tests.yaml
5 files changed, 109 insertions(+), 0 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Benjamin Keith Ford: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/tests/channels/pjsip/dialplan_functions/pjsip_parse_uri/configs/ast1/extensions.conf b/tests/channels/pjsip/dialplan_functions/pjsip_parse_uri/configs/ast1/extensions.conf
new file mode 100644
index 0000000..0653994
--- /dev/null
+++ b/tests/channels/pjsip/dialplan_functions/pjsip_parse_uri/configs/ast1/extensions.conf
@@ -0,0 +1,53 @@
+
+[default]
+
+exten => uri_test,1,NoOp()
+same => n,Set(uri=${LOCAL(ARG1)})
+same => n,Set(type=${LOCAL(ARG2)})
+same => n,Set(expected=${LOCAL(ARG3)})
+same => n,Verbose(1, Calling PJSIP_PARSE_URI for URI ${uri}, type ${type})
+same => n,GotoIf($["${PJSIP_PARSE_URI(${uri},${type})}"="${expected}"]?pass)
+same => n,UserEvent(Result, Status: failed, Message: ${uri}, ${type} did not match expected value ${expected} - actual ${PJSIP_PARSE_URI(${uri},${type})})
+same => n(pass),NoOp()
+same => n,Return()
+
+exten => s,1,NoOp()
+same => n,Answer()
+
+; Test entries
+same => n,GoSub(default,uri_test,1(sip:localhost,host,localhost))
+same => n,GoSub(default,uri_test,1(sip:user at localhost,user,user))
+same => n,GoSub(default,uri_test,1(sip:user at localhost,host,localhost))
+same => n,GoSub(default,uri_test,1(sip:user:password at localhost:5060,user,user))
+same => n,GoSub(default,uri_test,1(sip:user:password at localhost:5060,passwd,password))
+same => n,GoSub(default,uri_test,1(sip:user:password at localhost:5060,host,localhost))
+same => n,GoSub(default,uri_test,1(sip:user:password at localhost:5060,port,5060))
+same => n,GoSub(default,uri_test,1(sip:localhost\;transport=tcp\;user=ip\;ttl=255\;lr\;maddr=127.0.0.1\;method=ACK,host,localhost))
+same => n,GoSub(default,uri_test,1(sip:localhost\;transport=tcp\;user=ip\;ttl=255\;lr\;maddr=127.0.0.1\;method=ACK,transport_param,tcp))
+same => n,GoSub(default,uri_test,1(sip:localhost\;transport=tcp\;user=ip\;ttl=255\;lr\;maddr=127.0.0.1\;method=ACK,user_param,ip))
+same => n,GoSub(default,uri_test,1(sip:localhost\;transport=tcp\;user=ip\;ttl=255\;lr\;maddr=127.0.0.1\;method=ACK,ttl_param,255))
+same => n,GoSub(default,uri_test,1(sip:localhost\;transport=tcp\;user=ip\;ttl=255\;lr\;maddr=127.0.0.1\;method=ACK,lr_param,1))
+same => n,GoSub(default,uri_test,1(sip:localhost\;transport=tcp\;user=ip\;ttl=255\;lr\;maddr=127.0.0.1\;method=ACK,maddr_param,127.0.0.1))
+same => n,GoSub(default,uri_test,1(sip:localhost\;transport=tcp\;user=ip\;ttl=255\;lr\;maddr=127.0.0.1\;method=ACK,method_param,ACK))
+same => n,GoSub(default,uri_test,1(sips:localhost,scheme,sips))
+same => n,GoSub(default,uri_test,1(sips:localhost,host,localhost))
+same => n,GoSub(default,uri_test,1(  Power Administrator  <sips:localhost>,display,Power Administrator))
+same => n,GoSub(default,uri_test,1(  Power Administrator  <sips:localhost>,host,localhost))
+same => n,GoSub(default,uri_test,1( "User" <sip:user at localhost:5071>,display,User))
+same => n,GoSub(default,uri_test,1( "User" <sip:user at localhost:5071>,user,user))
+same => n,GoSub(default,uri_test,1( "User" <sip:user at localhost:5071>,host,localhost))
+same => n,GoSub(default,uri_test,1( "User" <sip:user at localhost:5071>,port,5071))
+same => n,GoSub(default,uri_test,1(This is -. !% *_+`'~ me <sip:a19A&=+$\;?/%2d:%40a&Zz=+$@my_proxy09.MY-domain.com:9801>,display,This is -. !% *_+`'~ me))
+same => n,GoSub(default,uri_test,1(This is -. !% *_+`'~ me <sip:a19A&=+$\;?/%2d:%40a&Zz=+$@my_proxy09.MY-domain.com:9801>,user,a19A&=+$\;?/-))
+same => n,GoSub(default,uri_test,1(This is -. !% *_+`'~ me <sip:a19A&=+$\;?/%2d:%40a&Zz=+$@my_proxy09.MY-domain.com:9801>,passwd, at a&Zz=+$))
+same => n,GoSub(default,uri_test,1(This is -. !% *_+`'~ me <sip:a19A&=+$\;?/%2d:%40a&Zz=+$@my_proxy09.MY-domain.com:9801>,host,my_proxy09.MY-domain.com))
+same => n,GoSub(default,uri_test,1(This is -. !% *_+`'~ me <sip:a19A&=+$\;?/%2d:%40a&Zz=+$@my_proxy09.MY-domain.com:9801>,port,9801))
+same => n,GoSub(default,uri_test,1(sip:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.com,host,abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.com))
+same => n,GoSub(default,uri_test,1(sip:user@[::1]\;maddr=[::01],user,user))
+same => n,GoSub(default,uri_test,1(sip:user@[::1]\;maddr=[::01],host,::1))
+same => n,GoSub(default,uri_test,1(sip:user@[::1]\;maddr=[::01],maddr_param,[::01]))
+same => n,GoSub(default,uri_test,1(sip:[::1]\;maddr=[::01],host,::1))
+same => n,GoSub(default,uri_test,1(sip:[::1]\;maddr=[::01],maddr_param,[::01]))
+
+same => n,UserEvent(Result, Status: passed)
+same => n,Hangup()
diff --git a/tests/channels/pjsip/dialplan_functions/pjsip_parse_uri/configs/ast1/manager.users.conf.inc b/tests/channels/pjsip/dialplan_functions/pjsip_parse_uri/configs/ast1/manager.users.conf.inc
new file mode 100644
index 0000000..1ba0710
--- /dev/null
+++ b/tests/channels/pjsip/dialplan_functions/pjsip_parse_uri/configs/ast1/manager.users.conf.inc
@@ -0,0 +1 @@
+writetimeout=1000
\ No newline at end of file
diff --git a/tests/channels/pjsip/dialplan_functions/pjsip_parse_uri/configs/ast1/pjsip.conf b/tests/channels/pjsip/dialplan_functions/pjsip_parse_uri/configs/ast1/pjsip.conf
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/channels/pjsip/dialplan_functions/pjsip_parse_uri/configs/ast1/pjsip.conf
diff --git a/tests/channels/pjsip/dialplan_functions/pjsip_parse_uri/test-config.yaml b/tests/channels/pjsip/dialplan_functions/pjsip_parse_uri/test-config.yaml
new file mode 100644
index 0000000..d95a9c1
--- /dev/null
+++ b/tests/channels/pjsip/dialplan_functions/pjsip_parse_uri/test-config.yaml
@@ -0,0 +1,54 @@
+testinfo:
+    summary:     'Tests the PJSIP_PARSE_URI function'
+    description: |
+        'Parse pre-defined test URIs and extract specified part of the URI
+        using the PJSIP_PARSE_URI function.
+        Test examples taken from the pjproject source:
+        pjsip/src/test/uri_test.c'
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'test_case.SimpleTestCase'
+    modules:
+        -
+            config-section: ami-config
+            typename: 'ami.AMIEventModule'
+
+
+test-object-config:
+    spawn-after-hangup: True
+    test-iterations:
+        -
+            channel: 'Local/s at default'
+            application: 'Echo'
+
+ami-config:
+    -
+        id: '0'
+        type: 'headermatch'
+        count: '1'
+        conditions:
+            match:
+                Event: 'UserEvent'
+        requirements:
+            match:
+                Status: 'passed'
+    -
+        id: '0'
+        type: 'headermatch'
+        count: '0'
+        conditions:
+            match:
+                Event: 'UserEvent'
+                Status: 'failed'
+
+properties:
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+        - asterisk : 'res_pjsip'
+        - asterisk : 'chan_pjsip'
+        - asterisk : 'app_userevent'
+    tags:
+        - pjsip
diff --git a/tests/channels/pjsip/dialplan_functions/tests.yaml b/tests/channels/pjsip/dialplan_functions/tests.yaml
index a2e26a0..59821e5 100644
--- a/tests/channels/pjsip/dialplan_functions/tests.yaml
+++ b/tests/channels/pjsip/dialplan_functions/tests.yaml
@@ -8,4 +8,5 @@
     - test: 'pjsip_dtmfmode'
     - test: 'pjsip_endpoint'
     - test: 'pjsip_header'
+    - test: 'pjsip_parse_uri'
     - test: 'pjsip_session_refresh'

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

Gerrit-Project: testsuite
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: Iea0d8bbd4bf96ad68dbd6395ca80905d19924771
Gerrit-Change-Number: 10591
Gerrit-PatchSet: 1
Gerrit-Owner: Alexei Gradinari <alex2grad at gmail.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2 (1000185)
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20181118/8f2fcdb3/attachment-0001.html>


More information about the asterisk-code-review mailing list