account_creator_tester.c 91.9 KB
Newer Older
Erwan Croze's avatar
Erwan Croze committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
	liblinphone_tester - liblinphone test suite
	Copyright (C) 2017  Belledonne Communications SARL

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "liblinphone_tester.h"
20
#include "private.h"
Erwan Croze's avatar
Erwan Croze committed
21 22 23

static const char XMLRPC_URL[] = "https://sip2.linphone.org:446/xmlrpc.php";

24
static const int TIMEOUT_REQUEST = 10000;
Erwan Croze's avatar
Erwan Croze committed
25

26 27
/////////// INIT //////////////

28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
static void init_linphone_account_creator_service(LinphoneCore *lc) {
	LinphoneAccountCreatorService *service = linphone_account_creator_service_new();
	linphone_account_creator_service_set_constructor_cb(service, NULL);
	linphone_account_creator_service_set_destructor_cb(service, NULL);
	linphone_account_creator_service_set_create_account_cb(service, linphone_account_creator_create_account_linphone);
	linphone_account_creator_service_set_is_account_exist_cb(service, linphone_account_creator_is_account_exist_linphone);
	linphone_account_creator_service_set_activate_account_cb(service, linphone_account_creator_activate_account_linphone);
	linphone_account_creator_service_set_is_account_activated_cb(service, linphone_account_creator_is_account_activated_linphone);
	linphone_account_creator_service_set_link_account_cb(service, linphone_account_creator_link_phone_number_with_account_linphone);
	linphone_account_creator_service_set_activate_alias_cb(service, linphone_account_creator_activate_phone_number_link_linphone);
	linphone_account_creator_service_set_is_alias_used_cb(service, linphone_account_creator_is_phone_number_used_linphone);
	linphone_account_creator_service_set_is_account_linked_cb(service, linphone_account_creator_is_account_linked_linphone);
	linphone_account_creator_service_set_recover_account_cb(service, linphone_account_creator_recover_phone_account_linphone);
	linphone_account_creator_service_set_update_account_cb(service, linphone_account_creator_update_password_linphone);
	linphone_core_set_account_creator_service(lc, service);
43 44 45
}

static LinphoneAccountCreator * _linphone_account_creator_new(LinphoneCore *lc, const char * url) {
46
	init_linphone_account_creator_service(lc);
47 48 49 50
	LinphoneAccountCreator *creator = linphone_account_creator_new(lc, url);
	return creator;
}

Erwan Croze's avatar
Erwan Croze committed
51 52 53 54 55
/////////// LOCAL TESTS ///////////

////// USERNAME //////
static void local_username_too_short(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
56
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, "");
Erwan Croze's avatar
Erwan Croze committed
57 58 59

	BC_ASSERT_EQUAL(
		linphone_account_creator_set_username(creator, ""),
60 61
		LinphoneAccountCreatorUsernameStatusTooShort,
		LinphoneAccountCreatorUsernameStatus,
Erwan Croze's avatar
Erwan Croze committed
62 63 64 65 66 67 68 69
		"%i");

	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

static void local_username_too_long(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
70
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, "");
Erwan Croze's avatar
Erwan Croze committed
71 72

	BC_ASSERT_EQUAL(
73
		linphone_account_creator_set_username(creator, "usernametoolongforyou"),
74 75
		LinphoneAccountCreatorUsernameStatusTooLong,
		LinphoneAccountCreatorUsernameStatus,
Erwan Croze's avatar
Erwan Croze committed
76 77 78 79 80 81
		"%i");

	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

82
static void local_username_invalid_character(void) {
Erwan Croze's avatar
Erwan Croze committed
83
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
84
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, "");
Erwan Croze's avatar
Erwan Croze committed
85 86 87

	BC_ASSERT_EQUAL(
			linphone_account_creator_set_username(creator, "use!"),
88 89
			LinphoneAccountCreatorUsernameStatusInvalidCharacters,
			LinphoneAccountCreatorUsernameStatus,
Erwan Croze's avatar
Erwan Croze committed
90 91 92 93 94 95 96 97
			"%i");

	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

static void local_username_ok(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
98
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, "");
Erwan Croze's avatar
Erwan Croze committed
99 100

	BC_ASSERT_EQUAL(
101
			linphone_account_creator_set_username(creator, "XXXTESTuser_1"),
102 103
			LinphoneAccountCreatorUsernameStatusOk,
			LinphoneAccountCreatorUsernameStatus,
Erwan Croze's avatar
Erwan Croze committed
104 105 106 107 108 109 110 111 112 113
			"%i");

	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

////// PASSWORD //////

static void local_password_too_short(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
114
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, "");
Erwan Croze's avatar
Erwan Croze committed
115 116 117

	BC_ASSERT_EQUAL(
		linphone_account_creator_set_password(creator, ""),
118 119
		LinphoneAccountCreatorPasswordStatusTooShort,
		LinphoneAccountCreatorPasswordStatus,
Erwan Croze's avatar
Erwan Croze committed
120 121 122 123 124 125 126 127
		"%i");

	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

static void local_password_too_long(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
128
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, "");
Erwan Croze's avatar
Erwan Croze committed
129 130 131

	BC_ASSERT_EQUAL(
		linphone_account_creator_set_password(creator, "passwordtoolong"),
132 133
		LinphoneAccountCreatorPasswordStatusTooLong,
		LinphoneAccountCreatorPasswordStatus,
Erwan Croze's avatar
Erwan Croze committed
134 135 136 137 138 139 140 141
		"%i");

	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

static void local_password_ok(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
142
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, "");
Erwan Croze's avatar
Erwan Croze committed
143 144

	BC_ASSERT_EQUAL(
145
		linphone_account_creator_set_password(creator, "pass"),
146 147
		LinphoneAccountCreatorPasswordStatusOk,
		LinphoneAccountCreatorPasswordStatus,
Erwan Croze's avatar
Erwan Croze committed
148 149 150 151 152 153 154 155
		"%i");

	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

////// EMAIL //////

