aboutsummaryrefslogtreecommitdiffstats
path: root/channels/sip
diff options
context:
space:
mode:
authordvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2010-02-10 23:13:49 +0000
committerdvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2010-02-10 23:13:49 +0000
commitbb96c2af4a28c2794f68266567f207d23e956aaa (patch)
tree20dc37fcf8e82b72211e163c50327b43ca6a0e49 /channels/sip
parent965e087bf8d2536ed16b21aedde7e2da1fd44894 (diff)
additional parse_uri test and documentation
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@246249 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/sip')
-rw-r--r--channels/sip/include/reqresp_parser.h2
-rw-r--r--channels/sip/reqresp_parser.c15
2 files changed, 16 insertions, 1 deletions
diff --git a/channels/sip/include/reqresp_parser.h b/channels/sip/include/reqresp_parser.h
index 8f7d58898..e724c98dd 100644
--- a/channels/sip/include/reqresp_parser.h
+++ b/channels/sip/include/reqresp_parser.h
@@ -31,6 +31,8 @@
* that if we don't have domain, we cannot split name:pass and domain:port.
* - It is safe to call with ret_name, pass, domain, port pointing all to
* the same place.
+ * - If no secret parameter is provided, ret_name will return with both parts, user:secret
+ * - If no port parameter is provided, domain will return with both parts, domain:port
* - This function overwrites the the uri string.
*
* \retval 0 on success
diff --git a/channels/sip/reqresp_parser.c b/channels/sip/reqresp_parser.c
index fe6ce0e1c..3697e7633 100644
--- a/channels/sip/reqresp_parser.c
+++ b/channels/sip/reqresp_parser.c
@@ -123,6 +123,10 @@ AST_TEST_DEFINE(sip_parse_uri_test)
char uri2[] = "sip:name@host;transport=tcp";
char uri3[] = "sip:name:secret@host;transport=tcp";
char uri4[] = "sip:name:secret@host:port;transport=tcp?headers=%40%40testblah&headers2=blah%20blah";
+ /* test 5 is for NULL input */
+ char uri6[] = "sip:name:secret@host:port;transport=tcp?headers=%40%40testblah&headers2=blah%20blah";
+ char uri7[] = "sip:name:secret@host:port;transport=tcp?headers=%40%40testblah&headers2=blah%20blah";
+
switch (cmd) {
case TEST_INIT:
info->name = "sip_uri_parse_test";
@@ -193,11 +197,20 @@ AST_TEST_DEFINE(sip_parse_uri_test)
/* Test 6, verify parse_uri does not crash when given a NULL output parameters */
name = pass = domain = port = transport = NULL;
- if (parse_uri(uri4, "sip:,sips:", NULL, NULL, NULL, NULL, NULL)) {
+ if (parse_uri(uri6, "sip:,sips:", NULL, NULL, NULL, NULL, NULL)) {
ast_test_status_update(test, "Test 6: passing NULL output parameters failed.\n");
res = AST_TEST_FAIL;
}
+ /* Test 7, verify parse_uri returns user:secret and domain:port when no port or secret output parameters are supplied. */
+ name = pass = domain = port = transport = NULL;
+ if (parse_uri(uri7, "sip:,sips:", &name, NULL, &domain, NULL, NULL) ||
+ strcmp(name, "name:secret") ||
+ strcmp(domain, "host:port")) {
+
+ ast_test_status_update(test, "Test 7: providing no port and secret output parameters failed.\n");
+ res = AST_TEST_FAIL;
+ }
return res;
}