From fd4827f907e7b24ae97e675f52204a321ec1ce57 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 10 Jan 2018 16:34:22 +0100 Subject: [PATCH] add new test for ambigous register. --- tester/flexisip_tester.c | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index 0f15d67a6..284f2e8f1 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -487,6 +487,64 @@ static void call_forking_with_push_notification_single(void){ bctbx_list_free(lcs); } +/* + * This test is a variant of push notification (single) where the client do send ambigous REGISTER with two contacts, + * one of them being the previous contact address with "expires=0" to tell the server to remove it. +**/ +static void call_forking_with_push_notification_double_contact(void){ + bctbx_list_t* lcs; + LinphoneCoreManager* marie = linphone_core_manager_new2( "marie_rc", FALSE); + LinphoneCoreManager* pauline = linphone_core_manager_new2( transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc",FALSE); + int dummy=0; + + + lp_config_set_int(linphone_core_get_config(marie->lc), "sip", "unregister_previous_contact", 1); + lp_config_set_int(linphone_core_get_config(pauline->lc), "sip", "unregister_previous_contact", 1); + linphone_core_set_user_agent(marie->lc,"Natted Linphone",NULL); + linphone_core_set_user_agent(pauline->lc,"Natted Linphone",NULL); + linphone_proxy_config_set_contact_uri_parameters( + linphone_core_get_default_proxy_config(marie->lc), + "app-id=org.linphonetester;pn-tok=aaabbb;pn-type=apple;pn-msg-str=33;pn-call-str=34;"); + + lcs=bctbx_list_append(NULL,pauline->lc); + lcs=bctbx_list_append(lcs,marie->lc); + + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneRegistrationOk,1,5000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneRegistrationOk,1,5000)); + + /*unfortunately marie gets unreachable due to crappy 3G operator or iOS bug...*/ + linphone_core_set_network_reachable(marie->lc,FALSE); + + linphone_core_invite_address(pauline->lc,marie->identity); + + /*After 5 seconds the server is expected to send a push notification to marie, this will wake up linphone, that will reconnect:*/ + wait_for_list(lcs,&dummy,1,6000); + linphone_core_set_network_reachable(marie->lc,TRUE); + + /*Marie shall receive the call immediately*/ + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallIncomingReceived,1,5000)); + /*pauline should hear ringback as well*/ + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallOutgoingRinging,1,1000)); + + /*marie accepts the call*/ + if (BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(marie->lc))) { + linphone_call_accept(linphone_core_get_current_call(marie->lc)); + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallConnected,1,5000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,1000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallConnected,1,1000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallStreamsRunning,1,1000)); + + liblinphone_tester_check_rtcp(pauline,marie); + + linphone_call_terminate(linphone_core_get_current_call(pauline->lc)); + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,5000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,5000)); + } + linphone_core_manager_destroy(pauline); + linphone_core_manager_destroy(marie); + bctbx_list_free(lcs); +} + static void call_forking_with_push_notification_multiple(void){ LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); @@ -1458,6 +1516,7 @@ test_t flexisip_tests[] = { TEST_NO_TAG("Call forking declined localy", call_forking_declined_localy), TEST_NO_TAG("Call forking with urgent reply", call_forking_with_urgent_reply), TEST_NO_TAG("Call forking with push notification (single)", call_forking_with_push_notification_single), + TEST_NO_TAG("Call forking with push notification with double contact", call_forking_with_push_notification_double_contact), TEST_NO_TAG("Call forking with push notification (multiple)", call_forking_with_push_notification_multiple), TEST_NO_TAG("Call forking not responded", call_forking_not_responded), TEST_NO_TAG("Early-media call forking", early_media_call_forking),