Commit fd42f40e authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Added new account creator xmlrpc method + added support of returned hashmap in xmlrpc

parent e5cc2f6f
......@@ -314,6 +314,15 @@ LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_update_accoun
void linphone_account_creator_cbs_set_update_account(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) {
cbs->update_account_response_cb = cb;
}
LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_login_linphone_account(const LinphoneAccountCreatorCbs *cbs) {
return cbs->login_linphone_account_response_cb;
}
void linphone_account_creator_cbs_set_login_linphone_account(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb) {
cbs->login_linphone_account_response_cb = cb;
}
/************************** End Account Creator Cbs **************************/
/************************** Start Account Creator data **************************/
......@@ -928,6 +937,75 @@ LinphoneAccountCreatorStatus linphone_account_creator_delete_account_linphone(Li
/****************** END OF CREATE ACCOUNT SECTION *****************************/
/****************** START OF VALIDATE ACCOUNT SECTION *************************/
static void _login_account_confirmation_key_cb_custom(LinphoneXmlRpcRequest *request) {
LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request);
LinphoneAccountCreatorStatus status = LinphoneAccountCreatorStatusRequestFailed;
if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusFailed) {
const char* resp = linphone_xml_rpc_request_get_string_response(request);
if (strcmp(resp, "ERROR_ACCOUNT_DOESNT_EXIST") == 0) {
status = LinphoneAccountCreatorStatusAccountNotExist;
} else if (strcmp(resp, "ERROR_KEY_DOESNT_MATCH") == 0) {
status = LinphoneAccountCreatorStatusWrongActivationCode;
} else if (strcmp(resp, "ERROR_ALGO_NOT_SUPPORTED") == 0) {
status = LinphoneAccountCreatorStatusAlgoNotSupported;
} else {
status = LinphoneAccountCreatorStatusUnexpectedError;
}
} else if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) {
status = LinphoneAccountCreatorStatusRequestOk;
const bctbx_map_t *resp = linphone_xml_rpc_request_get_string_struct_response(request);
const auto &it = bctbx_map_cchar_find_key(resp, "password");
if (!bctbx_iterator_equals(it, bctbx_map_cchar_end(resp))) {
const char *ha1 = (const char *)bctbx_pair_cchar_get_second(bctbx_iterator_cchar_get_pair(it));
set_string(&creator->ha1, ha1, FALSE);
}
const auto &it2 = bctbx_map_cchar_find_key(resp, "algorithm");
if (!bctbx_iterator_equals(it2, bctbx_map_cchar_end(resp))) {
const char *algo = (const char *)bctbx_pair_cchar_get_second(bctbx_iterator_cchar_get_pair(it2));
set_string(&creator->algorithm, algo, FALSE);
}
}
const char *content = linphone_xml_rpc_request_get_content(request);
if (creator->cbs->login_linphone_account_response_cb != NULL) {
creator->cbs->login_linphone_account_response_cb(creator, status, content);
}
NOTIFY_IF_EXIST(Status, login_linphone_account, creator, status, content)
}
LinphoneAccountCreatorStatus linphone_account_creator_login_linphone_account(LinphoneAccountCreator *creator) {
LinphoneXmlRpcRequest *request = NULL;
if ((!creator->username && !creator->phone_number) || !creator->activation_code) {
if (creator->cbs->login_linphone_account_response_cb != NULL) {
creator->cbs->login_linphone_account_response_cb(creator, LinphoneAccountCreatorStatusMissingArguments, "Missing required parameters");
}
NOTIFY_IF_EXIST(Status, login_linphone_account, creator, LinphoneAccountCreatorStatusMissingArguments, "Missing required parameters")
return LinphoneAccountCreatorStatusMissingArguments;
}
if (creator->xmlrpc_session) {
ms_debug("Account creator: recover_account_from_confirmation_key (username=%s, activation code=%s, domain=%s, algo=%s)",
creator->username ? creator->username : creator->phone_number,
creator->activation_code,
_get_domain(creator),
creator->algorithm);
request = linphone_xml_rpc_request_new(LinphoneXmlRpcArgStringStruct, "recover_account_from_confirmation_key");
linphone_xml_rpc_request_add_string_arg(request, creator->username ? creator->username : creator->phone_number);
linphone_xml_rpc_request_add_string_arg(request, creator->activation_code);
linphone_xml_rpc_request_add_string_arg(request, _get_domain(creator));
linphone_xml_rpc_request_add_string_arg(request, creator->algorithm);
linphone_xml_rpc_request_set_user_data(request, creator);
linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _login_account_confirmation_key_cb_custom);
linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
linphone_xml_rpc_request_unref(request);
return LinphoneAccountCreatorStatusRequestOk;
}
return LinphoneAccountCreatorStatusRequestFailed;
}
static void _activate_account_cb_custom(LinphoneXmlRpcRequest *request) {
LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request);
LinphoneAccountCreatorStatus status = LinphoneAccountCreatorStatusRequestFailed;
......
......@@ -70,6 +70,8 @@ struct _LinphoneAccountCreatorCbs {
LinphoneAccountCreatorCbsStatusCb recover_account_response_cb; /**< Response of recover_account request */
LinphoneAccountCreatorCbsStatusCb update_account_response_cb; /**< Response of update_account request */
LinphoneAccountCreatorCbsStatusCb login_linphone_account_response_cb; /** < Response of login_linphone_account request */
};
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneAccountCreatorCbs);
......@@ -203,6 +205,13 @@ LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_is_account
**/
LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_update_password_linphone(LinphoneAccountCreator *creator);
/**
* Send an XML-RPC request to get the password & algorithm of an account using the confirmation key
* @param[in] creator LinphoneAccountCreator object
* @return LinphoneAccountCreatorStatusRequestOk if everything is OK, or a specific error otherwise.
**/
LINPHONE_PUBLIC LinphoneAccountCreatorStatus linphone_account_creator_login_linphone_account(LinphoneAccountCreator *creator);
#ifdef __cplusplus
}
#endif
......
......@@ -514,6 +514,7 @@ struct _LinphoneXmlRpcArg {
union {
int i;
char *s;
bctbx_map_t *m;
} data;
};
......
......@@ -126,6 +126,9 @@ static void format_request(LinphoneXmlRpcRequest *request) {
switch (arg->type) {
case LinphoneXmlRpcArgNone:
break;
case LinphoneXmlRpcArgStringStruct:
ms_error("String struct not yet supported as argument");
break;
case LinphoneXmlRpcArgInt:
memset(si, 0, sizeof(si));
snprintf(si, sizeof(si), "%i", arg->data.i);
......@@ -240,6 +243,40 @@ static void parse_valid_xml_rpc_response(LinphoneXmlRpcRequest *request, const c
request->status = LinphoneXmlRpcStatusOk;
}
break;
case LinphoneXmlRpcArgStringStruct:
{
response_str = linphone_get_xml_text_content(xml_ctx, "/methodResponse/params/param/value/string");
if (response_str != NULL) {
request->response.data.s = belle_sip_strdup(response_str);
} else {
xmlXPathObjectPtr responses = linphone_get_xml_xpath_object_for_node_list(xml_ctx, "/methodResponse/params/param/value/struct/member");
if (responses != NULL && responses->nodesetval != NULL) {
request->response.data.m = bctbx_mmap_cchar_new();
request->status = LinphoneXmlRpcStatusOk;
xmlNodeSetPtr responses_nodes = responses->nodesetval;
if (responses_nodes->nodeNr >= 1) {
int i;
for (i = 0; i < responses_nodes->nodeNr; i++) {
xmlNodePtr response_node = responses_nodes->nodeTab[i];
xml_ctx->xpath_ctx->node = response_node;
{
char *name = linphone_get_xml_text_content(xml_ctx, "name");
char *value = linphone_get_xml_text_content(xml_ctx, "value/string");
const bctbx_pair_cchar_t *pair = bctbx_pair_cchar_new(bctbx_strdup(name), (void *)bctbx_strdup(value));
bctbx_map_cchar_insert(request->response.data.m, (const bctbx_pair_t *)pair);
linphone_free_xml_text_content(name);
linphone_free_xml_text_content(value);
}
}
}
xmlXPathFreeObject(responses);
}
}
break;
}
default:
break;
}
......@@ -309,6 +346,12 @@ static void _linphone_xml_rpc_request_destroy(LinphoneXmlRpcRequest *request) {
belle_sip_list_free_with_data(request->arg_list, (void (*)(void*))free_arg);
if ((request->response.type == LinphoneXmlRpcArgString) && (request->response.data.s != NULL)) {
belle_sip_free(request->response.data.s);
} else if (request->response.type == LinphoneXmlRpcArgStringStruct) {
if (request->status == LinphoneXmlRpcStatusOk && request->response.data.m != NULL) {
bctbx_mmap_cchar_delete_with_data(request->response.data.m, bctbx_free);
} else if (request->status == LinphoneXmlRpcStatusFailed && request->response.data.s != NULL) {
belle_sip_free(request->response.data.s);
}
}
if (request->content) belle_sip_free(request->content);
belle_sip_free(request->method);
......@@ -420,6 +463,10 @@ const char * linphone_xml_rpc_request_get_raw_response(const LinphoneXmlRpcReque
return request->raw_response;
}
const bctbx_map_t* linphone_xml_rpc_request_get_string_struct_response(const LinphoneXmlRpcRequest *request) {
return request->response.data.m;
}
LinphoneXmlRpcSession * linphone_xml_rpc_session_new(LinphoneCore *core, const char *url) {
LinphoneXmlRpcSession *session = belle_sip_object_new(LinphoneXmlRpcSession);
session->core = core;
......
......@@ -243,6 +243,13 @@ LINPHONE_PUBLIC const char * linphone_account_creator_get_activation_code(const
**/
LINPHONE_PUBLIC LinphoneAccountCreatorLanguageStatus linphone_account_creator_set_language(LinphoneAccountCreator *creator, const char *lang);
/**
* Get the language use in email of SMS.
* @param[in] creator #LinphoneAccountCreator object
* @return The language of the #LinphoneAccountCreator
**/
LINPHONE_PUBLIC const char * linphone_account_creator_get_language(const LinphoneAccountCreator *creator);
/**
* Set the supported algorithm.
* @param[in] creator LinphoneAccountCreator object
......@@ -252,11 +259,11 @@ LINPHONE_PUBLIC LinphoneAccountCreatorLanguageStatus linphone_account_creator_se
LINPHONE_PUBLIC LinphoneAccountCreatorAlgoStatus linphone_account_creator_set_algorithm(LinphoneAccountCreator *creator, const char *algorithm);
/**
* Get the language use in email of SMS.
* Get the algorithm configured in the account creator.
* @param[in] creator #LinphoneAccountCreator object
* @return The language of the #LinphoneAccountCreator
* @return The algorithm of the #LinphoneAccountCreator
**/
LINPHONE_PUBLIC const char * linphone_account_creator_get_language(const LinphoneAccountCreator *creator);
LINPHONE_PUBLIC const char * linphone_account_creator_get_algorithm(const LinphoneAccountCreator *creator);
/**
* Set the display name.
......@@ -556,6 +563,20 @@ LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_g
**/
LINPHONE_PUBLIC void linphone_account_creator_cbs_set_update_account(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb);
/**
* Get the login linphone account request.
* @param[in] cbs #LinphoneAccountCreatorCbs object.
* @return The current login linphone account request.
**/
LINPHONE_PUBLIC LinphoneAccountCreatorCbsStatusCb linphone_account_creator_cbs_get_login_linphone_account(const LinphoneAccountCreatorCbs *cbs);
/**
* Assign a user pointer to a #LinphoneAccountCreatorCbs object.
* @param[in] cbs #LinphoneAccountCreatorCbs object.
* @param[in] cb The login linphone account request to be used.
**/
LINPHONE_PUBLIC void linphone_account_creator_cbs_set_login_linphone_account(LinphoneAccountCreatorCbs *cbs, LinphoneAccountCreatorCbsStatusCb cb);
/************************** End Account Creator Cbs **************************/
/**
......
......@@ -184,6 +184,7 @@ typedef enum _LinphoneAccountCreatorStatus {
LinphoneAccountCreatorStatusWrongActivationCode, /**< Error key doesn't match */
LinphoneAccountCreatorStatusPhoneNumberOverused, /**< Error too many SMS sent */
LinphoneAccountCreatorStatusAlgoNotSupported, /** < Error algo isn't MD5 or SHA-256 */
LinphoneAccountCreatorStatusUnexpectedError, /** < Generic error */
} LinphoneAccountCreatorStatus;
/**
......@@ -1163,7 +1164,8 @@ typedef enum _LinphoneWaitingState {
typedef enum _LinphoneXmlRpcArgType {
LinphoneXmlRpcArgNone,
LinphoneXmlRpcArgInt,
LinphoneXmlRpcArgString
LinphoneXmlRpcArgString,
LinphoneXmlRpcArgStringStruct
} LinphoneXmlRpcArgType;
/**
......
......@@ -22,6 +22,7 @@
#include "linphone/types.h"
#include <bctoolbox/map.h>
#ifdef __cplusplus
......@@ -147,6 +148,14 @@ LINPHONE_PUBLIC const char * linphone_xml_rpc_request_get_string_response(const
**/
LINPHONE_PUBLIC const char * linphone_xml_rpc_request_get_raw_response(const LinphoneXmlRpcRequest *request);
/**
* Get the response to an XML-RPC request sent with linphone_xml_rpc_session_send_request() and returning a struct response.
* @param[in] request LinphoneXmlRpcRequest object.
* @return The struct response to the XML-RPC request.
* @donotwrap
**/
const bctbx_map_t* linphone_xml_rpc_request_get_string_struct_response(const LinphoneXmlRpcRequest *request);
/**
* Create a new #LinphoneXmlRpcSession object.
* @param[in] core The #LinphoneCore object used to send the XML-RPC requests.
......
......@@ -73,7 +73,7 @@ static void local_username_too_long(void) {
LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, "");
BC_ASSERT_EQUAL(
linphone_account_creator_set_username(creator, "usernametoolongforyou"),
linphone_account_creator_set_username(creator, "usernametoolongforyoutoobadmorelucknexttime"),
LinphoneAccountCreatorUsernameStatusTooLong,
LinphoneAccountCreatorUsernameStatus,
"%i");
......@@ -2131,6 +2131,229 @@ static void server_update_account_password_arg_new_password_missing(void) {
linphone_core_manager_destroy(marie);
}
static void login_linphone_account_creator_cb(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char* resp) {
LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
LinphoneAccountCreatorStatus expected_status = (LinphoneAccountCreatorStatus)linphone_account_creator_service_get_user_data(
linphone_account_creator_get_service(creator));
BC_ASSERT_EQUAL(
status,
expected_status,
LinphoneAccountCreatorStatus,
"%i");
if (expected_status == LinphoneAccountCreatorStatusRequestOk) {
const char * expected_password = (const char *)belle_sip_object_data_get((belle_sip_object_t *)creator, "expected_ha1");
const char * expected_algorithm = (const char *)belle_sip_object_data_get((belle_sip_object_t *)creator, "expected_algorithm");
const char * response_password = linphone_account_creator_get_ha1(creator);
const char * response_algorithm = linphone_account_creator_get_algorithm(creator);
BC_ASSERT_STRING_EQUAL(response_password, expected_password);
BC_ASSERT_STRING_EQUAL(response_algorithm, expected_algorithm);
}
account_creator_set_cb_done(cbs);
}
static void server_recover_phone_account_doesnt_exists(void) {
LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();
linphone_account_creator_set_username(creator, "user_inexistant");
linphone_account_creator_set_activation_code(creator, "1666");
linphone_account_creator_set_algorithm(creator, "SHA-256");
linphone_account_creator_cbs_set_user_data(cbs, stats);
linphone_account_creator_cbs_set_login_linphone_account(cbs, login_linphone_account_creator_cb);
linphone_account_creator_service_set_user_data(
linphone_account_creator_get_service(creator),
(void*)LinphoneAccountCreatorStatusAccountNotExist);
BC_ASSERT_EQUAL(
linphone_account_creator_login_linphone_account(creator),
LinphoneAccountCreatorStatusRequestOk,
LinphoneAccountCreatorStatus,
"%i");
wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST);
ms_free(stats);
linphone_account_creator_unref(creator);
linphone_core_manager_destroy(marie);
}
static void server_recover_phone_account_exists(void) {
LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();
linphone_account_creator_set_username(creator, "user_md5_only");
linphone_account_creator_set_domain(creator, "sip.example.org");
linphone_account_creator_set_activation_code(creator, "1666");
linphone_account_creator_set_algorithm(creator, "MD5");
belle_sip_object_data_set((belle_sip_object_t *)creator, "expected_ha1", ms_strdup("secret_md5"), ms_free);
belle_sip_object_data_set((belle_sip_object_t *)creator, "expected_algorithm", ms_strdup("MD5"), ms_free);
linphone_account_creator_cbs_set_user_data(cbs, stats);
linphone_account_creator_cbs_set_login_linphone_account(cbs, login_linphone_account_creator_cb);
linphone_account_creator_service_set_user_data(
linphone_account_creator_get_service(creator),
(void*)LinphoneAccountCreatorStatusRequestOk);
BC_ASSERT_EQUAL(
linphone_account_creator_login_linphone_account(creator),
LinphoneAccountCreatorStatusRequestOk,
LinphoneAccountCreatorStatus,
"%i");
wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST);
ms_free(stats);
linphone_account_creator_unref(creator);
creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
cbs = linphone_account_creator_get_callbacks(creator);
stats = new_linphone_account_creator_stats();
linphone_account_creator_set_username(creator, "user_sha256_only");
linphone_account_creator_set_domain(creator, "sip.example.org");
linphone_account_creator_set_activation_code(creator, "1666");
linphone_account_creator_set_algorithm(creator, "SHA-256");
belle_sip_object_data_set((belle_sip_object_t *)creator, "expected_ha1", ms_strdup("secret_sha256"), ms_free);
belle_sip_object_data_set((belle_sip_object_t *)creator, "expected_algorithm", ms_strdup("SHA-256"), ms_free);
linphone_account_creator_cbs_set_user_data(cbs, stats);
linphone_account_creator_cbs_set_login_linphone_account(cbs, login_linphone_account_creator_cb);
linphone_account_creator_service_set_user_data(
linphone_account_creator_get_service(creator),
(void*)LinphoneAccountCreatorStatusRequestOk);
BC_ASSERT_EQUAL(
linphone_account_creator_login_linphone_account(creator),
LinphoneAccountCreatorStatusRequestOk,
LinphoneAccountCreatorStatus,
"%i");
wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST);
ms_free(stats);
linphone_account_creator_unref(creator);
creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
cbs = linphone_account_creator_get_callbacks(creator);
stats = new_linphone_account_creator_stats();
linphone_account_creator_set_username(creator, "user_sha256_only");
linphone_account_creator_set_domain(creator, "sip.example.org");
linphone_account_creator_set_activation_code(creator, "1666");
linphone_account_creator_set_algorithm(creator, "MD5");
belle_sip_object_data_set((belle_sip_object_t *)creator, "expected_ha1", ms_strdup("secret_sha256"), ms_free);
belle_sip_object_data_set((belle_sip_object_t *)creator, "expected_algorithm", ms_strdup("SHA-256"), ms_free);
linphone_account_creator_cbs_set_user_data(cbs, stats);
linphone_account_creator_cbs_set_login_linphone_account(cbs, login_linphone_account_creator_cb);
linphone_account_creator_service_set_user_data(
linphone_account_creator_get_service(creator),
(void*)LinphoneAccountCreatorStatusRequestOk);
BC_ASSERT_EQUAL(
linphone_account_creator_login_linphone_account(creator),
LinphoneAccountCreatorStatusRequestOk,
LinphoneAccountCreatorStatus,
"%i");
wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST);
ms_free(stats);
linphone_account_creator_unref(creator);
creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
cbs = linphone_account_creator_get_callbacks(creator);
stats = new_linphone_account_creator_stats();
linphone_account_creator_set_username(creator, "user_md5_only");
linphone_account_creator_set_domain(creator, "sip.example.org");
linphone_account_creator_set_activation_code(creator, "1666");
linphone_account_creator_set_algorithm(creator, "SHA-256");
belle_sip_object_data_set((belle_sip_object_t *)creator, "expected_ha1", ms_strdup("secret_md5"), ms_free);
belle_sip_object_data_set((belle_sip_object_t *)creator, "expected_algorithm", ms_strdup("MD5"), ms_free);
linphone_account_creator_cbs_set_user_data(cbs, stats);
linphone_account_creator_cbs_set_login_linphone_account(cbs, login_linphone_account_creator_cb);
linphone_account_creator_service_set_user_data(
linphone_account_creator_get_service(creator),
(void*)LinphoneAccountCreatorStatusRequestOk);
BC_ASSERT_EQUAL(
linphone_account_creator_login_linphone_account(creator),
LinphoneAccountCreatorStatusRequestOk,
LinphoneAccountCreatorStatus,
"%i");
wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST);
ms_free(stats);
linphone_account_creator_unref(creator);
creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
cbs = linphone_account_creator_get_callbacks(creator);
stats = new_linphone_account_creator_stats();
linphone_account_creator_set_username(creator, "user_both_md5_sha256");
linphone_account_creator_set_domain(creator, "sip.example.org");
linphone_account_creator_set_activation_code(creator, "1666");
linphone_account_creator_set_algorithm(creator, "MD5");
belle_sip_object_data_set((belle_sip_object_t *)creator, "expected_ha1", ms_strdup("secret_md5"), ms_free);
belle_sip_object_data_set((belle_sip_object_t *)creator, "expected_algorithm", ms_strdup("MD5"), ms_free);
linphone_account_creator_cbs_set_user_data(cbs, stats);
linphone_account_creator_cbs_set_login_linphone_account(cbs, login_linphone_account_creator_cb);
linphone_account_creator_service_set_user_data(
linphone_account_creator_get_service(creator),
(void*)LinphoneAccountCreatorStatusRequestOk);
BC_ASSERT_EQUAL(
linphone_account_creator_login_linphone_account(creator),
LinphoneAccountCreatorStatusRequestOk,
LinphoneAccountCreatorStatus,
"%i");
wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST);
ms_free(stats);
linphone_account_creator_unref(creator);
creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
cbs = linphone_account_creator_get_callbacks(creator);
stats = new_linphone_account_creator_stats();
linphone_account_creator_set_username(creator, "user_both_md5_sha256");
linphone_account_creator_set_domain(creator, "sip.example.org");
linphone_account_creator_set_activation_code(creator, "1666");
linphone_account_creator_set_algorithm(creator, "SHA-256");
belle_sip_object_data_set((belle_sip_object_t *)creator, "expected_ha1", ms_strdup("secret_sha256"), ms_free);
belle_sip_object_data_set((belle_sip_object_t *)creator, "expected_algorithm", ms_strdup("SHA-256"), ms_free);
linphone_account_creator_cbs_set_user_data(cbs, stats);
linphone_account_creator_cbs_set_login_linphone_account(cbs, login_linphone_account_creator_cb);
linphone_account_creator_service_set_user_data(
linphone_account_creator_get_service(creator),
(void*)LinphoneAccountCreatorStatusRequestOk);
BC_ASSERT_EQUAL(
linphone_account_creator_login_linphone_account(creator),
LinphoneAccountCreatorStatusRequestOk,
LinphoneAccountCreatorStatus,
"%i");
wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST);
ms_free(stats);
linphone_account_creator_unref(creator);
linphone_core_manager_destroy(marie);
}
/****************** End Update Account ************************/
test_t account_creator_tests[] = {
......@@ -2399,6 +2622,14 @@ test_t account_creator_tests[] = {
"Server - Recover account with phone number used",
server_recover_account_with_phone_number_used,
"Server"),
TEST_ONE_TAG(
"Server - Recover account password and algorithm from confirmation key when doesnt exists",
server_recover_phone_account_doesnt_exists,
"Server"),
TEST_ONE_TAG(
"Server - Recover account password and algorithm from confirmation key",
server_recover_phone_account_exists,
"Server"),
};
test_suite_t account_creator_test_suite = {
......
......@@ -2,7 +2,7 @@
domain=sip.accounttest.org
password_max_length=12
password_min_length=3
username_max_length=14
username_max_length=22
username_min_length=3
username_regex=^[A-Za-z0-9_.\-\ ]*$
xmlrpc_url=https://sip2.linphone.org:446/wizard.php
......
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