From 5c7330b17f63e8d3e6f576a54681f175248a8653 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 6 Feb 2014 15:01:34 +0100 Subject: [PATCH] avoid 100 trying to reset op auth counters --- .cproject | 2 +- coreapi/bellesip_sal/sal_impl.c | 15 ++++++------- oRTP | 2 +- tester/call_tester.c | 37 ++++++++++++++++++++++----------- 4 files changed, 35 insertions(+), 21 deletions(-) diff --git a/.cproject b/.cproject index 8a879f8a7..e109f8b5b 100644 --- a/.cproject +++ b/.cproject @@ -22,7 +22,7 @@ - + diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index 1c2df0879..29f65c91b 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -146,12 +146,13 @@ void sal_process_authentication(SalOp *op) { if (is_within_dialog) { belle_sip_object_unref(new_request); } - if (op->auth_info) sal_auth_info_delete(op->auth_info); - if (auth_list){ - auth_event=(belle_sip_auth_event_t*)(auth_list->data); - op->auth_info=sal_auth_info_create(auth_event); - belle_sip_list_free_with_data(auth_list,(void (*)(void*))belle_sip_auth_event_destroy); - } + } + /*always store auth info, for case of wrong credential*/ + if (op->auth_info) sal_auth_info_delete(op->auth_info); + if (auth_list){ + auth_event=(belle_sip_auth_event_t*)(auth_list->data); + op->auth_info=sal_auth_info_create(auth_event); + belle_sip_list_free_with_data(auth_list,(void (*)(void*))belle_sip_auth_event_destroy); } } @@ -345,7 +346,7 @@ static void process_response_event(void *user_ctx, const belle_sip_response_even if (op->auth_info) op->base.root->callbacks.auth_failure(op,op->auth_info); break; } - if (response_code !=401 && response_code !=407 && response_code !=403) { + if (response_code >= 180 && response_code !=401 && response_code !=407 && response_code !=403) { /*not an auth request*/ op->auth_requests=0; } diff --git a/oRTP b/oRTP index 38eccb648..b03acc0a3 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 38eccb648fa80274082fb1aa299edcd37004f1cf +Subproject commit b03acc0a37ee64a12e9854e2ea4b781a9412240d diff --git a/tester/call_tester.c b/tester/call_tester.c index c47add6c2..34279e8d4 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -1410,41 +1410,53 @@ static void call_established_with_rejected_reinvite_with_error(void) { linphone_core_manager_destroy(pauline); } -static void call_rejected_because_wrong_credentials_with_params(const char* user_agent) { +static void call_rejected_because_wrong_credentials_with_params(const char* user_agent,bool_t enable_auth_req_cb) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneAuthInfo* good_auth_info=linphone_auth_info_clone((LinphoneAuthInfo*)(linphone_core_get_auth_info_list(marie->lc)->data)); LinphoneAuthInfo* wrong_auth_info=linphone_auth_info_clone(good_auth_info); + bool_t result=FALSE; + linphone_auth_info_set_passwd(wrong_auth_info,"passecretdutout"); + linphone_core_clear_all_auth_info(marie->lc); if (user_agent) { linphone_core_set_user_agent(marie->lc,user_agent,NULL); } - linphone_core_clear_all_auth_info(marie->lc); + if (!enable_auth_req_cb) { + marie->lc->vtable.auth_info_requested=NULL; + linphone_core_add_auth_info(marie->lc,wrong_auth_info); + } CU_ASSERT_PTR_NOT_NULL(linphone_core_invite_address(marie->lc,marie->identity)); - CU_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_auth_info_requested,1)); - - linphone_auth_info_set_passwd(wrong_auth_info,"passecretdutout"); - - /*automatically re-inititae the call*/ - linphone_core_add_auth_info(marie->lc,wrong_auth_info); + result=wait_for(marie->lc,marie->lc,&marie->stat.number_of_auth_info_requested,1); + if (enable_auth_req_cb) { + CU_ASSERT_TRUE(result); + /*automatically re-inititae the call*/ + linphone_core_add_auth_info(marie->lc,wrong_auth_info); + } CU_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphoneCallError,1)); - CU_ASSERT_EQUAL(marie->stat.number_of_auth_info_requested,2); - + if (enable_auth_req_cb) { + CU_ASSERT_EQUAL(marie->stat.number_of_auth_info_requested,2); + } /*to make sure unregister will work*/ linphone_core_clear_all_auth_info(marie->lc); linphone_core_add_auth_info(marie->lc,good_auth_info); linphone_core_manager_destroy(marie); } + static void call_rejected_because_wrong_credentials() { - call_rejected_because_wrong_credentials_with_params(NULL); + call_rejected_because_wrong_credentials_with_params(NULL,TRUE); } static void call_rejected_without_403_because_wrong_credentials() { - call_rejected_because_wrong_credentials_with_params("tester-no-403"); + call_rejected_because_wrong_credentials_with_params("tester-no-403",TRUE); +} + +static void call_rejected_without_403_because_wrong_credentials_no_auth_req_cb() { + call_rejected_because_wrong_credentials_with_params("tester-no-403",FALSE); } #ifdef VIDEO_ENABLED @@ -1480,6 +1492,7 @@ test_t call_tests[] = { { "Call with privacy", call_with_privacy }, { "Call rejected because of wrong credential", call_rejected_because_wrong_credentials}, { "Call rejected without 403 because of wrong credential", call_rejected_without_403_because_wrong_credentials}, + { "Call rejected without 403 because of wrong credential and no auth req cb", call_rejected_without_403_because_wrong_credentials_no_auth_req_cb}, { "Simple conference", simple_conference }, { "Simple call transfer", simple_call_transfer }, { "Unattended call transfer", unattended_call_transfer },