156
static void local_email_malformed(void) {
Erwan Croze's avatar
Erwan Croze committed
157
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
158
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, "");
Erwan Croze's avatar
Erwan Croze committed
159 160 161

	BC_ASSERT_EQUAL(
		linphone_account_creator_set_email(creator, "test.linphone.org"),
162 163
		LinphoneAccountCreatorEmailStatusMalformed,
		LinphoneAccountCreatorEmailStatus,
Erwan Croze's avatar
Erwan Croze committed
164 165
		"%i");

166 167
	BC_ASSERT_EQUAL(
		linphone_account_creator_set_email(creator, "test@linphone"),
168 169
		LinphoneAccountCreatorEmailStatusMalformed,
		LinphoneAccountCreatorEmailStatus,
170
		"%i");
Erwan Croze's avatar
Erwan Croze committed
171

172 173
	BC_ASSERT_EQUAL(
		linphone_account_creator_set_email(creator, "@linphone.org"),
174 175
		LinphoneAccountCreatorEmailStatusMalformed,
		LinphoneAccountCreatorEmailStatus,
176
		"%i");
Erwan Croze's avatar
Erwan Croze committed
177 178

	BC_ASSERT_EQUAL(
179
		linphone_account_creator_set_email(creator, "linphone@.org"),
180 181
		LinphoneAccountCreatorEmailStatusMalformed,
		LinphoneAccountCreatorEmailStatus,
182 183 184 185
		"%i");

	BC_ASSERT_EQUAL(
		linphone_account_creator_set_email(creator, ".linphone@.org"),
186 187
		LinphoneAccountCreatorEmailStatusMalformed,
		LinphoneAccountCreatorEmailStatus,
Erwan Croze's avatar
Erwan Croze committed
188 189 190 191 192 193
		"%i");

	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

194
static void local_email_invalid_character(void) {
Erwan Croze's avatar
Erwan Croze committed
195
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
196
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, "");
Erwan Croze's avatar
Erwan Croze committed
197 198

	BC_ASSERT_EQUAL(
199
		linphone_account_creator_set_email(creator, "test@linphone.org$"),
200 201
		LinphoneAccountCreatorEmailStatusInvalidCharacters,
		LinphoneAccountCreatorEmailStatus,
Erwan Croze's avatar
Erwan Croze committed
202 203 204 205 206 207
		"%i");

	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

208
static void local_email_ok(void) {
Erwan Croze's avatar
Erwan Croze committed
209
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
210
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, "");
Erwan Croze's avatar
Erwan Croze committed
211 212

	BC_ASSERT_EQUAL(
213
		linphone_account_creator_set_email(creator, "test@linphone.org"),
214 215
		LinphoneAccountCreatorEmailStatusOk,
		LinphoneAccountCreatorEmailStatus,
Erwan Croze's avatar
Erwan Croze committed
216 217
		"%i");

218 219
	BC_ASSERT_EQUAL(
		linphone_account_creator_set_email(creator, "test02@linphone5252.org"),
220 221
		LinphoneAccountCreatorEmailStatusOk,
		LinphoneAccountCreatorEmailStatus,
222
		"%i");
Erwan Croze's avatar
Erwan Croze committed
223 224

	BC_ASSERT_EQUAL(
225
		linphone_account_creator_set_email(creator, "9053test@50255linphone.org"),
226 227
		LinphoneAccountCreatorEmailStatusOk,
		LinphoneAccountCreatorEmailStatus,
Erwan Croze's avatar
Erwan Croze committed
228 229 230 231 232 233
		"%i");

	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

234 235 236
////// PHONE NUMBER //////

static void local_phone_number_too_short(void) {
Erwan Croze's avatar
Erwan Croze committed
237
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
238
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, "");
Erwan Croze's avatar
Erwan Croze committed
239 240

	BC_ASSERT_EQUAL(
241 242 243
		linphone_account_creator_set_phone_number(creator, "0123", "33")&LinphoneAccountCreatorPhoneNumberStatusTooShort,
		LinphoneAccountCreatorPhoneNumberStatusTooShort,
		LinphoneAccountCreatorPhoneNumberStatus,
Erwan Croze's avatar
Erwan Croze committed
244 245 246 247 248 249
		"%i");

	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

250
static void local_phone_number_too_long(void) {
Erwan Croze's avatar
Erwan Croze committed
251
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
252
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, "");
Erwan Croze's avatar
Erwan Croze committed
253 254

	BC_ASSERT_EQUAL(
255 256 257
		linphone_account_creator_set_phone_number(creator, "01234567891011", "33")&LinphoneAccountCreatorPhoneNumberStatusTooLong,
		LinphoneAccountCreatorPhoneNumberStatusTooLong,
		LinphoneAccountCreatorPhoneNumberStatus,
Erwan Croze's avatar
Erwan Croze committed
258 259 260 261 262 263
		"%i");

	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

264
static void local_phone_number_invalid(void) {
Erwan Croze's avatar
Erwan Croze committed
265
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
266
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, "");
Erwan Croze's avatar
Erwan Croze committed
267 268

	BC_ASSERT_EQUAL(
269 270 271
		linphone_account_creator_set_phone_number(creator, NULL, "33")&LinphoneAccountCreatorPhoneNumberStatusInvalid,
		LinphoneAccountCreatorPhoneNumberStatusInvalid,
		LinphoneAccountCreatorPhoneNumberStatus,
Erwan Croze's avatar
Erwan Croze committed
272 273 274 275 276 277
		"%i");

	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

278
static void local_country_code_invalid(void) {
Erwan Croze's avatar
Erwan Croze committed
279
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
280
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, "");
281

Erwan Croze's avatar
Erwan Croze committed
282
	BC_ASSERT_EQUAL(
283 284 285
		linphone_account_creator_set_phone_number(creator, "0123", "")&LinphoneAccountCreatorPhoneNumberStatusInvalidCountryCode,
		LinphoneAccountCreatorPhoneNumberStatusInvalidCountryCode,
		LinphoneAccountCreatorPhoneNumberStatus,
Erwan Croze's avatar
Erwan Croze committed
286
		"%i");
