[asterisk-commits] dvossel: trunk r271056 - /trunk/channels/sip/reqresp_parser.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Jun 16 17:37:49 CDT 2010
Author: dvossel
Date: Wed Jun 16 17:37:45 2010
New Revision: 271056
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=271056
Log:
addition of more parse_uri test cases
Modified:
trunk/channels/sip/reqresp_parser.c
Modified: trunk/channels/sip/reqresp_parser.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sip/reqresp_parser.c?view=diff&rev=271056&r1=271055&r2=271056
==============================================================================
--- trunk/channels/sip/reqresp_parser.c (original)
+++ trunk/channels/sip/reqresp_parser.c Wed Jun 16 17:37:45 2010
@@ -516,6 +516,10 @@
/* test 5 is for NULL input */
char uri6[] = "sip:name:secret at host:port;transport=tcp?headers=%40%40testblah&headers2=blah%20blah";
char uri7[] = "sip:name:secret at host:port;transport=tcp?headers=%40%40testblah&headers2=blah%20blah";
+ char uri8[] = "sip:host";
+ char uri9[] = "sip:host:port;transport=tcp?headers=%40%40testblah&headers2=blah%20blah";
+ char uri10[] = "host:port;transport=tcp?headers=%40%40testblah&headers2=blah%20blah";
+ char uri11[] = "host";
switch (cmd) {
case TEST_INIT:
@@ -601,6 +605,56 @@
ast_test_status_update(test, "Test 7: providing no port and secret output parameters failed.\n");
res = AST_TEST_FAIL;
}
+
+ /* Test 8, verify parse_uri can handle a domain only uri */
+ name = pass = domain = port = transport = NULL;
+ if (parse_uri(uri8, "sip:,sips:", &name, &pass, &domain, &port, &transport) ||
+ strcmp(domain, "host") ||
+ !ast_strlen_zero(name)) {
+ ast_test_status_update(test, "Test 8: add port and unparsed header field failed.\n");
+ res = AST_TEST_FAIL;
+ }
+
+ /* Test 9, add port and unparsed header field with domain only uri*/
+ name = pass = domain = port = transport = NULL;
+ if (parse_uri(uri9, "sip:,sips:", &name, &pass, &domain, &port, &transport) ||
+ !ast_strlen_zero(name) ||
+ !ast_strlen_zero(pass) ||
+ strcmp(domain, "host") ||
+ strcmp(port, "port") ||
+ strcmp(transport, "tcp")) {
+ ast_test_status_update(test, "Test 9: domain only uri failed \n");
+ res = AST_TEST_FAIL;
+ }
+
+ /* Test 10, handle invalid/missing "sip:,sips:" scheme
+ * we expect parse_uri to return an error, but still parse
+ * the results correctly here */
+ name = pass = domain = port = transport = NULL;
+ if (!parse_uri(uri10, "sip:,sips:", &name, &pass, &domain, &port, &transport) ||
+ !ast_strlen_zero(name) ||
+ !ast_strlen_zero(pass) ||
+ strcmp(domain, "host") ||
+ strcmp(port, "port") ||
+ strcmp(transport, "tcp")) {
+ ast_test_status_update(test, "Test 10: missing \"sip:sips:\" scheme failed\n");
+ res = AST_TEST_FAIL;
+ }
+
+ /* Test 11, simple domain only URI with missing scheme
+ * we expect parse_uri to return an error, but still parse
+ * the results correctly here */
+ name = pass = domain = port = transport = NULL;
+ if (!parse_uri(uri11, "sip:,sips:", &name, &pass, &domain, &port, &transport) ||
+ !ast_strlen_zero(name) ||
+ !ast_strlen_zero(pass) ||
+ strcmp(domain, "host") ||
+ !ast_strlen_zero(port) ||
+ !ast_strlen_zero(transport)) {
+ ast_test_status_update(test, "Test 11: simple uri with missing scheme failed. \n");
+ res = AST_TEST_FAIL;
+ }
+
return res;
}
More information about the asterisk-commits
mailing list