From 53bc2cd5a0ad55c2c378d570dd678a79879c4c29 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 2 Feb 2015 18:13:20 +0100 Subject: [PATCH] add tests to check sips and ipv6 support of flexisip --- coreapi/address.c | 16 ++++ coreapi/bellesip_sal/sal_address_impl.c | 6 ++ coreapi/linphonecore.h | 4 +- include/sal/sal.h | 1 + tester/accountmanager.c | 9 +- tester/flexisip_tester.c | 116 ++++++++++++++++++++++++ tester/liblinphone_tester.h | 1 + tester/rcfiles/marie_sips_rc | 53 +++++++++++ tester/rcfiles/pauline_sips_rc | 50 ++++++++++ tester/tester.c | 6 ++ tester/tester_hosts | 1 + 11 files changed, 260 insertions(+), 3 deletions(-) create mode 100644 tester/rcfiles/marie_sips_rc create mode 100644 tester/rcfiles/pauline_sips_rc diff --git a/coreapi/address.c b/coreapi/address.c index d9d772337..1299a5351 100644 --- a/coreapi/address.c +++ b/coreapi/address.c @@ -154,11 +154,27 @@ char *linphone_address_as_string_uri_only(const LinphoneAddress *u){ /** * Returns true if address refers to a secure location (sips) + * @deprecated use linphone_address_get_secure() **/ bool_t linphone_address_is_secure(const LinphoneAddress *uri){ return sal_address_is_secure(uri); } +/** + * Returns true if address refers to a secure location (sips) +**/ +bool_t linphone_address_get_secure(const LinphoneAddress *uri){ + return sal_address_is_secure(uri); +} + +/** + * Make the address refer to a secure location (sips scheme) + * @param enabled TRUE if address is requested to be secure. +**/ +void linphone_address_set_secure(LinphoneAddress *addr, bool_t enabled){ + sal_address_set_secure(addr, enabled); +} + /** * returns true if address is a routable sip address */ diff --git a/coreapi/bellesip_sal/sal_address_impl.c b/coreapi/bellesip_sal/sal_address_impl.c index 034135f72..2546e7850 100644 --- a/coreapi/bellesip_sal/sal_address_impl.c +++ b/coreapi/bellesip_sal/sal_address_impl.c @@ -49,6 +49,12 @@ const char *sal_address_get_scheme(const SalAddress *addr){ return NULL; } +void sal_address_set_secure(SalAddress *addr, bool_t enabled){ + belle_sip_header_address_t* header_addr = BELLE_SIP_HEADER_ADDRESS(addr); + belle_sip_uri_t* uri = belle_sip_header_address_get_uri(header_addr); + if (uri) belle_sip_uri_set_secure(uri,enabled); +} + bool_t sal_address_is_secure(const SalAddress *addr){ belle_sip_header_address_t* header_addr = BELLE_SIP_HEADER_ADDRESS(addr); belle_sip_uri_t* uri = belle_sip_header_address_get_uri(header_addr); diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 6997c3470..a17efa793 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -397,7 +397,9 @@ LINPHONE_PUBLIC void linphone_address_set_domain(LinphoneAddress *uri, const cha LINPHONE_PUBLIC void linphone_address_set_port(LinphoneAddress *uri, int port); /*remove tags, params etc... so that it is displayable to the user*/ LINPHONE_PUBLIC void linphone_address_clean(LinphoneAddress *uri); -LINPHONE_PUBLIC bool_t linphone_address_is_secure(const LinphoneAddress *uri); +LINPHONE_PUBLIC bool_t linphone_address_is_secure(const LinphoneAddress *addr); +LINPHONE_PUBLIC bool_t linphone_address_get_secure(const LinphoneAddress *addr); +LINPHONE_PUBLIC void linphone_address_set_secure(LinphoneAddress *addr, bool_t enabled); LINPHONE_PUBLIC bool_t linphone_address_is_sip(const LinphoneAddress *uri); LINPHONE_PUBLIC LinphoneTransportType linphone_address_get_transport(const LinphoneAddress *uri); LINPHONE_PUBLIC void linphone_address_set_transport(LinphoneAddress *uri,LinphoneTransportType type); diff --git a/include/sal/sal.h b/include/sal/sal.h index f765bf349..95037fe0e 100644 --- a/include/sal/sal.h +++ b/include/sal/sal.h @@ -92,6 +92,7 @@ const char *sal_address_get_username(const SalAddress *addr); const char *sal_address_get_domain(const SalAddress *addr); int sal_address_get_port(const SalAddress *addr); bool_t sal_address_is_secure(const SalAddress *addr); +void sal_address_set_secure(SalAddress *addr, bool_t enabled); SalTransport sal_address_get_transport(const SalAddress* addr); const char* sal_address_get_transport_name(const SalAddress* addr); diff --git a/tester/accountmanager.c b/tester/accountmanager.c index 2236b2039..93c250135 100644 --- a/tester/accountmanager.c +++ b/tester/accountmanager.c @@ -130,6 +130,7 @@ void account_create_on_server(Account *account, const LinphoneProxyConfig *refcf linphone_core_set_sip_transports(lc,&tr); cfg=linphone_core_create_proxy_config(lc); + linphone_address_set_secure(tmp_identity, FALSE); linphone_address_set_password(tmp_identity,account->password); linphone_address_set_header(tmp_identity,"X-Create-Account","yes"); tmp=linphone_address_as_string(tmp_identity); @@ -138,7 +139,8 @@ void account_create_on_server(Account *account, const LinphoneProxyConfig *refcf linphone_address_unref(tmp_identity); server_addr=linphone_address_new(linphone_proxy_config_get_server_addr(refcfg)); - linphone_address_set_transport(server_addr,LinphoneTransportTcp); /*use tcp for account creation*/ + linphone_address_set_secure(server_addr, FALSE); + linphone_address_set_transport(server_addr,LinphoneTransportTcp); /*use tcp for account creation, we may not have certificates configured at this stage*/ linphone_address_set_port(server_addr,0); tmp=linphone_address_as_string(server_addr); linphone_proxy_config_set_server_addr(cfg,tmp); @@ -152,8 +154,11 @@ void account_create_on_server(Account *account, const LinphoneProxyConfig *refcf ms_fatal("Account for %s could not be created on server.", linphone_proxy_config_get_identity(refcfg)); } linphone_proxy_config_edit(cfg); - tmp=linphone_address_as_string(account->modified_identity); + tmp_identity=linphone_address_clone(account->modified_identity); + linphone_address_set_secure(tmp_identity, FALSE); + tmp=linphone_address_as_string(tmp_identity); linphone_proxy_config_set_identity(cfg,tmp); /*remove the X-Create-Account header*/ + linphone_address_unref(tmp_identity); ms_free(tmp); linphone_proxy_config_done(cfg); diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index 4b310be88..3e5992988 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -583,6 +583,119 @@ static void early_media_call_forking(void) { linphone_core_manager_destroy(pauline); } +static void call_with_sips(void){ + LinphoneCoreManager* marie = linphone_core_manager_new( "marie_sips_rc"); + LinphoneCoreManager* pauline1 = linphone_core_manager_new( "pauline_sips_rc"); + LinphoneCoreManager* pauline2 = linphone_core_manager_new( "pauline_tcp_rc"); + MSList* lcs=ms_list_append(NULL,marie->lc); + + lcs=ms_list_append(lcs,pauline1->lc); + lcs=ms_list_append(lcs,pauline2->lc); + + linphone_core_set_user_agent(marie->lc,"Natted Linphone",NULL); + linphone_core_set_user_agent(pauline1->lc,"Natted Linphone",NULL); + linphone_core_set_user_agent(pauline2->lc,"Natted Linphone",NULL); + + linphone_core_invite_address(marie->lc,pauline1->identity); + + /*marie should hear ringback*/ + CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallOutgoingRinging,1,3000)); + /*Only the sips registered device from pauline should ring*/ + CU_ASSERT_TRUE(wait_for_list(lcs,&pauline1->stat.number_of_LinphoneCallIncomingReceived,1,1000)); + + /*pauline accepts the call */ + linphone_core_accept_call(pauline1->lc,linphone_core_get_current_call(pauline1->lc)); + CU_ASSERT_TRUE(wait_for_list(lcs,&pauline1->stat.number_of_LinphoneCallConnected,1,1000)); + CU_ASSERT_TRUE(wait_for_list(lcs,&pauline1->stat.number_of_LinphoneCallStreamsRunning,1,1000)); + CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallConnected,1,1000)); + CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallStreamsRunning,1,1000)); + + /*pauline2 should not have ring*/ + CU_ASSERT_TRUE(pauline2->stat.number_of_LinphoneCallIncomingReceived==0); + + linphone_core_terminate_call(pauline1->lc,linphone_core_get_current_call(pauline1->lc)); + CU_ASSERT_TRUE(wait_for_list(lcs,&pauline1->stat.number_of_LinphoneCallEnd,1,3000)); + CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,3000)); + + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline1); + linphone_core_manager_destroy(pauline2); + ms_list_free(lcs); +} + +static void call_with_sips_not_achievable(void){ + LinphoneCoreManager* marie = linphone_core_manager_new( "marie_sips_rc"); + LinphoneCoreManager* pauline1 = linphone_core_manager_new( "pauline_rc"); + LinphoneCoreManager* pauline2 = linphone_core_manager_new( "pauline_tcp_rc"); + MSList* lcs=ms_list_append(NULL,marie->lc); + LinphoneAddress *dest; + LinphoneCall *call; + const LinphoneErrorInfo *ei; + + lcs=ms_list_append(lcs,pauline1->lc); + lcs=ms_list_append(lcs,pauline2->lc); + + + dest=linphone_address_clone(pauline1->identity); + linphone_address_set_secure(dest,TRUE); + call=linphone_core_invite_address(marie->lc,dest); + linphone_call_ref(call); + linphone_address_unref(dest); + + /*Call should be rejected by server with 480*/ + CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallError,1,3000)); + ei=linphone_call_get_error_info(call); + CU_ASSERT_PTR_NOT_NULL(ei); + if (ei){ + CU_ASSERT_EQUAL(linphone_error_info_get_reason(ei), LinphoneReasonTemporarilyUnavailable); + } + + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline1); + linphone_core_manager_destroy(pauline2); + ms_list_free(lcs); +} + +static void call_with_ipv6(void) { + int begin; + int leaked_objects; + LinphoneCoreManager* marie; + LinphoneCoreManager* pauline; + LinphoneCall *pauline_call; + + /*skipped until sip2 has ipv6 address*/ + return; + + if (!liblinphone_tester_ipv6_available()){ + ms_warning("Call with ipv6 not tested, no ipv6 connectivity"); + return; + } + + belle_sip_object_enable_leak_detector(TRUE); + begin=belle_sip_object_get_object_count(); + + liblinphone_tester_enable_ipv6(TRUE); + marie = linphone_core_manager_new( "marie_rc"); + pauline = linphone_core_manager_new( "pauline_rc"); + + linphone_core_set_user_agent(marie->lc,"Natted Linphone",NULL); + linphone_core_set_user_agent(pauline->lc,"Natted Linphone",NULL); + CU_ASSERT_TRUE(call(marie,pauline)); + pauline_call=linphone_core_get_current_call(pauline->lc); + CU_ASSERT_PTR_NOT_NULL(pauline_call); + + liblinphone_tester_check_rtcp(marie,pauline); + end_call(marie,pauline); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); + liblinphone_tester_enable_ipv6(FALSE); + + leaked_objects=belle_sip_object_get_object_count()-begin; + CU_ASSERT_TRUE(leaked_objects==0); + if (leaked_objects>0){ + belle_sip_object_dump_active_objects(); + } +} test_t flexisip_tests[] = { { "Subscribe forking", subscribe_forking }, @@ -598,6 +711,9 @@ test_t flexisip_tests[] = { { "Call forking with push notification (multiple)", call_forking_with_push_notification_multiple }, { "Call forking not responded", call_forking_not_responded }, { "Early-media call forking", early_media_call_forking }, + { "Call with sips", call_with_sips }, + { "Call with sips not achievable", call_with_sips_not_achievable }, + { "Call with ipv6", call_with_ipv6 } }; diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index b6aca2626..8111015f0 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -307,6 +307,7 @@ bool_t liblinphone_tester_clock_elapsed(const MSTimeSpec *start, int value_ms); void linphone_core_manager_check_accounts(LinphoneCoreManager *m); void account_manager_destroy(void); LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* path, const char* file, void* user_data); +void liblinphone_tester_enable_ipv6(bool_t enabled); #ifdef ANDROID void cunit_android_trace_handler(int level, const char *fmt, va_list args) ; #endif diff --git a/tester/rcfiles/marie_sips_rc b/tester/rcfiles/marie_sips_rc new file mode 100644 index 000000000..0723c13a0 --- /dev/null +++ b/tester/rcfiles/marie_sips_rc @@ -0,0 +1,53 @@ +[sip] +sip_port=-1 +sip_tcp_port=-1 +sip_tls_port=-1 +default_proxy=0 +ping_with_options=0 +register_only_when_network_is_up=0 +composing_idle_timeout=1 + +[auth_info_0] +username=marie +userid=marie +passwd=secret +realm=sip2.linphone.org + + +[proxy_0] +reg_proxy=sips:sip2.linphone.org +reg_route=sips:sip2.linphone.org +reg_identity="Super Marie" +reg_expires=3600 +reg_sendregister=1 +publish=0 +dial_escape_plus=0 +quality_reporting_collector=sip:collector@sip2.linphone.org +quality_reporting_enabled=1 + +[friend_0] +url="Paupoche" +pol=accept +subscribe=0 + + +[rtp] +audio_rtp_port=8070 +video_rtp_port=9072 + +[video] +display=0 +capture=0 +show_local=0 +size=vga +enabled=0 +self_view=0 +automatically_initiate=0 +automatically_accept=0 +device=StaticImage: Static picture + +[sound] +echocancellation=0 #to not overload cpu in case of VG + +[net] +dns_srv_enabled=0 #no srv needed in general diff --git a/tester/rcfiles/pauline_sips_rc b/tester/rcfiles/pauline_sips_rc new file mode 100644 index 000000000..5d9f3d5ed --- /dev/null +++ b/tester/rcfiles/pauline_sips_rc @@ -0,0 +1,50 @@ +[sip] +sip_port=-1 +sip_tcp_port=-1 +sip_tls_port=-1 +default_proxy=0 +ping_with_options=0 +register_only_when_network_is_up=0 +composing_idle_timeout=1 + +[auth_info_0] +username=pauline +userid=pauline +passwd=secret +realm=sip.example.org + + +[proxy_0] +reg_proxy=sips:sip2.linphone.org +reg_route=sips:sip2.linphone.org +reg_identity=sips:pauline@sip.example.org +reg_expires=3600 +reg_sendregister=1 +publish=0 +dial_escape_plus=0 + +#[friend_0] +#url="Mariette" +#pol=accept +#subscribe=0 + +[rtp] +audio_rtp_port=8090 +video_rtp_port=9092 + +[video] +display=0 +capture=0 +show_local=0 +size=vga +enabled=0 +self_view=0 +automatically_initiate=0 +automatically_accept=0 +device=StaticImage: Static picture + +[sound] +echocancellation=0 #to not overload cpu in case of VG + +[net] +dns_srv_enabled=0 #no srv needed in general diff --git a/tester/tester.c b/tester/tester.c index d3a34a375..cbd1bfd44 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -41,6 +41,7 @@ const char* test_password="secret"; const char* test_route="sip2.linphone.org"; int liblinphone_tester_use_log_file=0; static int liblinphone_tester_keep_accounts_flag = 0; +static bool_t liblinphone_tester_ipv6_enabled=FALSE; static int manager_count = 0; static const char* liblinphone_tester_xml_file = NULL; @@ -83,6 +84,10 @@ bool_t liblinphone_tester_clock_elapsed(const MSTimeSpec *start, int value_ms){ return FALSE; } +void liblinphone_tester_enable_ipv6(bool_t enabled){ + liblinphone_tester_ipv6_enabled=enabled; +} + LinphoneAddress * create_linphone_address(const char * domain) { LinphoneAddress *addr = linphone_address_new(NULL); CU_ASSERT_PTR_NOT_NULL_FATAL(addr); @@ -157,6 +162,7 @@ LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* path, c sal_set_dns_user_hosts_file(lc->sal, dnsuserhostspath); linphone_core_set_static_picture(lc,nowebcampath); + linphone_core_enable_ipv6(lc, liblinphone_tester_ipv6_enabled); ms_free(ringpath); ms_free(ringbackpath); diff --git a/tester/tester_hosts b/tester/tester_hosts index b7056b863..872dd4a63 100644 --- a/tester/tester_hosts +++ b/tester/tester_hosts @@ -1 +1,2 @@ 94.23.19.176 sip2.linphone.org sip.example.org sipopen.example.org auth.example.org auth1.example.org auth2.example.org altname.linphone.org sip.wildcard1.linphone.org altname.wildcard2.linphone.org +2001:41d0:2:14b0::1 sip2.linphone.org sip.example.org sipopen.example.org auth.example.org auth1.example.org auth2.example.org altname.linphone.org sip.wildcard1.linphone.org altname.wildcard2.linphone.org \ No newline at end of file