287

Erwan Croze's avatar
Erwan Croze committed
288 289
	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
290
}
Erwan Croze's avatar
Erwan Croze committed
291

292
static void local_phone_number_ok(void) {
Erwan Croze's avatar
Erwan Croze committed
293
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
294
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, "");
Erwan Croze's avatar
Erwan Croze committed
295 296

	BC_ASSERT_EQUAL(
297 298 299
		linphone_account_creator_set_phone_number(creator, "000555455", "1")&LinphoneAccountCreatorPhoneNumberStatusOk,
		LinphoneAccountCreatorPhoneNumberStatusOk,
		LinphoneAccountCreatorPhoneNumberStatus,
Erwan Croze's avatar
Erwan Croze committed
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
		"%i");

	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

/////////// SERVER TESTS ///////////

typedef struct _LinphoneAccountCreatorStats {
	int cb_done;
} LinphoneAccountCreatorStats;

static LinphoneAccountCreatorStats* new_linphone_account_creator_stats(void) {
	LinphoneAccountCreatorStats *stats = (LinphoneAccountCreatorStats*) ms_new0(LinphoneAccountCreatorStats, 1);
	return stats;
}

317 318
static void account_creator_set_cb_done(LinphoneAccountCreatorCbs *cbs) {
	LinphoneAccountCreatorStats *stats = (LinphoneAccountCreatorStats*) linphone_account_creator_cbs_get_user_data(cbs);
Erwan Croze's avatar
Erwan Croze committed
319 320 321 322
	stats->cb_done++;
	BC_ASSERT_TRUE(stats->cb_done);
}

323 324
static void account_creator_reset_cb_done(LinphoneAccountCreatorCbs *cbs) {
	LinphoneAccountCreatorStats *stats = (LinphoneAccountCreatorStats*) linphone_account_creator_cbs_get_user_data(cbs);
Erwan Croze's avatar
Erwan Croze committed
325 326
	stats->cb_done = 0;
	BC_ASSERT_FALSE(stats->cb_done);
327
}
Erwan Croze's avatar
Erwan Croze committed
328

329 330 331 332
static void 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));
Erwan Croze's avatar
Erwan Croze committed
333 334 335
	BC_ASSERT_EQUAL(
		status,
		expected_status,
336
		LinphoneAccountCreatorStatus,
Erwan Croze's avatar
Erwan Croze committed
337 338 339 340
		"%i");
	account_creator_set_cb_done(cbs);
}

341 342
static void _get_activation_code_cb(LinphoneXmlRpcRequest *request) {
	LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request);
343
	LinphoneAccountCreatorStatus status = LinphoneAccountCreatorStatusRequestFailed;
344 345 346
	const char* resp = linphone_xml_rpc_request_get_string_response(request);
	if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) {
		if (strstr(resp, "ERROR_") == resp) {
347
			status = LinphoneAccountCreatorStatusRequestFailed;
348
		} else {
349
			status = LinphoneAccountCreatorStatusRequestOk;
350 351 352 353 354 355
			set_string(&creator->activation_code, resp, FALSE);
		}
	}
	account_creator_cb(creator, status, resp);
}

356
LinphoneAccountCreatorStatus get_activation_code_account_cb(LinphoneAccountCreator *creator) {
357 358
	LinphoneXmlRpcRequest *request;
	if ((!creator->username && !creator->phone_number) || !creator->password) {
359
		return LinphoneAccountCreatorStatusMissingArguments;
360 361
	}

362 363 364 365
	request = linphone_xml_rpc_request_new(LinphoneXmlRpcArgString, "get_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->password);
	linphone_xml_rpc_request_add_string_arg(request, linphone_proxy_config_get_domain(creator->proxy_cfg));
366 367 368 369 370
	linphone_xml_rpc_request_set_user_data(request, creator);
	linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _get_activation_code_cb);
	linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
	linphone_xml_rpc_request_unref(request);

371
	return LinphoneAccountCreatorStatusRequestOk;
372 373 374 375
}

static void _delete_account_cb(LinphoneXmlRpcRequest *request) {
	LinphoneAccountCreator *creator = (LinphoneAccountCreator *)linphone_xml_rpc_request_get_user_data(request);
376
	LinphoneAccountCreatorStatus status = LinphoneAccountCreatorStatusRequestFailed;
377 378 379 380 381
	const char* resp = linphone_xml_rpc_request_get_string_response(request);
	if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) {
		// We want to delete account from table but it's not an error if it doesn't exist or password doesn't match
		if (strstr(resp, "ERROR_ACCOUNT_DOESNT_EXIST") == resp
			|| strstr(resp, "ERROR_PASSWORD_DOESNT_MATCH") == resp) {
382
			status = LinphoneAccountCreatorStatusRequestOk;
383
		} else if (strstr(resp, "ERROR_") == resp) {
384
			status = LinphoneAccountCreatorStatusRequestFailed;
385
		} else {
386
			status = LinphoneAccountCreatorStatusRequestOk;
387 388 389 390 391
		}
	}
	account_creator_cb(creator, status, resp);
}

392
LinphoneAccountCreatorStatus delete_account_cb(LinphoneAccountCreator *creator) {
393 394
	LinphoneXmlRpcRequest *request;
	if ((!creator->username && !creator->phone_number) || !creator->password) {
395
		return LinphoneAccountCreatorStatusMissingArguments;
396 397
	}

398 399 400 401
	request = linphone_xml_rpc_request_new(LinphoneXmlRpcArgString, "delete_account");
	linphone_xml_rpc_request_add_string_arg(request, creator->username ? creator->username : creator->phone_number);
	linphone_xml_rpc_request_add_string_arg(request, creator->password);
	linphone_xml_rpc_request_add_string_arg(request, linphone_proxy_config_get_domain(creator->proxy_cfg));
402 403 404 405 406
	linphone_xml_rpc_request_set_user_data(request, creator);
	linphone_xml_rpc_request_cbs_set_response(linphone_xml_rpc_request_get_callbacks(request), _delete_account_cb);
	linphone_xml_rpc_session_send_request(creator->xmlrpc_session, request);
	linphone_xml_rpc_request_unref(request);

407
	return LinphoneAccountCreatorStatusRequestOk;
408 409 410
}

static void get_activation_code(LinphoneAccountCreator *creator, int *cb_done) {
411 412 413
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusRequestOk);
414 415 416

	BC_ASSERT_EQUAL(
		get_activation_code_account_cb(creator),
417 418
		LinphoneAccountCreatorStatusRequestOk,
		LinphoneAccountCreatorStatus,
419 420 421 422 423 424 425 426
		"%i");

	wait_for_until(creator->core, NULL, cb_done, 1, TIMEOUT_REQUEST);
}

static void server_delete_account_test(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
427
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
428 429
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

430 431 432 433
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusRequestOk);
434 435 436 437 438 439
	linphone_account_creator_set_email(creator, "user_2@linphone.org");
	linphone_account_creator_set_password(creator, "password");
	linphone_account_creator_set_phone_number(creator, "000555455","1");

	BC_ASSERT_EQUAL(
		delete_account_cb(creator),
440 441
		LinphoneAccountCreatorStatusRequestOk,
		LinphoneAccountCreatorStatus,
442 443 444 445 446 447 448 449
		"%i");

	wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST);

	linphone_account_creator_unref(creator);

	// First attempt with the first password
	creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
450
	cbs = linphone_account_creator_get_callbacks(creator);
451

452
	linphone_account_creator_cbs_set_user_data(cbs, stats);
453
	account_creator_reset_cb_done(cbs);
454 455 456
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusRequestOk);
457 458 459 460 461 462
	linphone_account_creator_set_username(creator, "XXXTESTuser_1");
	linphone_account_creator_set_email(creator, "user_1@linphone.org");
	linphone_account_creator_set_password(creator, "password");

	BC_ASSERT_EQUAL(
		delete_account_cb(creator),
463 464
		LinphoneAccountCreatorStatusRequestOk,
		LinphoneAccountCreatorStatus,
465 466 467 468 469 470 471 472
		"%i");

	wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST);

	linphone_account_creator_unref(creator);

	// Second attempt with the second password
	creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
473
	cbs = linphone_account_creator_get_callbacks(creator);
474

475
	linphone_account_creator_cbs_set_user_data(cbs, stats);
476
	account_creator_reset_cb_done(cbs);
477 478 479
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusRequestOk);
480 481 482 483 484 485
	linphone_account_creator_set_username(creator, "XXXTESTuser_1");
	linphone_account_creator_set_email(creator, "user_1@linphone.org");
	linphone_account_creator_set_password(creator, "newpassword");

	BC_ASSERT_EQUAL(
		delete_account_cb(creator),
486 487
		LinphoneAccountCreatorStatusRequestOk,
		LinphoneAccountCreatorStatus,
488 489 490 491
		"%i");

	wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST);

492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513
	linphone_account_creator_unref(creator);

	creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
	cbs = linphone_account_creator_get_callbacks(creator);

	linphone_account_creator_cbs_set_user_data(cbs, stats);
	account_creator_reset_cb_done(cbs);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusRequestOk);
	linphone_account_creator_set_username(creator, "XXXTESTuser_3");
	linphone_account_creator_set_email(creator, "user_1@linphone.org");
	linphone_account_creator_set_password(creator, "password");

	BC_ASSERT_EQUAL(
		delete_account_cb(creator),
		LinphoneAccountCreatorStatusRequestOk,
		LinphoneAccountCreatorStatus,
		"%i");

	wait_for_until(marie->lc, NULL, &stats->cb_done, 1, TIMEOUT_REQUEST);

514 515 516 517 518
	ms_free(stats);
	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

519
/****************** Start Is Account Exist ************************/
Erwan Croze's avatar
Erwan Croze committed
520 521
static void server_account_doesnt_exist(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
522
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
523
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
Erwan Croze's avatar
Erwan Croze committed
524 525
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

526 527 528 529
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusAccountNotExist);
Erwan Croze's avatar
Erwan Croze committed
530
	linphone_account_creator_set_username(creator, "user_not_exist");
531
	linphone_account_creator_cbs_set_is_account_exist(cbs, account_creator_cb);
Erwan Croze's avatar
Erwan Croze committed
532 533

	BC_ASSERT_EQUAL(
534
		linphone_account_creator_is_account_exist(creator),
535 536
		LinphoneAccountCreatorStatusRequestOk,
		LinphoneAccountCreatorStatus,
Erwan Croze's avatar
Erwan Croze committed
537 538 539 540 541 542 543 544 545 546 547
		"%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_account_exist(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
548
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
549
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
550 551
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

552 553 554 555
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusAccountExist);
556
	linphone_account_creator_set_username(creator, "XXXTESTuser_1");
557
	linphone_account_creator_cbs_set_is_account_exist(cbs, account_creator_cb);
558 559 560

	BC_ASSERT_EQUAL(
		linphone_account_creator_is_account_exist(creator),
561 562
		LinphoneAccountCreatorStatusRequestOk,
		LinphoneAccountCreatorStatus,
563 564 565 566 567 568 569 570 571 572 573
		"%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_is_account_exist_cb_missing(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
574
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
575 576 577 578 579

	linphone_account_creator_set_username(creator, "user_exist");

	BC_ASSERT_EQUAL(
		linphone_account_creator_is_account_exist(creator),
580 581
		LinphoneAccountCreatorStatusMissingCallbacks,
		LinphoneAccountCreatorStatus,
582 583 584 585 586 587 588 589
		"%i");

	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

static void server_is_account_exist_arg_missing(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
590
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
591
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
592 593
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

594 595 596 597 598
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusMissingArguments);
	linphone_account_creator_cbs_set_is_account_exist(cbs, account_creator_cb);
599 600 601

	BC_ASSERT_EQUAL(
		linphone_account_creator_is_account_exist(creator),
602 603
		LinphoneAccountCreatorStatusMissingArguments,
		LinphoneAccountCreatorStatus,
604 605 606 607 608 609 610 611 612
		"%i");

	ms_free(stats);
	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}
/****************** End Is Account Exist ************************/

/****************** Start Create Account ************************/
613
static void server_account_created_with_email(void) {
614
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
615
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
616
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
617 618
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

619 620 621 622
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusAccountCreated);
623
	linphone_account_creator_set_username(creator, "XXXTESTuser_1");
624 625
	linphone_account_creator_set_email(creator, "user_1@linphone.org");
	linphone_account_creator_set_password(creator, "password");
626
	linphone_account_creator_cbs_set_create_account(cbs, account_creator_cb);
627 628 629

	BC_ASSERT_EQUAL(
		linphone_account_creator_create_account(creator),
630 631
		LinphoneAccountCreatorStatusRequestOk,
		LinphoneAccountCreatorStatus,
632 633 634 635 636 637 638 639 640 641 642
		"%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_create_account_already_create_with_email(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
643
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
644
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
645 646
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

647 648 649 650
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusAccountExist);
651 652
	linphone_account_creator_set_username(creator, "XXXTESTuser_1");
	linphone_account_creator_set_email(creator, "user_1@linphone.org");
653
	linphone_account_creator_set_password(creator, "password");
654
	linphone_account_creator_cbs_set_create_account(cbs, account_creator_cb);
655 656 657

	BC_ASSERT_EQUAL(
		linphone_account_creator_create_account(creator),
658 659
		LinphoneAccountCreatorStatusRequestOk,
		LinphoneAccountCreatorStatus,
660 661 662 663 664 665 666 667 668
		"%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);
}

669
static void server_account_created_with_phone_number(void) {
670
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
671
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
672
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
673 674
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

675 676 677 678
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusAccountCreated);
679
	linphone_account_creator_set_email(creator, "user_2@linphone.org");
680
	linphone_account_creator_set_password(creator, "password");
681
	linphone_account_creator_set_phone_number(creator, "000555455","1");
682
	linphone_account_creator_cbs_set_create_account(cbs, account_creator_cb);
683 684 685

	BC_ASSERT_EQUAL(
		linphone_account_creator_create_account(creator),
686 687
		LinphoneAccountCreatorStatusRequestOk,
		LinphoneAccountCreatorStatus,
688 689 690 691 692 693 694 695 696 697 698
		"%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_create_account_already_create_as_account_with_phone_number(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
699
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
700
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
701 702
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

703 704 705 706
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusAccountExist);
707 708 709
	linphone_account_creator_set_email(creator, "user_2@linphone.org");
	linphone_account_creator_set_password(creator, "password");
	linphone_account_creator_set_phone_number(creator, "000555455","1");
710
	linphone_account_creator_cbs_set_create_account(cbs, account_creator_cb);
711 712 713

	BC_ASSERT_EQUAL(
		linphone_account_creator_create_account(creator),
714 715
		LinphoneAccountCreatorStatusRequestOk,
		LinphoneAccountCreatorStatus,
716 717 718 719 720 721 722 723 724 725 726
		"%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_create_account_already_create_as_alias_with_phone_number(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
727
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
728
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
Erwan Croze's avatar
Erwan Croze committed
729 730
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

731 732 733 734
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusAccountExistWithAlias);
735 736 737 738
	linphone_account_creator_set_username(creator, "XXXTESTuser_3");
	linphone_account_creator_set_email(creator, "user_2@linphone.org");
	linphone_account_creator_set_password(creator, "password");
	linphone_account_creator_set_phone_number(creator, "000555456","1");
739
	linphone_account_creator_cbs_set_create_account(cbs, account_creator_cb);
Erwan Croze's avatar
Erwan Croze committed
740 741

	BC_ASSERT_EQUAL(
742
		linphone_account_creator_create_account(creator),
743 744
		LinphoneAccountCreatorStatusRequestOk,
		LinphoneAccountCreatorStatus,
Erwan Croze's avatar
Erwan Croze committed
745 746 747 748 749 750 751 752 753
		"%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);
}

754 755
static void server_create_account_cb_missing(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
756
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
757 758 759 760 761 762 763

	linphone_account_creator_set_username(creator, "user_exist");
	linphone_account_creator_set_email(creator, "user_1@linphone.org");
	linphone_account_creator_set_password(creator, "password");

	BC_ASSERT_EQUAL(
		linphone_account_creator_create_account(creator),
764 765
		LinphoneAccountCreatorStatusMissingCallbacks,
		LinphoneAccountCreatorStatus,
766 767 768 769 770 771 772 773
		"%i");

	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

static void server_create_account_with_email_arg_username_missing(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
774
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
775
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
776 777 778 779 780
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

	linphone_account_creator_set_email(creator, "user_1@linphone.org");
	linphone_account_creator_set_password(creator, "password");

781 782 783 784 785
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusMissingArguments);
	linphone_account_creator_cbs_set_create_account(cbs, account_creator_cb);
786 787 788

	BC_ASSERT_EQUAL(
		linphone_account_creator_create_account(creator),
789 790
		LinphoneAccountCreatorStatusMissingArguments,
		LinphoneAccountCreatorStatus,
791 792 793 794 795 796 797 798 799
		"%i");

	ms_free(stats);
	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

static void server_create_account_with_email_arg_email_missing(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
800
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
801
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
802 803 804 805 806
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

	linphone_account_creator_set_username(creator, "user_exist");
	linphone_account_creator_set_password(creator, "password");

807 808 809 810 811
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusMissingArguments);
	linphone_account_creator_cbs_set_create_account(cbs, account_creator_cb);
812 813 814

	BC_ASSERT_EQUAL(
		linphone_account_creator_create_account(creator),
815 816
		LinphoneAccountCreatorStatusMissingArguments,
		LinphoneAccountCreatorStatus,
817 818 819 820 821 822 823 824 825
		"%i");

	ms_free(stats);
	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

static void server_create_account_with_email_arg_password_missing(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
826
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
827
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
828 829 830 831 832
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

	linphone_account_creator_set_username(creator, "user_exist");
	linphone_account_creator_set_email(creator, "user_1@linphone.org");

833 834 835 836 837
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusMissingArguments);
	linphone_account_creator_cbs_set_create_account(cbs, account_creator_cb);
838 839 840

	BC_ASSERT_EQUAL(
		linphone_account_creator_create_account(creator),
841 842
		LinphoneAccountCreatorStatusMissingArguments,
		LinphoneAccountCreatorStatus,
843 844 845 846 847 848 849 850 851
		"%i");

	ms_free(stats);
	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

static void server_create_account_with_phone_number_arg_username_missing(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
852
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
853
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
854 855 856 857 858
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

	linphone_account_creator_set_phone_number(creator, "0123456", "33");
	linphone_account_creator_set_password(creator, "password");

859 860 861 862 863
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusMissingArguments);
	linphone_account_creator_cbs_set_create_account(cbs, account_creator_cb);
864 865 866

	BC_ASSERT_EQUAL(
		linphone_account_creator_create_account(creator),
867 868
		LinphoneAccountCreatorStatusMissingArguments,
		LinphoneAccountCreatorStatus,
869 870 871 872 873 874 875 876 877
		"%i");

	ms_free(stats);
	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

static void server_create_account_with_phone_number_arg_phone_number_missing(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
878
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
879
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
880 881 882 883 884
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

	linphone_account_creator_set_username(creator, "user_exist");
	linphone_account_creator_set_password(creator, "password");

885 886 887 888 889
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusMissingArguments);
	linphone_account_creator_cbs_set_create_account(cbs, account_creator_cb);
890 891 892

	BC_ASSERT_EQUAL(
		linphone_account_creator_create_account(creator),
893 894
		LinphoneAccountCreatorStatusMissingArguments,
		LinphoneAccountCreatorStatus,
895 896 897 898 899 900 901 902 903
		"%i");

	ms_free(stats);
	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}
/****************** End Create Account ************************/

/****************** Start Is Account Activated ************************/
904 905
static void server_account_not_activated(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
906
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
907
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
908 909
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

910
	linphone_account_creator_set_username(creator, "XXXTESTuser_1");
911

912 913 914 915 916
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusAccountNotActivated);
	linphone_account_creator_cbs_set_is_account_activated(cbs, account_creator_cb);
917 918 919

	BC_ASSERT_EQUAL(
		linphone_account_creator_is_account_activated(creator),
920 921
		LinphoneAccountCreatorStatusRequestOk,
		LinphoneAccountCreatorStatus,
922 923 924 925 926 927 928 929 930 931 932
		"%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_account_already_activated(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
933
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
934
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
935 936
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

937
	linphone_account_creator_set_username(creator, "XXXTESTuser_1");
938

939 940 941 942 943
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusAccountActivated);
	linphone_account_creator_cbs_set_is_account_activated(cbs, account_creator_cb);
944 945 946

	BC_ASSERT_EQUAL(
		linphone_account_creator_is_account_activated(creator),
947 948
		LinphoneAccountCreatorStatusRequestOk,
		LinphoneAccountCreatorStatus,
949 950 951 952 953 954 955 956 957
		"%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);
}

958 959
static void server_is_account_activated_cb_missing(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
960
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
961 962 963 964 965

	linphone_account_creator_set_username(creator, "user_exist");

	BC_ASSERT_EQUAL(
		linphone_account_creator_is_account_activated(creator),
966 967
		LinphoneAccountCreatorStatusMissingCallbacks,
		LinphoneAccountCreatorStatus,
968 969 970 971 972 973 974 975
		"%i");

	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

static void server_is_account_activated_arg_username_missing(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
976
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
977
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
978 979
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

980 981 982 983 984
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusMissingArguments);
	linphone_account_creator_cbs_set_is_account_activated(cbs, account_creator_cb);
985 986 987

	BC_ASSERT_EQUAL(
		linphone_account_creator_is_account_activated(creator),
988 989
		LinphoneAccountCreatorStatusMissingArguments,
		LinphoneAccountCreatorStatus,
990 991 992 993 994 995 996 997 998
		"%i");

	ms_free(stats);
	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}
/****************** End Is Account Activated ************************/

/****************** Start Activate Account ************************/
999
static void server_activate_account_not_activated(void) {
1000
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
1001
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
1002
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
1003 1004
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

1005
	linphone_account_creator_cbs_set_user_data(cbs, stats);
1006
	linphone_account_creator_set_username(creator, "XXXTESTuser_1");
1007
	linphone_account_creator_set_email(creator, "user_1@linphone.org");
1008 1009
	linphone_account_creator_set_password(creator, "password");
	get_activation_code(creator, &stats->cb_done);
1010
	account_creator_reset_cb_done(creator->cbs);
1011

1012 1013 1014 1015
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusAccountActivated);
	linphone_account_creator_cbs_set_activate_account(cbs, account_creator_cb);
1016

1017 1018 1019 1020
	linphone_account_creator_service_set_activate_account_cb(
		linphone_account_creator_get_service(creator),
		linphone_account_creator_activate_email_account_linphone);

1021 1022
	BC_ASSERT_EQUAL(
		linphone_account_creator_activate_account(creator),
1023 1024
		LinphoneAccountCreatorStatusRequestOk,
		LinphoneAccountCreatorStatus,
1025 1026 1027 1028 1029 1030 1031 1032 1033
		"%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);
}

