Commit af6db9e6 authored by jehan's avatar jehan
Browse files

add offers/answers test for DTLS

parent 5955681c
......@@ -275,17 +275,23 @@ bool_t call_with_params2(LinphoneCoreManager* caller_mgr
wait_for(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_callee.number_of_LinphoneCallStreamsRunning+1);
if (linphone_core_get_media_encryption(caller_mgr->lc) != LinphoneMediaEncryptionNone
&& linphone_core_get_media_encryption(callee_mgr->lc) != LinphoneMediaEncryptionNone) {
|| linphone_core_get_media_encryption(callee_mgr->lc) != LinphoneMediaEncryptionNone) {
/*wait for encryption to be on, in case of zrtp or dtls, it can take a few seconds*/
if ((linphone_core_get_media_encryption(caller_mgr->lc) == LinphoneMediaEncryptionZRTP) || (linphone_core_get_media_encryption(caller_mgr->lc) == LinphoneMediaEncryptionDTLS))
if ( (linphone_core_get_media_encryption(caller_mgr->lc) == LinphoneMediaEncryptionZRTP)
|| (linphone_core_get_media_encryption(caller_mgr->lc) == LinphoneMediaEncryptionDTLS))
wait_for(callee_mgr->lc,caller_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallEncryptedOn,initial_caller.number_of_LinphoneCallEncryptedOn+1);
if ((linphone_core_get_media_encryption(callee_mgr->lc) == LinphoneMediaEncryptionZRTP) || (linphone_core_get_media_encryption(callee_mgr->lc) == LinphoneMediaEncryptionDTLS))
if ((linphone_core_get_media_encryption(callee_mgr->lc) == LinphoneMediaEncryptionZRTP)
|| (linphone_core_get_media_encryption(callee_mgr->lc) == LinphoneMediaEncryptionDTLS)
|| (linphone_core_get_media_encryption(caller_mgr->lc) == LinphoneMediaEncryptionDTLS) /*also take care of caller policy*/ )
wait_for(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallEncryptedOn,initial_callee.number_of_LinphoneCallEncryptedOn+1);
{
const LinphoneCallParams* call_param = linphone_call_get_current_params(linphone_core_get_current_call(callee_mgr->lc));
CU_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(caller_mgr->lc));
call_param = linphone_call_get_current_params(linphone_core_get_current_call(caller_mgr->lc));
CU_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(callee_mgr->lc));
if (linphone_call_params_get_media_encryption(call_param) != LinphoneMediaEncryptionDTLS) {
/*for DTLS this test is not relevant */
CU_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(callee_mgr->lc));
}
}
}
return result;
......
......@@ -157,7 +157,7 @@ static void call_failed_because_of_codecs(void) {
}
static void profile_call(bool_t avpf1, bool_t srtp1, bool_t avpf2, bool_t srtp2, const char *expected_profile) {
static void profile_call(bool_t avpf1, LinphoneMediaEncryption srtp1, bool_t avpf2, LinphoneMediaEncryption srtp2, const char *expected_profile) {
LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc");
LinphoneProxyConfig *lpc;
......@@ -173,15 +173,19 @@ static void profile_call(bool_t avpf1, bool_t srtp1, bool_t avpf2, bool_t srtp2,
linphone_proxy_config_enable_avpf(lpc, TRUE);
linphone_proxy_config_set_avpf_rr_interval(lpc, 3);
}
if (srtp1) {
if (linphone_core_media_encryption_supported(marie->lc, LinphoneMediaEncryptionSRTP)) {
linphone_core_set_media_encryption(marie->lc, LinphoneMediaEncryptionSRTP);
}
if (linphone_core_media_encryption_supported(marie->lc, srtp1)) {
linphone_core_set_media_encryption(marie->lc, srtp1);
} else {
ms_message("Unsupported [%s] encryption type, cannot test",linphone_media_encryption_to_string(srtp1));
goto end;
}
if (srtp2) {
if (linphone_core_media_encryption_supported(pauline->lc, LinphoneMediaEncryptionSRTP)) {
linphone_core_set_media_encryption(pauline->lc, LinphoneMediaEncryptionSRTP);
}
if (linphone_core_media_encryption_supported(pauline->lc, srtp2)) {
linphone_core_set_media_encryption(pauline->lc, srtp2);
}else {
ms_message("Unsupported [%s] encryption type, cannot test",linphone_media_encryption_to_string(srtp2));
goto end;
}
CU_ASSERT_TRUE(call(marie, pauline));
......@@ -197,73 +201,85 @@ static void profile_call(bool_t avpf1, bool_t srtp1, bool_t avpf2, bool_t srtp2,
CU_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallEnd, 1));
CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallConnected, 1);
CU_ASSERT_EQUAL(pauline->stat.number_of_LinphoneCallConnected, 1);
end:
linphone_core_manager_destroy(pauline);
linphone_core_manager_destroy(marie);
}
static void avp_to_avp_call(void) {
profile_call(FALSE, FALSE, FALSE, FALSE, "RTP/AVP");
profile_call(FALSE, LinphoneMediaEncryptionNone, FALSE, LinphoneMediaEncryptionNone, "RTP/AVP");
}
static void avp_to_avpf_call(void) {
profile_call(FALSE, FALSE, TRUE, FALSE, "RTP/AVP");
profile_call(FALSE, LinphoneMediaEncryptionNone, TRUE, LinphoneMediaEncryptionNone, "RTP/AVP");
}
static void avp_to_savp_call(void) {
profile_call(FALSE, FALSE, FALSE, TRUE, "RTP/AVP");
profile_call(FALSE, LinphoneMediaEncryptionNone, FALSE, LinphoneMediaEncryptionSRTP, "RTP/AVP");
}
static void avp_to_savpf_call(void) {
profile_call(FALSE, FALSE, TRUE, TRUE, "RTP/AVP");
profile_call(FALSE, LinphoneMediaEncryptionNone, TRUE, LinphoneMediaEncryptionSRTP, "RTP/AVP");
}
static void avpf_to_avp_call(void) {
profile_call(TRUE, FALSE, FALSE, FALSE, "RTP/AVPF");
profile_call(TRUE, LinphoneMediaEncryptionNone, FALSE, LinphoneMediaEncryptionNone, "RTP/AVPF");
}
static void avpf_to_avpf_call(void) {
profile_call(TRUE, FALSE, TRUE, FALSE, "RTP/AVPF");
profile_call(TRUE, LinphoneMediaEncryptionNone, TRUE, LinphoneMediaEncryptionNone, "RTP/AVPF");
}
static void avpf_to_savp_call(void) {
profile_call(TRUE, FALSE, FALSE, TRUE, "RTP/AVPF");
profile_call(TRUE, LinphoneMediaEncryptionNone, FALSE, LinphoneMediaEncryptionSRTP, "RTP/AVPF");
}
static void avpf_to_savpf_call(void) {
profile_call(TRUE, FALSE, TRUE, TRUE, "RTP/AVPF");
profile_call(TRUE, LinphoneMediaEncryptionNone, TRUE, LinphoneMediaEncryptionSRTP, "RTP/AVPF");
}
static void savp_to_avp_call(void) {
profile_call(FALSE, TRUE, FALSE, FALSE, "RTP/SAVP");
profile_call(FALSE, LinphoneMediaEncryptionSRTP, FALSE, LinphoneMediaEncryptionNone, "RTP/SAVP");
}
static void savp_to_avpf_call(void) {
profile_call(FALSE, TRUE, TRUE, FALSE, "RTP/SAVP");
profile_call(FALSE, LinphoneMediaEncryptionSRTP, TRUE, LinphoneMediaEncryptionNone, "RTP/SAVP");
}
static void savp_to_savp_call(void) {
profile_call(FALSE, TRUE, FALSE, TRUE, "RTP/SAVP");
profile_call(FALSE, LinphoneMediaEncryptionSRTP, FALSE, LinphoneMediaEncryptionSRTP, "RTP/SAVP");
}
static void savp_to_savpf_call(void) {
profile_call(FALSE, TRUE, TRUE, TRUE, "RTP/SAVP");
profile_call(FALSE, LinphoneMediaEncryptionSRTP, TRUE, LinphoneMediaEncryptionSRTP, "RTP/SAVP");
}
static void savpf_to_avp_call(void) {
profile_call(TRUE, TRUE, FALSE, FALSE, "RTP/SAVPF");
profile_call(TRUE, LinphoneMediaEncryptionSRTP, FALSE, LinphoneMediaEncryptionNone, "RTP/SAVPF");
}
static void savpf_to_avpf_call(void) {
profile_call(TRUE, TRUE, TRUE, FALSE, "RTP/SAVPF");
profile_call(TRUE, LinphoneMediaEncryptionSRTP, TRUE, LinphoneMediaEncryptionNone, "RTP/SAVPF");
}
static void savpf_to_savp_call(void) {
profile_call(TRUE, TRUE, FALSE, TRUE, "RTP/SAVPF");
profile_call(TRUE, LinphoneMediaEncryptionSRTP, FALSE, LinphoneMediaEncryptionSRTP, "RTP/SAVPF");
}
static void savpf_to_savpf_call(void) {
profile_call(TRUE, TRUE, TRUE, TRUE, "RTP/SAVPF");
profile_call(TRUE, LinphoneMediaEncryptionSRTP, TRUE, LinphoneMediaEncryptionSRTP, "RTP/SAVPF");
}
static void savpf_dtls_to_savpf_dtls_call(void) {
profile_call(TRUE, LinphoneMediaEncryptionDTLS, TRUE, LinphoneMediaEncryptionDTLS, "UDP/TLS/RTP/SAVPF");
}
static void savpf_dtls_to_savpf_call(void) {
profile_call(TRUE, LinphoneMediaEncryptionDTLS, TRUE, LinphoneMediaEncryptionSRTP, "UDP/TLS/RTP/SAVPF");
}
static void savpf_dtls_to_avpf_call(void) {
profile_call(TRUE, LinphoneMediaEncryptionDTLS, TRUE, LinphoneMediaEncryptionNone, "UDP/TLS/RTP/SAVPF");
}
static test_t offeranswer_tests[] = {
......@@ -286,6 +302,9 @@ static test_t offeranswer_tests[] = {
{ "SAVPF to AVPF call", savpf_to_avpf_call },
{ "SAVPF to SAVP call", savpf_to_savp_call },
{ "SAVPF to SAVPF call", savpf_to_savpf_call },
{ "SAVPF/DTLS to SAVPF/DTLS call", savpf_dtls_to_savpf_dtls_call},
{ "SAVPF/DTLS to SAVPF call", savpf_dtls_to_savpf_call},
{ "SAVPF/DTLS to AVPF call", savpf_dtls_to_avpf_call},
};
test_suite_t offeranswer_test_suite = {
......
......@@ -583,6 +583,8 @@ int liblinphone_tester_run_tests(const char *suite_name, const char *test_name)
/*special case for suite Call which is now splitted into simple and multi*/
CU_run_suite(CU_get_suite("Single call"));
CU_run_suite(CU_get_suite("Multi call"));
CU_run_suite(CU_get_suite("DTMF"));
CU_run_suite(CU_get_suite("Transport"));
} else if (suite_name){
CU_pSuite suite;
suite=CU_get_suite(suite_name);
......
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