From 0ea0897390b9e1bc5c99f0f573158520ea2678a3 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 2 Oct 2015 14:28:38 +0200 Subject: [PATCH] add more test for presence --- tester/complex_sip_call_tester.c | 2 +- tester/flexisip_tester.c | 79 +++++++++++++++ tester/liblinphone_tester.h | 4 + tester/presence_tester.c | 2 +- tester/sipp/double_publish_with_error.xml | 111 ++++++++++++++++++++++ tester/sipp/simple_publish.xml | 71 ++++++++++++++ 6 files changed, 267 insertions(+), 2 deletions(-) create mode 100644 tester/sipp/double_publish_with_error.xml create mode 100644 tester/sipp/simple_publish.xml diff --git a/tester/complex_sip_call_tester.c b/tester/complex_sip_call_tester.c index 605b10cba..4d2d0da2b 100644 --- a/tester/complex_sip_call_tester.c +++ b/tester/complex_sip_call_tester.c @@ -48,7 +48,7 @@ void check_rtcp(LinphoneCall *call) { linphone_call_unref(call); } -static FILE *sip_start(const char *senario, const char* dest_username, LinphoneAddress* dest_addres) { +FILE *sip_start(const char *senario, const char* dest_username, LinphoneAddress* dest_addres) { #if HAVE_SIPP char *dest; char *command; diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index 2b60a0f80..4861fe036 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -884,6 +884,81 @@ static void dos_module_trigger(void) { linphone_core_manager_destroy(pauline); } +#define USE_PRESENCE_SERVER 1 + +#if USE_PRESENCE_SERVER + +static void test_subscribe_notify_with_sipp_publisher(void) { + char *scen; + FILE * sipp_out; + LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); + /*just to get an identity*/ + LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); + + LpConfig *pauline_lp = linphone_core_get_config(pauline->lc); + char* lf_identity=linphone_address_as_string_uri_only(marie->identity); + LinphoneFriend *lf = linphone_core_create_friend_with_address(pauline->lc,lf_identity); + ms_free(lf_identity); + + lp_config_set_int(pauline_lp,"sip","subscribe_expires",5); + + linphone_core_add_friend(pauline->lc,lf); + + /*wait for subscribe acknowledgment*/ + wait_for_until(pauline->lc,pauline->lc,&pauline->stat.number_of_NotifyReceived,1,2000); + BC_ASSERT_EQUAL(LinphoneStatusOffline,linphone_friend_get_status(lf), int, "%d"); + + scen = bc_tester_res("sipp/simple_publish.xml"); + + sipp_out = sip_start(scen, linphone_address_get_username(marie->identity), marie->identity); + + if (TRUE/*sipp_out*/) { + /*wait for marie status*/ + wait_for_until(pauline->lc,pauline->lc,&pauline->stat.number_of_NotifyReceived,2,3000); + BC_ASSERT_EQUAL(LinphoneStatusOnline,linphone_friend_get_status(lf), int, "%d"); + pclose(sipp_out); + } + + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} +static void test_subscribe_notify_with_sipp_publisher_double_publish(void) { + char *scen; + FILE * sipp_out; + LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); + /*just to get an identity*/ + LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); + + LpConfig *pauline_lp = linphone_core_get_config(pauline->lc); + char* lf_identity=linphone_address_as_string_uri_only(marie->identity); + LinphoneFriend *lf = linphone_core_create_friend_with_address(pauline->lc,lf_identity); + ms_free(lf_identity); + lp_config_set_int(pauline_lp,"sip","subscribe_expires",5); + + linphone_core_add_friend(pauline->lc,lf); + + /*wait for subscribe acknowledgment*/ + wait_for_until(pauline->lc,pauline->lc,&pauline->stat.number_of_NotifyReceived,1,2000); + BC_ASSERT_EQUAL(LinphoneStatusOffline,linphone_friend_get_status(lf), int, "%d"); + + scen = bc_tester_res("sipp/double_publish_with_error.xml"); + + sipp_out = sip_start(scen, linphone_address_get_username(marie->identity), marie->identity); + + if (TRUE/*sipp_out*/) { + /*wait for marie status*/ + wait_for_until(pauline->lc,pauline->lc,&pauline->stat.number_of_NotifyReceived,2,3000); + BC_ASSERT_EQUAL(LinphoneStatusOnline,linphone_friend_get_status(lf), int, "%d"); + pclose(sipp_out); + BC_ASSERT_EQUAL(pauline->stat.number_of_NotifyReceived,2,int, "%d"); + } + + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +#endif + test_t flexisip_tests[] = { { "Subscribe forking", subscribe_forking }, { "Message forking", message_forking }, @@ -901,6 +976,10 @@ test_t flexisip_tests[] = { { "Call with sips", call_with_sips }, { "Call with sips not achievable", call_with_sips_not_achievable }, { "Call with ipv6", call_with_ipv6 }, +#if USE_PRESENCE_SERVER + { "Subscribe Notify with sipp publisher", test_subscribe_notify_with_sipp_publisher }, + { "Subscribe Notify with sipp double publish", test_subscribe_notify_with_sipp_publisher_double_publish }, +#endif { "File transfer message rcs to external body client", file_transfer_message_rcs_to_external_body_client }, { "File transfer message external body to rcs client", file_transfer_message_external_body_to_rcs_client }, { "File transfer message external body to external body client", file_transfer_message_external_body_to_external_body_client }, diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index 21b7d305f..7b55f3c3f 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -352,6 +352,10 @@ bool_t check_ice(LinphoneCoreManager* caller, LinphoneCoreManager* callee, Linph extern const char *liblinphone_tester_mire_id; +FILE *sip_start(const char *senario, const char* dest_username, LinphoneAddress* dest_addres); + + + #ifdef __cplusplus }; diff --git a/tester/presence_tester.c b/tester/presence_tester.c index a06ac99d7..3b9bc5527 100644 --- a/tester/presence_tester.c +++ b/tester/presence_tester.c @@ -429,7 +429,7 @@ static void subscribe_presence_expired(void){ } -#define USE_PRESENCE_SERVER 0 +#define USE_PRESENCE_SERVER 1 #if USE_PRESENCE_SERVER static void test_subscribe_notify_publish(void) { diff --git a/tester/sipp/double_publish_with_error.xml b/tester/sipp/double_publish_with_error.xml new file mode 100644 index 000000000..7527aa78a --- /dev/null +++ b/tester/sipp/double_publish_with_error.xml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + ;tag=[pid]SIPpTag00[call_number] + To: sipp + Call-ID: [call_id] + CSeq: 1 PUBLISH + Max-Forwards: 70 + Expire: 60 + Event: presence + Content-Type: application/pidf+xml + Content-Length: [len] + + + + + + open + + sip:[service]@[local_ip]:[local_port] + 2015-09-28T15:49:00Z + + + ]]> + + + + + + + + + + + + + + ;tag=[pid]SIPpTag00[call_number] + To: sipp + Call-ID: [call_id]-2 + CSeq: 1 PUBLISH + Max-Forwards: 70 + Expire: 60 + Event: presence + Content-Type: application/pidf+xml + Content-Length: [len] + + + + + + open + + sip:[service]@[local_ip]:[local_port] + 2015-09-28T15:49:00Z + + + ]]> + + + + + + + + + + + + + + + + + + + + + diff --git a/tester/sipp/simple_publish.xml b/tester/sipp/simple_publish.xml new file mode 100644 index 000000000..83b04bedd --- /dev/null +++ b/tester/sipp/simple_publish.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + ;tag=[pid]SIPpTag00[call_number] + To: sipp + Call-ID: [call_id] + CSeq: 1 PUBLISH + Max-Forwards: 70 + Expire: 60 + Event: presence + Content-Type: application/pidf+xml + Content-Length: [len] + + + + + + open + + sip:[service]@[local_ip]:[local_port] + 2015-09-28T15:49:00Z + + + ]]> + + + + + + + + + + + + + + + + + + + +