1034
static void server_activate_account_already_activated(void) {
1035
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
1036
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
1037
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
1038 1039
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

1040
	linphone_account_creator_cbs_set_user_data(cbs, stats);
1041 1042 1043 1044
	linphone_account_creator_set_username(creator, "XXXTESTuser_1");
	linphone_account_creator_set_email(creator, "user_1@linphone.org");
	linphone_account_creator_set_password(creator, "password");
	get_activation_code(creator, &stats->cb_done);
1045
	account_creator_reset_cb_done(creator->cbs);
1046

1047 1048 1049 1050
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusAccountAlreadyActivated);
	linphone_account_creator_cbs_set_activate_account(cbs, account_creator_cb);
1051 1052 1053
	linphone_account_creator_service_set_activate_account_cb(
		linphone_account_creator_get_service(creator),
		linphone_account_creator_activate_email_account_linphone);
1054 1055 1056

	BC_ASSERT_EQUAL(
		linphone_account_creator_activate_account(creator),
1057 1058
		LinphoneAccountCreatorStatusRequestOk,
		LinphoneAccountCreatorStatus,
1059 1060 1061 1062 1063 1064 1065 1066 1067
		"%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);
}

1068
static void server_activate_non_existent_account(void) {
1069
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
1070
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
1071
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
1072 1073 1074
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

	linphone_account_creator_set_username(creator, "unknown_user");
1075
	linphone_account_creator_set_activation_code(creator, "58c9");
1076 1077
	linphone_account_creator_set_email(creator, "user_1@linphone.org");

1078 1079 1080 1081 1082
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusAccountNotActivated);
	linphone_account_creator_cbs_set_activate_account(cbs, account_creator_cb);
1083 1084 1085
	linphone_account_creator_service_set_activate_account_cb(
		linphone_account_creator_get_service(creator),
		linphone_account_creator_activate_email_account_linphone);
1086 1087 1088

	BC_ASSERT_EQUAL(
		linphone_account_creator_activate_account(creator),
1089 1090
		LinphoneAccountCreatorStatusRequestOk,
		LinphoneAccountCreatorStatus,
1091 1092 1093 1094 1095 1096 1097 1098 1099
		"%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);
}

1100 1101
static void server_activate_account_cb_missing(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
1102
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
1103 1104 1105 1106 1107

	linphone_account_creator_set_username(creator, "user_exist");

	BC_ASSERT_EQUAL(
		linphone_account_creator_activate_account(creator),
1108 1109
		LinphoneAccountCreatorStatusMissingCallbacks,
		LinphoneAccountCreatorStatus,
1110 1111 1112 1113 1114 1115 1116 1117
		"%i");

	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

static void server_activate_account_with_email_activated_arg_username_missing(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
1118
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
1119
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
1120 1121 1122 1123 1124
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

	linphone_account_creator_set_activation_code(creator, "123456789");
	linphone_account_creator_set_email(creator, "user_1@linphone.org");

1125 1126 1127 1128 1129
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusMissingArguments);
	linphone_account_creator_cbs_set_activate_account(cbs, account_creator_cb);
1130 1131 1132
	linphone_account_creator_service_set_activate_account_cb(
		linphone_account_creator_get_service(creator),
		linphone_account_creator_activate_email_account_linphone);
1133 1134 1135

	BC_ASSERT_EQUAL(
		linphone_account_creator_activate_account(creator),
1136 1137
		LinphoneAccountCreatorStatusMissingArguments,
		LinphoneAccountCreatorStatus,
1138 1139 1140 1141 1142 1143 1144 1145 1146
		"%i");

	ms_free(stats);
	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

static void server_activate_account_with_email_activated_arg_activation_code_missing(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
1147
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
1148
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
1149 1150 1151 1152 1153
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

	linphone_account_creator_set_username(creator, "user_exist");
	linphone_account_creator_set_email(creator, "user_1@linphone.org");

1154 1155 1156 1157 1158
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusMissingArguments);
	linphone_account_creator_cbs_set_activate_account(cbs, account_creator_cb);
1159 1160 1161
	linphone_account_creator_service_set_activate_account_cb(
		linphone_account_creator_get_service(creator),
		linphone_account_creator_activate_email_account_linphone);
1162 1163 1164

	BC_ASSERT_EQUAL(
		linphone_account_creator_activate_account(creator),
1165 1166
		LinphoneAccountCreatorStatusMissingArguments,
		LinphoneAccountCreatorStatus,
1167 1168 1169 1170 1171 1172 1173 1174 1175
		"%i");

	ms_free(stats);
	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

static void server_activate_account_with_phone_number_activated_arg_username_missing(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
1176
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
1177
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
1178 1179 1180 1181 1182
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

	linphone_account_creator_set_activation_code(creator, "123456789");
	linphone_account_creator_set_phone_number(creator, "0123456", "33");

1183 1184 1185 1186 1187
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusMissingArguments);
	linphone_account_creator_cbs_set_activate_account(cbs, account_creator_cb);
1188 1189 1190

	BC_ASSERT_EQUAL(
		linphone_account_creator_activate_account(creator),
1191 1192
		LinphoneAccountCreatorStatusMissingArguments,
		LinphoneAccountCreatorStatus,
1193 1194 1195 1196 1197 1198 1199 1200 1201
		"%i");

	ms_free(stats);
	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

static void server_activate_account_with_phone_number_activated_arg_activation_code_missing(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
1202
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
1203
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
1204 1205 1206 1207 1208
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

	linphone_account_creator_set_username(creator, "user_exist");
	linphone_account_creator_set_phone_number(creator, "0123456", "33");

1209 1210 1211 1212 1213
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusMissingArguments);
	linphone_account_creator_cbs_set_activate_account(cbs, account_creator_cb);
1214 1215 1216

	BC_ASSERT_EQUAL(
		linphone_account_creator_activate_account(creator),
1217 1218
		LinphoneAccountCreatorStatusMissingArguments,
		LinphoneAccountCreatorStatus,
1219 1220 1221 1222 1223 1224 1225 1226 1227
		"%i");

	ms_free(stats);
	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}
/****************** End Activate Account ************************/

