add URI validation for file://

parent 46c40fd4
......@@ -46,9 +46,8 @@ static void test_basic_uri() {
CU_ASSERT_STRING_EQUAL("http://www.linphone.org/a/b/c",source_uri_raw = belle_sip_object_to_string(source_uri));
belle_sip_free(source_uri_raw);
belle_sip_object_unref(source_uri);
}
static void test_complex_uri() {
belle_generic_uri_t* source_uri = belle_generic_uri_parse("ftp://toto:secret@ftp.linphone.fr:1234/url?sa=t&rct=j&url=http%3A%2F%2Ftranslate.google.fr");
......@@ -71,7 +70,7 @@ static void test_complex_uri() {
belle_sip_object_unref(uri);
}
static void test_abs_path() {
static void test_file_path() {
belle_generic_uri_t* source_uri = belle_generic_uri_parse("/index.html");
char* source_uri_raw = belle_sip_object_to_string(source_uri);
belle_generic_uri_t* first_uri = belle_generic_uri_parse(source_uri_raw);
......@@ -84,13 +83,25 @@ static void test_abs_path() {
CU_ASSERT_PTR_NULL(belle_generic_uri_get_host(uri));
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(uri),"/index.html");
belle_sip_object_unref(uri);
source_uri = belle_generic_uri_parse("file:///tmp/absolute-file");
CU_ASSERT_PTR_NOT_NULL_FATAL(source_uri);
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_scheme(source_uri),"file");
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_host(source_uri),"localhost");
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(source_uri),"/tmp/absolute-file");
belle_sip_object_unref(source_uri);
//this is INVALID
source_uri = belle_generic_uri_parse("file:///./relative-file");
CU_ASSERT_PTR_NULL(source_uri);
}
static test_t tests[] = {
{ "Simple uri", test_basic_uri },
{ "Complex uri", test_complex_uri },
{ "abs path", test_abs_path }
{ "File path", test_file_path }
};
test_suite_t generic_uri_test_suite = {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment