[svn-commits] dvossel: branch dvossel/sip_string_parse_testing r244327 - /team/dvossel/sip_...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Tue Feb 2 12:10:48 CST 2010
Author: dvossel
Date: Tue Feb 2 12:10:47 2010
New Revision: 244327
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=244327
Log:
improved config and resquest/response testing for failure cases
Modified:
team/dvossel/sip_string_parse_testing/channels/sip/config-parser.c
team/dvossel/sip_string_parse_testing/channels/sip/reqresp-parser.c
Modified: team/dvossel/sip_string_parse_testing/channels/sip/config-parser.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/sip_string_parse_testing/channels/sip/config-parser.c?view=diff&rev=244327&r1=244326&r2=244327
==============================================================================
--- team/dvossel/sip_string_parse_testing/channels/sip/config-parser.c (original)
+++ team/dvossel/sip_string_parse_testing/channels/sip/config-parser.c Tue Feb 2 12:10:47 2010
@@ -69,6 +69,10 @@
if (!value) {
return -1;
}
+
+ if (!reg) {
+ return -1;
+ }
ast_copy_string(buf, value, sizeof(buf));
/*! register => [peer?][transport://]user[@domain][:secret[:authuser]]@host[:port][/extension][~expiry]
@@ -223,6 +227,8 @@
const char *reg6 = "tls://name@namedomain:pass:authuser@domain/extension~111";
const char *reg7 = "peer?tcp://name@namedomain:pass:authuser@domain:1234/extension~111";
const char *reg8 = "peer?name at namedomain:pass:authuser at domain:1234/extension~111";
+ const char *reg9 = "peer?name:pass:authuser:1234/extension~111";
+ const char *reg10 = "@domin:1234";
switch (cmd) {
case TEST_INIT:
@@ -453,6 +459,46 @@
ast_string_field_free_memory(reg);
ast_free(reg);
+ /* ---Test reg 9, missing domain, expected to fail --- */
+ if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
+ goto alloc_fail;
+ } else if (!sip_parse_register_line(reg, reg9, 1)) {
+
+ ast_str_append(&args->ast_test_error_str, 0, "Test 9, missing domain, expected to fail but did not.\n");
+ res = AST_TEST_FAIL;
+ }
+ ast_string_field_free_memory(reg);
+ ast_free(reg);
+
+ /* ---Test reg 10, missing user, expected to fail --- */
+ if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
+ goto alloc_fail;
+ } else if (!sip_parse_register_line(reg, reg10, 1)) {
+
+ ast_str_append(&args->ast_test_error_str, 0, "Test 10, missing user expected to fail but did not\n");
+ res = AST_TEST_FAIL;
+ }
+ ast_string_field_free_memory(reg);
+ ast_free(reg);
+
+ /* ---Test reg 11, no registry object, expected to fail--- */
+ if (!sip_parse_register_line(NULL, reg1, 1)) {
+
+ ast_str_append(&args->ast_test_error_str, 0, "Test 11, no registery object, expected to fail but did not.\n");
+ res = AST_TEST_FAIL;
+ }
+
+ /* ---Test reg 11, no registry line, expected to fail --- */
+ if (!(reg = ast_calloc_with_stringfields(1, struct sip_registry, 256))) {
+ goto alloc_fail;
+ } else if (!sip_parse_register_line(reg, NULL, 1)) {
+
+ ast_str_append(&args->ast_test_error_str, 0, "Test 11, NULL register line expected to fail but did not.\n");
+ res = AST_TEST_FAIL;
+ }
+ ast_string_field_free_memory(reg);
+ ast_free(reg);
+
return res;
Modified: team/dvossel/sip_string_parse_testing/channels/sip/reqresp-parser.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/sip_string_parse_testing/channels/sip/reqresp-parser.c?view=diff&rev=244327&r1=244326&r2=244327
==============================================================================
--- team/dvossel/sip_string_parse_testing/channels/sip/reqresp-parser.c (original)
+++ team/dvossel/sip_string_parse_testing/channels/sip/reqresp-parser.c Tue Feb 2 12:10:47 2010
@@ -122,7 +122,7 @@
char uri1[] = "sip:name at host";
char uri2[] = "sip:name at host;transport=tcp";
char uri3[] = "sip:name:secret at host;transport=tcp";
- char uri4[] = "sip:name:secret at host:port;transport=tcp?headers";
+ char uri4[] = "sip:name:secret at host:port;transport=tcp?headers=%40%40testblah&headers2=blah%20blah";
switch (cmd) {
case TEST_INIT:
info->name = "sip_uri_parse_test";
@@ -185,6 +185,20 @@
strcmp(transport, "tcp")) {
ast_str_append(&args->ast_test_error_str, 0, "Test 4: add port and unparsed header field failed.\n");
+ res = AST_TEST_FAIL;
+ }
+
+ /* Test 5, verify parse_uri does not crash when given a NULL uri */
+ name = pass = domain = port = transport = NULL;
+ if (!parse_uri(NULL, "sip:,sips:", &name, &pass, &domain, &port, &transport)) {
+ ast_str_append(&args->ast_test_error_str, 0, "Test 5: passing a NULL uri failed.\n");
+ res = AST_TEST_FAIL;
+ }
+
+ /* 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)) {
+ ast_str_append(&args->ast_test_error_str, 0, "Test 6: passing NULL output parameters failed.\n");
res = AST_TEST_FAIL;
}
More information about the svn-commits
mailing list