changeset 890:19a261c9a2e1

Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
author Sebastien Decugis <sdecugis@freediameter.net>
date Sat, 17 Nov 2012 22:54:24 +0100
parents 4a299daed8b2
children 9432ac55823c
files tests/testmesg.c
diffstat 1 files changed, 53 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tests/testmesg.c	Sat Nov 17 22:52:50 2012 +0100
+++ b/tests/testmesg.c	Sat Nov 17 22:54:24 2012 +0100
@@ -185,6 +185,11 @@
 			CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, NULL ) );
 		}
 		
+		{
+			struct dict_avp_data avp_data = { 139103, 0, "AVP Test - no vendor - f64", 0, 0, AVP_TYPE_FLOAT64 };
+			CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, NULL ) );
+		}
+		
 		{ 
 			struct dict_object  * type = NULL;
 			struct dict_type_data type_data = { AVP_TYPE_INTEGER64, "Int64 test" };
@@ -271,6 +276,15 @@
 		}
 		
 		{
+			struct dict_object  * application = NULL;
+			struct dict_object  * command = NULL;
+			struct dict_cmd_data  cmd_data = { 73573, "Test-Command-Answer", CMD_FLAG_REQUEST, 0 };
+			
+			CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_APPLICATION, APPLICATION_BY_NAME, "Application test", &application, ENOENT ) );
+			CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_COMMAND, &cmd_data , application, &command ) );
+		}
+		
+		{
 			struct dict_object  * gavp = NULL;
 			struct dict_avp_data  avp_data = { 73574, 73565, "AVP Test - rules", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_GROUPED };
 			
@@ -725,6 +739,45 @@
 				CHECK( 0, fd_msg_free ( msg ) );
 			}
 			
+			/* Test with an invalid AVP (definition mismatch with the dictionary) */
+			{
+				CPYBUF();
+				
+				buf_cpy[21] = 0x02;	/* New AVP code = 0x00021F5F, f64 type in the dictionary */
+				
+				
+				/* Check that we cannot support this message now */
+				CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
+				CHECK( EBADMSG, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );
+				
+				/* reset */
+				CHECK( 0, fd_msg_free ( msg ) );
+			}
+			
+#if 1
+			{
+				/* Check the parse or error works as expected */
+				CPYBUF();
+				
+				buf_cpy[21] = 0x02;	/* New AVP code = 0x00021F5F, f64 type in the dictionary */
+				
+				/* Check that we cannot support this message now */
+				CHECK( 0, fd_msg_init() );
+				CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
+				CHECK( EBADMSG, fd_msg_parse_or_error( &msg ) );
+				
+				/* Check the Failed-AVP is as expected */
+				
+				fd_msg_dump_walk(0, msg);
+				
+				/* reset */
+				CHECK( 0, fd_msg_free ( msg ) );
+				
+				ASSERT(0);
+			}
+#endif			
+			
+			
 			CHECK( 0, fd_msg_parse_buffer( &buf, 344, &msg) );
 			CHECK( 0, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );
 			#if 0
"Welcome to our mercurial repository"