/****************** Start Link Account ************************/
1228
static void server_link_account_with_phone_number(void) {
1229
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
1230
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
1231
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
1232 1233
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

1234 1235
	linphone_account_creator_set_username(creator, "XXXTESTuser_1");
	linphone_account_creator_set_phone_number(creator, "000555456", "1");
1236

1237 1238 1239 1240 1241
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusRequestOk);
	linphone_account_creator_cbs_set_link_account(cbs, account_creator_cb);
1242 1243 1244

	BC_ASSERT_EQUAL(
		linphone_account_creator_link_account(creator),
1245 1246
		LinphoneAccountCreatorStatusRequestOk,
		LinphoneAccountCreatorStatus,
1247 1248 1249 1250 1251 1252 1253 1254 1255
		"%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);
}

1256
static void server_link_non_existent_account_with_phone_number(void) {
1257
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
1258
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
1259
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
1260 1261 1262 1263 1264
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

	linphone_account_creator_set_username(creator, "unknown_user");
	linphone_account_creator_set_phone_number(creator, "012345678", "33");

1265 1266 1267 1268 1269
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusAccountNotLinked);
	linphone_account_creator_cbs_set_link_account(cbs, account_creator_cb);
1270 1271 1272

	BC_ASSERT_EQUAL(
		linphone_account_creator_link_account(creator),
1273 1274
		LinphoneAccountCreatorStatusRequestOk,
		LinphoneAccountCreatorStatus,
1275 1276 1277 1278 1279 1280 1281 1282 1283
		"%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);
}

1284 1285
static void server_link_account_cb_missing(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
1286
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
1287 1288 1289 1290 1291 1292

	linphone_account_creator_set_username(creator, "user_exist");
	linphone_account_creator_set_phone_number(creator, "0123456", "33");

	BC_ASSERT_EQUAL(
		linphone_account_creator_link_account(creator),
1293 1294
		LinphoneAccountCreatorStatusMissingCallbacks,
		LinphoneAccountCreatorStatus,
1295 1296 1297 1298 1299 1300 1301 1302
		"%i");

	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

static void server_link_account_arg_username_missing(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
1303
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
1304
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
1305 1306 1307 1308
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

	linphone_account_creator_set_phone_number(creator, "0123456", "33");

1309 1310 1311 1312 1313
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusMissingArguments);
	linphone_account_creator_cbs_set_link_account(cbs, account_creator_cb);
1314 1315 1316

	BC_ASSERT_EQUAL(
		linphone_account_creator_link_account(creator),
1317 1318
		LinphoneAccountCreatorStatusMissingArguments,
		LinphoneAccountCreatorStatus,
1319 1320 1321 1322 1323 1324 1325 1326 1327
		"%i");

	ms_free(stats);
	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}

static void server_link_account_arg_phone_number_missing(void) {
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
1328
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
1329
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
1330 1331 1332 1333
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

	linphone_account_creator_set_username(creator, "user_exist");

1334 1335 1336 1337 1338
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusMissingArguments);
	linphone_account_creator_cbs_set_link_account(cbs, account_creator_cb);
1339 1340 1341

	BC_ASSERT_EQUAL(
		linphone_account_creator_link_account(creator),
1342 1343
		LinphoneAccountCreatorStatusMissingArguments,
		LinphoneAccountCreatorStatus,
1344 1345 1346 1347 1348 1349 1350 1351 1352
		"%i");

	ms_free(stats);
	linphone_account_creator_unref(creator);
	linphone_core_manager_destroy(marie);
}
/****************** End Link Account ************************/

/****************** Start Activate Alias ************************/
1353
static void server_activate_phone_number_for_non_existent_account(void) {
1354
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
1355
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
1356
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
1357 1358
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

1359
	linphone_account_creator_set_username(creator, "unknown_user");
1360 1361 1362 1363
	linphone_account_creator_set_phone_number(creator, "012345678", "33");
	linphone_account_creator_set_activation_code(creator, "12345679");
	linphone_account_creator_set_password(creator, "password");

1364 1365 1366 1367 1368
	linphone_account_creator_cbs_set_user_data(cbs, stats);
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusAccountNotActivated);
	linphone_account_creator_cbs_set_activate_alias(cbs, account_creator_cb);
1369 1370 1371

	BC_ASSERT_EQUAL(
		linphone_account_creator_activate_alias(creator),
1372 1373
		LinphoneAccountCreatorStatusRequestOk,
		LinphoneAccountCreatorStatus,
1374 1375 1376 1377 1378 1379 1380 1381 1382
		"%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);
}

1383
static void server_activate_phone_number_for_account(void) {
1384
	LinphoneCoreManager *marie = linphone_core_manager_new2("account_creator_rc", 0);
1385
	LinphoneAccountCreator *creator = _linphone_account_creator_new(marie->lc, XMLRPC_URL);
1386
	LinphoneAccountCreatorCbs *cbs = linphone_account_creator_get_callbacks(creator);
1387 1388
	LinphoneAccountCreatorStats *stats = new_linphone_account_creator_stats();

1389
	linphone_account_creator_cbs_set_user_data(cbs, stats);
1390 1391 1392 1393 1394
	linphone_account_creator_set_username(creator, "XXXTESTuser_1");
	linphone_account_creator_set_phone_number(creator, "000555456", "1");
	linphone_account_creator_set_password(creator, "password");
	linphone_account_creator_set_email(creator, "user_1@linphone.org");
	get_activation_code(creator, &stats->cb_done);
1395
	account_creator_reset_cb_done(creator->cbs);
1396

1397 1398 1399 1400
	linphone_account_creator_service_set_user_data(
		linphone_account_creator_get_service(creator),
		(void*)LinphoneAccountCreatorStatusAccountActivated);
	linphone_account_creator_cbs_set_activate_alias(cbs, account_creator_cb);
1401 1402 1403

	BC_ASSERT_EQUAL(
		linphone_account_creator_activate_alias(creator),
1404 1405
		LinphoneAccountCreatorStatusRequestOk,
		LinphoneAccountCreatorStatus,
1406 1407 1408 1409 1410 1411 1412 1413 1414
		"%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);
}