register_tester.c 34 KB
Newer Older
jehan's avatar
jehan committed
1 2 3 4 5 6
/*
	belle-sip - SIP (RFC3261) library.
    Copyright (C) 2010  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
Simon Morlat's avatar
Simon Morlat committed
7
    the Free Software Foundation, either version 2 of the License, or
jehan's avatar
jehan committed
8 9 10 11 12 13 14 15 16 17
    (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/>.
*/
Ghislain MARY's avatar
Ghislain MARY committed
18

jehan's avatar
jehan committed
19 20 21 22 23 24
#include <stdio.h>
#include "CUnit/Basic.h"
#include "linphonecore.h"
#include "private.h"
#include "liblinphone_tester.h"

25 26 27 28 29 30 31 32 33 34


static void auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain) {
	LinphoneAuthInfo *info;
	info=linphone_auth_info_new(test_username,NULL,test_password,NULL,realm,domain); /*create authentication structure from identity*/
	linphone_core_add_auth_info(lc,info); /*add authentication info to LinphoneCore*/
}



35
static LinphoneCoreManager* create_lcm_with_auth(unsigned int with_auth) {
Simon Morlat's avatar
Simon Morlat committed
36
	LinphoneCoreManager* mgr=linphone_core_manager_new(NULL);
37

38
	if (with_auth) {
39
		LinphoneCoreVTable* vtable = linphone_core_v_table_new();
40 41
		vtable->auth_info_requested=auth_info_requested;
		linphone_core_add_listener(mgr->lc,vtable);
42
	}
43

44 45 46 47
	/*to allow testing with 127.0.0.1*/
	linphone_core_set_network_reachable(mgr->lc,TRUE);
	return mgr;
}
jehan's avatar
jehan committed
48

49 50
static LinphoneCoreManager* create_lcm() {
	return create_lcm_with_auth(0);
jehan's avatar
jehan committed
51 52 53
}

void registration_state_changed(struct _LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message){
54
		stats* counters;
jehan's avatar
jehan committed
55 56 57 58
		ms_message("New registration state %s for user id [%s] at proxy [%s]\n"
				,linphone_registration_state_to_string(cstate)
				,linphone_proxy_config_get_identity(cfg)
				,linphone_proxy_config_get_addr(cfg));
59
		counters = get_stats(lc);
jehan's avatar
jehan committed
60 61 62 63 64 65 66 67 68 69 70
		switch (cstate) {
		case LinphoneRegistrationNone:counters->number_of_LinphoneRegistrationNone++;break;
		case LinphoneRegistrationProgress:counters->number_of_LinphoneRegistrationProgress++;break;
		case LinphoneRegistrationOk:counters->number_of_LinphoneRegistrationOk++;break;
		case LinphoneRegistrationCleared:counters->number_of_LinphoneRegistrationCleared++;break;
		case LinphoneRegistrationFailed:counters->number_of_LinphoneRegistrationFailed++;break;
		default:
			CU_FAIL("unexpected event");break;
		}

}
Ghislain MARY's avatar
Ghislain MARY committed
71

72 73 74 75 76 77 78
static void register_with_refresh_base_3(LinphoneCore* lc
											, bool_t refresh
											,const char* domain
											,const char* route
											,bool_t late_auth_info
											,LCSipTransports transport
											,LinphoneRegistrationState expected_final_state) {
jehan's avatar
jehan committed
79
	int retry=0;
Simon Morlat's avatar
Simon Morlat committed
80
	char* addr;
81 82 83 84 85 86
	LinphoneProxyConfig* proxy_cfg;
	stats* counters;
	LinphoneAddress *from;
	const char* server_addr;
	LinphoneAuthInfo *info;

jehan's avatar
jehan committed
87 88
	CU_ASSERT_PTR_NOT_NULL(lc);
	if (!lc) return;
89
	counters = get_stats(lc);
jehan's avatar
jehan committed
90 91 92 93 94
	reset_counters(counters);
	linphone_core_set_sip_transports(lc,&transport);

	proxy_cfg = linphone_proxy_config_new();

95
	from = create_linphone_address(domain);
jehan's avatar
jehan committed
96

97 98
	linphone_proxy_config_set_identity(proxy_cfg,addr=linphone_address_as_string(from));
	ms_free(addr);
99
	server_addr = linphone_address_get_domain(from);
jehan's avatar
jehan committed
100 101

	linphone_proxy_config_enable_register(proxy_cfg,TRUE);
102
	linphone_proxy_config_set_expires(proxy_cfg,1);
jehan's avatar
jehan committed
103 104 105 106 107 108 109 110 111 112 113
	if (route) {
		linphone_proxy_config_set_route(proxy_cfg,route);
		linphone_proxy_config_set_server_addr(proxy_cfg,route);
	} else {
		linphone_proxy_config_set_server_addr(proxy_cfg,server_addr);
	}
	linphone_address_destroy(from);

	linphone_core_add_proxy_config(lc,proxy_cfg);
	linphone_core_set_default_proxy(lc,proxy_cfg);

114 115
	while (counters->number_of_LinphoneRegistrationOk<1+(refresh!=0)
			&& retry++ <(110 /*only wait 11 s if final state is progress*/+(expected_final_state==LinphoneRegistrationProgress?0:200))) {
jehan's avatar
jehan committed
116
		linphone_core_iterate(lc);
jehan's avatar
jehan committed
117
		if (counters->number_of_auth_info_requested>0 && linphone_proxy_config_get_state(proxy_cfg) == LinphoneRegistrationFailed && late_auth_info) {
118
			if (!linphone_core_get_auth_info_list(lc)) {
jehan's avatar
jehan committed
119
				CU_ASSERT_EQUAL(linphone_proxy_config_get_error(proxy_cfg),LinphoneReasonUnauthorized);
120
				info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain,NULL); /*create authentication structure from identity*/
121 122
				linphone_core_add_auth_info(lc,info); /*add authentication info to LinphoneCore*/
			}
jehan's avatar
jehan committed
123
		}
124 125
		if (linphone_proxy_config_get_error(proxy_cfg) == LinphoneReasonBadCredentials
				|| (counters->number_of_auth_info_requested>2 &&linphone_proxy_config_get_error(proxy_cfg) == LinphoneReasonUnauthorized)) /*no need to continue if auth cannot be found*/
126
			break; /*no need to continue*/
jehan's avatar
jehan committed
127 128
		ms_usleep(100000);
	}
129
	CU_ASSERT_EQUAL(linphone_proxy_config_is_registered(proxy_cfg),(expected_final_state == LinphoneRegistrationOk));
jehan's avatar
jehan committed
130
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationNone,0);
131 132 133 134 135 136
	CU_ASSERT_TRUE(counters->number_of_LinphoneRegistrationProgress>=1);
	if (expected_final_state == LinphoneRegistrationOk) {
		CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationOk,1+(refresh!=0));
		CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,late_auth_info?1:0);
	} else
		/*checking to be done outside this functions*/
jehan's avatar
jehan committed
137 138 139
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationCleared,0);

}
Ghislain MARY's avatar
Ghislain MARY committed
140

141 142 143 144 145 146 147 148
static void register_with_refresh_base_2(LinphoneCore* lc
											, bool_t refresh
											,const char* domain
											,const char* route
											,bool_t late_auth_info
											,LCSipTransports transport) {
	register_with_refresh_base_3(lc, refresh, domain, route, late_auth_info, transport,LinphoneRegistrationOk );
}
jehan's avatar
jehan committed
149
static void register_with_refresh_base(LinphoneCore* lc, bool_t refresh,const char* domain,const char* route) {
150 151
	LCSipTransports transport = {5070,5070,0,5071};
	register_with_refresh_base_2(lc,refresh,domain,route,FALSE,transport);
jehan's avatar
jehan committed
152
}
Ghislain MARY's avatar
Ghislain MARY committed
153

154 155 156 157
static void register_with_refresh(LinphoneCoreManager* lcm, bool_t refresh,const char* domain,const char* route) {
	stats* counters = &lcm->stat;
	register_with_refresh_base(lcm->lc,refresh,domain,route);
	linphone_core_manager_stop(lcm);
jehan's avatar
jehan committed
158 159 160
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationCleared,1);
}

161
static void register_with_refresh_with_send_error() {
jehan's avatar
jehan committed
162
	int retry=0;
163 164
	LinphoneCoreManager* lcm = create_lcm_with_auth(1);
	stats* counters = &lcm->stat;
165
	LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain,NULL); /*create authentication structure from identity*/
166 167
	char route[256];
	sprintf(route,"sip:%s",test_route);
168
	linphone_core_add_auth_info(lcm->lc,info); /*add authentication info to LinphoneCore*/
jehan's avatar
jehan committed
169

170
	register_with_refresh_base(lcm->lc,TRUE,auth_domain,route);
jehan's avatar
jehan committed
171
	/*simultate a network error*/
172
	sal_set_send_error(lcm->lc->sal, -1);
173
	while (counters->number_of_LinphoneRegistrationProgress<2 && retry++ <20) {
174
			linphone_core_iterate(lcm->lc);
jehan's avatar
jehan committed
175 176
			ms_usleep(100000);
	}
177 178
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0);
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationProgress,2);
jehan's avatar
jehan committed
179 180 181

	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationCleared,0);

182
	linphone_core_manager_destroy(lcm);
jehan's avatar
jehan committed
183
}
Ghislain MARY's avatar
Ghislain MARY committed
184

jehan's avatar
jehan committed
185
static void simple_register(){
186 187 188
	LinphoneCoreManager* lcm = create_lcm();
	stats* counters = &lcm->stat;
	register_with_refresh(lcm,FALSE,NULL,NULL);
jehan's avatar
jehan committed
189
	CU_ASSERT_EQUAL(counters->number_of_auth_info_requested,0);
190
	linphone_core_manager_destroy(lcm);
jehan's avatar
jehan committed
191 192
}

193 194 195 196 197
static void register_with_custom_headers(void){
	LinphoneCoreManager *marie=linphone_core_manager_new("marie_rc");
	LinphoneProxyConfig *cfg=linphone_core_get_default_proxy_config(marie->lc);
	int initial_register_ok=marie->stat.number_of_LinphoneRegistrationOk;
	const char *value;
198

199 200 201 202
	linphone_core_set_network_reachable(marie->lc, FALSE);
	linphone_proxy_config_set_custom_header(cfg, "ah-bah-ouais", "...mais bon.");
	/*unfortunately it is difficult to programmatically check that sent custom headers are actually sent.
	 * A server development would be required here.*/
203

204 205 206 207 208 209 210 211
	linphone_core_set_network_reachable(marie->lc, TRUE);
	wait_for(marie->lc, NULL, &marie->stat.number_of_LinphoneRegistrationOk,initial_register_ok+1);
	value=linphone_proxy_config_get_custom_header(cfg, "Server");
	CU_ASSERT_PTR_NOT_NULL(value);
	if (value) CU_ASSERT_TRUE(strstr(value, "Flexisip")!=NULL);
	linphone_core_manager_destroy(marie);
}

212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
static void simple_unregister(){
	LinphoneCoreManager* lcm = create_lcm();
	stats* counters = &lcm->stat;
	LinphoneProxyConfig* proxy_config;
	register_with_refresh_base(lcm->lc,FALSE,NULL,NULL);

	linphone_core_get_default_proxy(lcm->lc,&proxy_config);

	linphone_proxy_config_edit(proxy_config);
	reset_counters(counters); /*clear stats*/

	/*nothing is supposed to arrive until done*/
	CU_ASSERT_FALSE(wait_for_until(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationCleared,1,3000));
	linphone_proxy_config_enable_register(proxy_config,FALSE);
	linphone_proxy_config_done(proxy_config);
	CU_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationCleared,1));
	linphone_core_manager_destroy(lcm);
}

static void change_expires(){
	LinphoneCoreManager* lcm = create_lcm();
	stats* counters = &lcm->stat;
	LinphoneProxyConfig* proxy_config;
	register_with_refresh_base(lcm->lc,FALSE,NULL,NULL);

	linphone_core_get_default_proxy(lcm->lc,&proxy_config);

	linphone_proxy_config_edit(proxy_config);
	reset_counters(counters); /*clear stats*/

	/*nothing is supposed to arrive until done*/
	CU_ASSERT_FALSE(wait_for_until(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationCleared,1,3000));

	linphone_proxy_config_set_expires(proxy_config,3);

	linphone_proxy_config_done(proxy_config);
	CU_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,1));
	/*wait 2s without receive refresh*/
	CU_ASSERT_FALSE(wait_for_until(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,2,2000));
	/* now, it should be ok*/
	CU_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,2));


	linphone_core_manager_destroy(lcm);
}

jehan's avatar
jehan committed
258 259
/*take care of min expires configuration from server*/
static void simple_register_with_refresh() {
260 261 262
	LinphoneCoreManager* lcm = create_lcm();
	stats* counters = &lcm->stat;
	register_with_refresh(lcm,TRUE,NULL,NULL);
jehan's avatar
jehan committed
263
	CU_ASSERT_EQUAL(counters->number_of_auth_info_requested,0);
264
	linphone_core_manager_destroy(lcm);
jehan's avatar
jehan committed
265 266 267
}

static void simple_auth_register_with_refresh() {
268 269
	LinphoneCoreManager* lcm = create_lcm_with_auth(1);
	stats* counters = &lcm->stat;
270 271
	char route[256];
	sprintf(route,"sip:%s",test_route);
272
	register_with_refresh(lcm,TRUE,auth_domain,route);
jehan's avatar
jehan committed
273
	CU_ASSERT_EQUAL(counters->number_of_auth_info_requested,1);
274
	linphone_core_manager_destroy(lcm);
jehan's avatar
jehan committed
275 276 277 278
}

static void simple_tcp_register(){
	char route[256];
279
	LinphoneCoreManager* lcm;
280
	sprintf(route,"sip:%s;transport=tcp",test_route);
281 282 283
	lcm = create_lcm();
	register_with_refresh(lcm,FALSE,test_domain,route);
	linphone_core_manager_destroy(lcm);
jehan's avatar
jehan committed
284
}
Ghislain MARY's avatar
Ghislain MARY committed
285

286
static void simple_tcp_register_compatibility_mode(){
287
	char route[256];
288
	LinphoneCoreManager* lcm;
289
	LCSipTransports transport = {0,5070,0,0};
290
	sprintf(route,"sip:%s",test_route);
291 292 293
	lcm = create_lcm();
	register_with_refresh_base_2(lcm->lc,FALSE,test_domain,route,FALSE,transport);
	linphone_core_manager_destroy(lcm);
294 295 296
}


jehan's avatar
jehan committed
297 298
static void simple_tls_register(){
	char route[256];
299
	LinphoneCoreManager* lcm;
300
	sprintf(route,"sip:%s;transport=tls",test_route);
301 302 303
	lcm = create_lcm();
	register_with_refresh(lcm,FALSE,test_domain,route);
	linphone_core_manager_destroy(lcm);
jehan's avatar
jehan committed
304 305
}

306

jehan's avatar
jehan committed
307
static void simple_authenticated_register(){
308
	stats* counters;
309
	LinphoneCoreManager* lcm = create_lcm();
310
	LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain,NULL); /*create authentication structure from identity*/
311 312
	char route[256];
	sprintf(route,"sip:%s",test_route);
313 314 315
	linphone_core_add_auth_info(lcm->lc,info); /*add authentication info to LinphoneCore*/
	counters = &lcm->stat;
	register_with_refresh(lcm,FALSE,auth_domain,route);
jehan's avatar
jehan committed
316 317 318
	CU_ASSERT_EQUAL(counters->number_of_auth_info_requested,0);
}

319 320
static void ha1_authenticated_register(){
	stats* counters;
321
	LinphoneCoreManager* lcm = create_lcm();
322 323 324 325
	char ha1[33];
	LinphoneAuthInfo *info;
	char route[256];
	sal_auth_compute_ha1(test_username,auth_domain,test_password,ha1);
326
	info=linphone_auth_info_new(test_username,NULL,NULL,ha1,auth_domain,NULL); /*create authentication structure from identity*/
327
	sprintf(route,"sip:%s",test_route);
328 329 330
	linphone_core_add_auth_info(lcm->lc,info); /*add authentication info to LinphoneCore*/
	counters = &lcm->stat;
	register_with_refresh(lcm,FALSE,auth_domain,route);
331 332 333
	CU_ASSERT_EQUAL(counters->number_of_auth_info_requested,0);
}

jehan's avatar
jehan committed
334
static void authenticated_register_with_no_initial_credentials(){
335
	LinphoneCoreManager *mgr;
336
	LinphoneCoreVTable* vtable = linphone_core_v_table_new();
337
	stats* counters;
338
	char route[256];
339

340
	sprintf(route,"sip:%s",test_route);
341

Simon Morlat's avatar
Simon Morlat committed
342
	mgr = linphone_core_manager_new(NULL);
343

344 345
	vtable->auth_info_requested=auth_info_requested;
	linphone_core_add_listener(mgr->lc,vtable);
346

347
	counters= get_stats(mgr->lc);
jehan's avatar
jehan committed
348
	counters->number_of_auth_info_requested=0;
349
	register_with_refresh(mgr,FALSE,auth_domain,route);
jehan's avatar
jehan committed
350
	CU_ASSERT_EQUAL(counters->number_of_auth_info_requested,1);
351
	linphone_core_manager_destroy(mgr);
jehan's avatar
jehan committed
352
}
Ghislain MARY's avatar
Ghislain MARY committed
353

jehan's avatar
jehan committed
354 355

static void authenticated_register_with_late_credentials(){
356
	LinphoneCoreManager *mgr;
357
	stats* counters;
358
	LCSipTransports transport = {5070,5070,0,5071};
359
	char route[256];
360

361
	sprintf(route,"sip:%s",test_route);
362

Simon Morlat's avatar
Simon Morlat committed
363
	mgr =  linphone_core_manager_new(NULL);
364

365 366
	counters = get_stats(mgr->lc);
	register_with_refresh_base_2(mgr->lc,FALSE,auth_domain,route,TRUE,transport);
367
	CU_ASSERT_EQUAL(counters->number_of_auth_info_requested,1);
368
	linphone_core_manager_destroy(mgr);
jehan's avatar
jehan committed
369
}
jehan's avatar
jehan committed
370

371 372 373 374 375 376
static void authenticated_register_with_wrong_late_credentials(){
	LinphoneCoreManager *mgr;
	stats* counters;
	LCSipTransports transport = {5070,5070,0,5071};
	char route[256];
	const char* saved_test_passwd=test_password;
377
	char* wrong_passwd="mot de pass tout pourri";
378 379 380 381 382 383

	test_password=wrong_passwd;

	sprintf(route,"sip:%s",test_route);

	mgr =  linphone_core_manager_new(NULL);
384

385 386
	counters = get_stats(mgr->lc);
	register_with_refresh_base_3(mgr->lc,FALSE,auth_domain,route,TRUE,transport,LinphoneRegistrationFailed);
387
	CU_ASSERT_EQUAL(counters->number_of_auth_info_requested,2);
388 389 390 391 392 393 394
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,2);
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationProgress,2);
	test_password=saved_test_passwd;

	linphone_core_manager_destroy(mgr);
}

395
static void authenticated_register_with_wrong_credentials_with_params_base(const char* user_agent,LinphoneCoreManager *mgr) {
jehan's avatar
jehan committed
396 397
	stats* counters;
	LCSipTransports transport = {5070,5070,0,5071};
398
	LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,"wrong passwd",NULL,auth_domain,NULL); /*create authentication structure from identity*/
jehan's avatar
jehan committed
399
	char route[256];
400

jehan's avatar
jehan committed
401
	sprintf(route,"sip:%s",test_route);
402

403 404 405 406
	sal_set_refresher_retry_after(mgr->lc->sal,500);
	if (user_agent) {
		linphone_core_set_user_agent(mgr->lc,user_agent,NULL);
	}
407 408
	linphone_core_add_auth_info(mgr->lc,info); /*add wrong authentication info to LinphoneCore*/
	counters = get_stats(mgr->lc);
409 410 411 412 413
	register_with_refresh_base_3(mgr->lc,TRUE,auth_domain,route,FALSE,transport,LinphoneRegistrationFailed);
	//CU_ASSERT_EQUAL(counters->number_of_auth_info_requested,3); register_with_refresh_base_3 does not alow to precisely check number of number_of_auth_info_requested
	/*wait for retry*/
	CU_ASSERT_TRUE(wait_for(mgr->lc,mgr->lc,&counters->number_of_auth_info_requested,4));
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,1);
414

415 416 417 418 419 420 421 422 423 424 425 426 427
	/*check the detailed error info */
	if (!user_agent || strcmp(user_agent,"tester-no-403")!=0){
		LinphoneProxyConfig *cfg=NULL;
		linphone_core_get_default_proxy(mgr->lc,&cfg);
		CU_ASSERT_PTR_NOT_NULL(cfg);
		if (cfg){
			const LinphoneErrorInfo *ei=linphone_proxy_config_get_error_info(cfg);
			const char *phrase=linphone_error_info_get_phrase(ei);
			CU_ASSERT_PTR_NOT_NULL(phrase);
			if (phrase) CU_ASSERT_TRUE(strcmp(phrase,"Forbidden")==0);
			CU_ASSERT_EQUAL(linphone_error_info_get_protocol_code(ei),403);
			CU_ASSERT_PTR_NULL(linphone_error_info_get_details(ei));
		}
428

429
	}
430 431 432 433
	}
static void authenticated_register_with_wrong_credentials_with_params(const char* user_agent) {
	LinphoneCoreManager *mgr = linphone_core_manager_new(NULL);
	authenticated_register_with_wrong_credentials_with_params_base(user_agent,mgr);
434
	linphone_core_manager_destroy(mgr);
jehan's avatar
jehan committed
435
}
436 437 438
static void authenticated_register_with_wrong_credentials() {
	authenticated_register_with_wrong_credentials_with_params(NULL);
}
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456
static void authenticated_register_with_wrong_credentials_2() {
	LinphoneCoreManager *mgr = linphone_core_manager_new(NULL);
	stats* counters = get_stats(mgr->lc);
	int current_in_progress;
	LinphoneProxyConfig* proxy;

	authenticated_register_with_wrong_credentials_with_params_base(NULL,mgr);

	linphone_core_get_default_proxy(mgr->lc,&proxy);
	/*Make sure registration attempts are stopped*/
	linphone_proxy_config_edit(proxy);
	linphone_proxy_config_enable_register(proxy,FALSE);
	linphone_proxy_config_done(proxy);
	current_in_progress=counters->number_of_LinphoneRegistrationProgress;
	CU_ASSERT_FALSE(wait_for(mgr->lc,mgr->lc,&counters->number_of_LinphoneRegistrationProgress,current_in_progress+1));

	linphone_core_manager_destroy(mgr);
}
457 458 459
static void authenticated_register_with_wrong_credentials_without_403() {
	authenticated_register_with_wrong_credentials_with_params("tester-no-403");
}
460
static LinphoneCoreManager* configure_lcm(void) {
461
	LinphoneCoreManager *mgr=linphone_core_manager_new( "multi_account_rc");
462 463
	stats *counters=&mgr->stat;
	CU_ASSERT_TRUE(wait_for(mgr->lc,mgr->lc,&counters->number_of_LinphoneRegistrationOk,ms_list_size(linphone_core_get_proxy_config_list(mgr->lc))));
464
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0);
465
	return mgr;
jehan's avatar
jehan committed
466 467 468
}

static void multiple_proxy(){
469 470
	LinphoneCoreManager *mgr=configure_lcm();
	linphone_core_manager_destroy(mgr);
jehan's avatar
jehan committed
471 472
}

jehan's avatar
jehan committed
473 474
static void network_state_change(){
	int register_ok;
475 476 477
	stats *counters;
	LinphoneCoreManager *mgr=configure_lcm();
	LinphoneCore *lc=mgr->lc;
478

479
	counters = get_stats(lc);
jehan's avatar
jehan committed
480 481
	register_ok=counters->number_of_LinphoneRegistrationOk;
	linphone_core_set_network_reachable(lc,FALSE);
482
	CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_NetworkReachableFalse,1));
jehan's avatar
jehan committed
483
	CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationNone,register_ok));
jehan's avatar
jehan committed
484
	linphone_core_set_network_reachable(lc,TRUE);
485
	CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_NetworkReachableTrue,1));
jehan's avatar
jehan committed
486
	wait_for(lc,lc,&counters->number_of_LinphoneRegistrationOk,2*register_ok);
487

488
	linphone_core_manager_destroy(mgr);
jehan's avatar
jehan committed
489
}
jehan's avatar
jehan committed
490 491 492 493 494 495 496 497 498 499 500
static int get_number_of_udp_proxy(const LinphoneCore* lc) {
	int number_of_udp_proxy=0;
	LinphoneProxyConfig* proxy_cfg;
	MSList* proxys;
	for (proxys=(MSList*)linphone_core_get_proxy_config_list(lc);proxys!=NULL;proxys=proxys->next) {
			proxy_cfg=(LinphoneProxyConfig*)proxys->data;
			if (strcmp("udp",linphone_proxy_config_get_transport(proxy_cfg))==0)
				number_of_udp_proxy++;
	}
	return number_of_udp_proxy;
}
501
static void transport_change(){
502
	LinphoneCoreManager *mgr;
503 504 505 506 507
	LinphoneCore* lc;
	int register_ok;
	stats* counters ;
	LCSipTransports sip_tr;
	LCSipTransports sip_tr_orig;
jehan's avatar
jehan committed
508
	int number_of_udp_proxy=0;
jehan's avatar
jehan committed
509
	int total_number_of_proxies;
jehan's avatar
jehan committed
510
	memset(&sip_tr,0,sizeof(sip_tr));
511

512 513
	mgr=configure_lcm();
	lc=mgr->lc;
514
	counters = get_stats(lc);
515
	register_ok=counters->number_of_LinphoneRegistrationOk;
jehan's avatar
jehan committed
516 517

	number_of_udp_proxy=get_number_of_udp_proxy(lc);
jehan's avatar
jehan committed
518
	total_number_of_proxies=ms_list_size(linphone_core_get_proxy_config_list(lc));
519
	linphone_core_get_sip_transports(lc,&sip_tr_orig);
jehan's avatar
jehan committed
520

521 522 523 524
	sip_tr.udp_port=sip_tr_orig.udp_port;

	/*keep only udp*/
	linphone_core_set_sip_transports(lc,&sip_tr);
jehan's avatar
jehan committed
525
	CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationOk,register_ok+number_of_udp_proxy));
526

527
	CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationFailed,total_number_of_proxies-number_of_udp_proxy));
528

529
	linphone_core_manager_destroy(mgr);
530 531
}

532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626
static void proxy_transport_change(){
	LinphoneCoreManager* lcm = create_lcm();
	stats* counters = &lcm->stat;
	LinphoneProxyConfig* proxy_config;
	LinphoneAddress* addr;
	char* addr_as_string;
	LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain,NULL); /*create authentication structure from identity*/
	linphone_core_add_auth_info(lcm->lc,info); /*add authentication info to LinphoneCore*/

	register_with_refresh_base(lcm->lc,FALSE,auth_domain,NULL);

	linphone_core_get_default_proxy(lcm->lc,&proxy_config);
	reset_counters(counters); /*clear stats*/
	linphone_proxy_config_edit(proxy_config);

	CU_ASSERT_FALSE(wait_for_until(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationCleared,1,3000));
	addr = linphone_address_new(linphone_proxy_config_get_addr(proxy_config));

	if (LinphoneTransportTcp == linphone_address_get_transport(addr)) {
		linphone_address_set_transport(addr,LinphoneTransportUdp);
	} else {
		linphone_address_set_transport(addr,LinphoneTransportTcp);
	}
	linphone_proxy_config_set_server_addr(proxy_config,addr_as_string=linphone_address_as_string(addr));

	linphone_proxy_config_done(proxy_config);

	CU_ASSERT(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,1));
	/*as we change p[roxy server destination, we should'nt be notified about the clear*/
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationCleared,0);
	ms_free(addr_as_string);
	linphone_address_destroy(addr);
	linphone_core_manager_destroy(lcm);

}
static void proxy_transport_change_with_wrong_port() {
	LinphoneCoreManager* lcm = create_lcm();
	stats* counters = &lcm->stat;
	LinphoneProxyConfig* proxy_config;
	LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain,NULL); /*create authentication structure from identity*/
	char route[256];
	LCSipTransports transport= {LC_SIP_TRANSPORT_RANDOM,LC_SIP_TRANSPORT_RANDOM,LC_SIP_TRANSPORT_RANDOM,LC_SIP_TRANSPORT_RANDOM};
	sprintf(route,"sip:%s",test_route);

	linphone_core_add_auth_info(lcm->lc,info); /*add authentication info to LinphoneCore*/

	register_with_refresh_base_3(lcm->lc, FALSE, auth_domain, "sip2.linphone.org:5987", 0,transport,LinphoneRegistrationProgress);

	linphone_core_get_default_proxy(lcm->lc,&proxy_config);
	linphone_proxy_config_edit(proxy_config);

	CU_ASSERT_FALSE(wait_for_until(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationCleared,1,3000));
	linphone_proxy_config_set_server_addr(proxy_config,route);
	linphone_proxy_config_done(proxy_config);

	CU_ASSERT(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,1));
	/*as we change proxy server destination, we should'nt be notified about the clear*/
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationCleared,0);
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationOk,1);
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationProgress,1);
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0);

	linphone_core_manager_destroy(lcm);

}

static void proxy_transport_change_with_wrong_port_givin_up() {
	LinphoneCoreManager* lcm = create_lcm();
	stats* counters = &lcm->stat;
	LinphoneProxyConfig* proxy_config;
	LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain,NULL); /*create authentication structure from identity*/
	char route[256];
	LCSipTransports transport= {LC_SIP_TRANSPORT_RANDOM,LC_SIP_TRANSPORT_RANDOM,LC_SIP_TRANSPORT_RANDOM,LC_SIP_TRANSPORT_RANDOM};
	sprintf(route,"sip:%s",test_route);

	linphone_core_add_auth_info(lcm->lc,info); /*add authentication info to LinphoneCore*/

	register_with_refresh_base_3(lcm->lc, FALSE, auth_domain, "sip2.linphone.org:5987", 0,transport,LinphoneRegistrationProgress);

	linphone_core_get_default_proxy(lcm->lc,&proxy_config);
	linphone_proxy_config_edit(proxy_config);

	CU_ASSERT_FALSE(wait_for_until(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationCleared,1,3000));
	linphone_proxy_config_enableregister(proxy_config,FALSE);
	linphone_proxy_config_done(proxy_config);

	CU_ASSERT(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationCleared,1));
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationOk,0);
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationProgress,1);
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0);

	linphone_core_manager_destroy(lcm);

}

jehan's avatar
jehan committed
627
static void io_recv_error(){
628
	LinphoneCoreManager *mgr;
jehan's avatar
jehan committed
629 630 631
	LinphoneCore* lc;
	int register_ok;
	stats* counters ;
jehan's avatar
jehan committed
632
	int number_of_udp_proxy=0;
jehan's avatar
jehan committed
633

634

635 636
	mgr=configure_lcm();
	lc=mgr->lc;
637
	counters = get_stats(lc);
jehan's avatar
jehan committed
638
	register_ok=counters->number_of_LinphoneRegistrationOk;
jehan's avatar
jehan committed
639
	number_of_udp_proxy=get_number_of_udp_proxy(lc);
jehan's avatar
jehan committed
640 641
	sal_set_recv_error(lc->sal, 0);

642 643 644
	CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationProgress,2*(register_ok-number_of_udp_proxy) /*because 1 udp*/));
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0)

jehan's avatar
jehan committed
645 646
	sal_set_recv_error(lc->sal, 1); /*reset*/

647
	linphone_core_manager_destroy(mgr);
jehan's avatar
jehan committed
648 649
}

jehan's avatar
jehan committed
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664
static void io_recv_error_retry_immediatly(){
	LinphoneCoreManager *mgr;
	LinphoneCore* lc;
	int register_ok;
	stats* counters ;
	int number_of_udp_proxy=0;


	mgr=configure_lcm();
	lc=mgr->lc;
	counters = get_stats(lc);
	register_ok=counters->number_of_LinphoneRegistrationOk;
	number_of_udp_proxy=get_number_of_udp_proxy(lc);
	sal_set_recv_error(lc->sal, 0);

665
	CU_ASSERT_TRUE(wait_for(lc,NULL,&counters->number_of_LinphoneRegistrationProgress,(register_ok-number_of_udp_proxy)+register_ok /*because 1 udp*/));
jehan's avatar
jehan committed
666 667 668
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0)
	sal_set_recv_error(lc->sal, 1); /*reset*/

669
	CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationOk,register_ok-number_of_udp_proxy+register_ok));
jehan's avatar
jehan committed
670 671 672 673 674 675 676 677 678 679 680 681

	linphone_core_manager_destroy(mgr);
}

static void io_recv_error_late_recovery(){
	LinphoneCoreManager *mgr;
	LinphoneCore* lc;
	int register_ok;
	stats* counters ;
	int number_of_udp_proxy=0;
	MSList* lcs;

682
	mgr=linphone_core_manager_new2( "multi_account_rc",FALSE); /*to make sure iterates are not call yet*/
jehan's avatar
jehan committed
683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698
	lc=mgr->lc;
	sal_set_refresher_retry_after(lc->sal,1000);
	counters=&mgr->stat;
	CU_ASSERT_TRUE(wait_for(mgr->lc,mgr->lc,&counters->number_of_LinphoneRegistrationOk,ms_list_size(linphone_core_get_proxy_config_list(mgr->lc))));


	counters = get_stats(lc);
	register_ok=counters->number_of_LinphoneRegistrationOk;
	number_of_udp_proxy=get_number_of_udp_proxy(lc);
	/*simulate a general socket error*/
	sal_set_recv_error(lc->sal, 0);
	sal_set_send_error(lc->sal, -1);

	CU_ASSERT_TRUE(wait_for(lc,NULL,&counters->number_of_LinphoneRegistrationProgress,(register_ok-number_of_udp_proxy)+register_ok /*because 1 udp*/));
	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0)

Simon Morlat's avatar
Simon Morlat committed
699
	CU_ASSERT_TRUE(wait_for_list(lcs=ms_list_append(NULL,lc),&counters->number_of_LinphoneRegistrationFailed,(register_ok-number_of_udp_proxy),sal_get_refresher_retry_after(lc->sal)+3000));
jehan's avatar
jehan committed
700 701 702 703

	sal_set_recv_error(lc->sal, 1); /*reset*/
	sal_set_send_error(lc->sal, 0);

704
	CU_ASSERT_TRUE(wait_for_list(lcs=ms_list_append(NULL,lc),&counters->number_of_LinphoneRegistrationOk,register_ok-number_of_udp_proxy +register_ok,sal_get_refresher_retry_after(lc->sal)+3000));
jehan's avatar
jehan committed
705 706 707 708

	linphone_core_manager_destroy(mgr);
}

jehan's avatar
jehan committed
709
static void io_recv_error_without_active_register(){
710
	LinphoneCoreManager *mgr;
jehan's avatar
jehan committed
711 712 713 714 715 716
	LinphoneCore* lc;
	int register_ok;
	stats* counters ;
	int number_of_udp_proxy=0;
	MSList* proxys;

717 718
	mgr=configure_lcm();
	lc=mgr->lc;
719
	counters = get_stats(lc);
720

jehan's avatar
jehan committed
721 722 723 724 725 726
	register_ok=counters->number_of_LinphoneRegistrationOk;
	number_of_udp_proxy=get_number_of_udp_proxy(lc);

	for (proxys=ms_list_copy(linphone_core_get_proxy_config_list(lc));proxys!=NULL;proxys=proxys->next) {
		LinphoneProxyConfig* proxy_cfg=(LinphoneProxyConfig*)proxys->data;
		linphone_proxy_config_edit(proxy_cfg);
727 728
		linphone_proxy_config_enableregister(proxy_cfg,FALSE);
		linphone_proxy_config_done(proxy_cfg);
729 730 731 732 733
	}
	ms_list_free(proxys);
	/*wait for unregistrations*/
	CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationCleared,register_ok /*because 1 udp*/));

jehan's avatar
jehan committed
734 735 736
	sal_set_recv_error(lc->sal, 0);

	/*nothing should happen because no active registration*/
737
	CU_ASSERT_FALSE(wait_for_until(lc,lc,&counters->number_of_LinphoneRegistrationProgress,2*(register_ok-number_of_udp_proxy) /*because 1 udp*/,3000));
jehan's avatar
jehan committed
738 739 740 741 742

	CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0)

	sal_set_recv_error(lc->sal, 1); /*reset*/

743
	linphone_core_manager_destroy(mgr);
jehan's avatar
jehan committed
744 745
}

jehan's avatar
jehan committed
746

jehan's avatar
jehan committed
747
static void tls_certificate_failure(){
748 749
	LinphoneCoreManager* mgr;
	LinphoneCore *lc;
jehan's avatar
jehan committed
750
	char rootcapath[256];
751

Simon Morlat's avatar
Simon Morlat committed
752
	mgr=linphone_core_manager_new2("pauline_rc",FALSE);
753
	lc=mgr->lc;
Gautier Pelloux-Prayer's avatar
Gautier Pelloux-Prayer committed
754
	snprintf(rootcapath,sizeof(rootcapath), "%s/certificates/cn/agent.pem", bc_tester_read_dir_prefix); /*bad root ca*/
755
	linphone_core_set_root_ca(mgr->lc,rootcapath);
jehan's avatar
jehan committed
756
	linphone_core_set_network_reachable(lc,TRUE);
757 758 759 760
	CU_ASSERT_TRUE(wait_for(mgr->lc,mgr->lc,&mgr->stat.number_of_LinphoneRegistrationFailed,1));
	linphone_core_set_root_ca(mgr->lc,NULL); /*no root ca*/
	linphone_core_refresh_registers(mgr->lc);
	CU_ASSERT_TRUE(wait_for(lc,lc,&mgr->stat.number_of_LinphoneRegistrationFailed,2));
Gautier Pelloux-Prayer's avatar
Gautier Pelloux-Prayer committed
761
	snprintf(rootcapath,sizeof(rootcapath), "%s/certificates/cn/cafile.pem", bc_tester_read_dir_prefix); /*goot root ca*/
762 763 764 765 766
	linphone_core_set_root_ca(mgr->lc,rootcapath);
	linphone_core_refresh_registers(mgr->lc);
	CU_ASSERT_TRUE(wait_for(lc,lc,&mgr->stat.number_of_LinphoneRegistrationOk,1));
	CU_ASSERT_EQUAL(mgr->stat.number_of_LinphoneRegistrationFailed,2);
	linphone_core_destroy(mgr->lc);
jehan's avatar
jehan committed
767
}
Simon Morlat's avatar
Simon Morlat committed
768

769
/*the purpose of this test is to check that will not block the proxy config during SSL handshake for entire life in case of mistaken configuration*/
jehan's avatar
jehan committed
770
static void tls_with_non_tls_server(){
771
	LinphoneCoreManager *mgr;
jehan's avatar
jehan committed
772 773 774
	LinphoneProxyConfig* proxy_cfg;
	LinphoneAddress* addr;
	char tmp[256];
775
	LinphoneCore *lc;
776

Simon Morlat's avatar
Simon Morlat committed
777
	mgr=linphone_core_manager_new2( "marie_rc", 0);
778
	lc=mgr->lc;
779
	sal_set_transport_timeout(lc->sal,3000);
jehan's avatar
jehan committed
780 781 782 783
	linphone_core_get_default_proxy(lc,&proxy_cfg);
	linphone_proxy_config_edit(proxy_cfg);
	addr=linphone_address_new(linphone_proxy_config_get_addr(proxy_cfg));
	snprintf(tmp,sizeof(tmp),"sip:%s:%i;transport=tls"	,linphone_address_get_domain(addr)
784
			,(linphone_address_get_port(addr)>0?linphone_address_get_port(addr):5060));
jehan's avatar
jehan committed
785 786 787
	linphone_proxy_config_set_server_addr(proxy_cfg,tmp);
	linphone_proxy_config_done(proxy_cfg);
	linphone_address_destroy(addr);
788
	CU_ASSERT_TRUE(wait_for_until(lc,lc,&mgr->stat.number_of_LinphoneRegistrationFailed,1,5000));
789
	linphone_core_manager_destroy(mgr);
Simon Morlat's avatar
Simon Morlat committed
790
}
jehan's avatar
jehan committed
791

792 793 794 795
static void tls_alt_name_register(){
	LinphoneCoreManager* mgr;
	LinphoneCore *lc;
	char rootcapath[256];
796

797 798
	mgr=linphone_core_manager_new2("pauline_alt_rc",FALSE);
	lc=mgr->lc;
Gautier Pelloux-Prayer's avatar
Gautier Pelloux-Prayer committed
799
	snprintf(rootcapath,sizeof(rootcapath), "%s/certificates/cn/cafile.pem", bc_tester_read_dir_prefix);
800 801 802 803
	linphone_core_set_root_ca(mgr->lc,rootcapath);
	linphone_core_refresh_registers(mgr->lc);
	CU_ASSERT_TRUE(wait_for(lc,lc,&mgr->stat.number_of_LinphoneRegistrationOk,1));
	CU_ASSERT_EQUAL(mgr->stat.number_of_LinphoneRegistrationFailed,0);
804
	linphone_core_manager_destroy(mgr);
805 806 807 808 809 810
}

static void tls_wildcard_register(){
	LinphoneCoreManager* mgr;
	LinphoneCore *lc;
	char rootcapath[256];
811

812 813
	mgr=linphone_core_manager_new2("pauline_wild_rc",FALSE);
	lc=mgr->lc;
Gautier Pelloux-Prayer's avatar
Gautier Pelloux-Prayer committed
814
	snprintf(rootcapath,sizeof(rootcapath), "%s/certificates/cn/cafile.pem", bc_tester_read_dir_prefix);
815 816
	linphone_core_set_root_ca(mgr->lc,rootcapath);
	linphone_core_refresh_registers(mgr->lc);
817
	CU_ASSERT_TRUE(wait_for(lc,lc,&mgr->stat.number_of_LinphoneRegistrationOk,2));
818 819 820 821
	CU_ASSERT_EQUAL(mgr->stat.number_of_LinphoneRegistrationFailed,0);
	linphone_core_destroy(mgr->lc);
}

jehan's avatar
jehan committed
822 823 824 825 826 827 828 829 830 831 832
static void redirect(){
	char route[256];
	LinphoneCoreManager* lcm;
	LCSipTransports transport = {-1,0,0,0};
	sprintf(route,"sip:%s:5064",test_route);
	lcm = create_lcm();
	linphone_core_set_user_agent(lcm->lc,"redirect",NULL);
	register_with_refresh_base_2(lcm->lc,FALSE,test_domain,route,FALSE,transport);
	linphone_core_manager_destroy(lcm);
}

Ghislain MARY's avatar
Ghislain MARY committed
833 834
test_t register_tests[] = {
	{ "Simple register", simple_register },
835
	{ "Simple register unregister", simple_unregister },
Ghislain MARY's avatar
Ghislain MARY committed
836
	{ "TCP register", simple_tcp_register },
837
	{ "Register with custom headers", register_with_custom_headers },
838
	{ "TCP register compatibility mode", simple_tcp_register_compatibility_mode },
839
	{ "TLS register", simple_tls_register },
840 841
	{ "TLS register with alt. name certificate", tls_alt_name_register },
	{ "TLS register with wildcard certificate", tls_wildcard_register },
jehan's avatar
jehan committed
842
	{ "TLS certificate not verified",tls_certificate_failure},
Simon Morlat's avatar
Simon Morlat committed
843
	{ "TLS with non tls server",tls_with_non_tls_server},
Ghislain MARY's avatar
Ghislain MARY committed
844
	{ "Simple authenticated register", simple_authenticated_register },
845
	{ "Ha1 authenticated register", ha1_authenticated_register },
Ghislain MARY's avatar
Ghislain MARY committed
846
	{ "Digest auth without initial credentials", authenticated_register_with_no_initial_credentials },
jehan's avatar
jehan committed
847
	{ "Digest auth with wrong credentials", authenticated_register_with_wrong_credentials },
848
	{ "Digest auth with wrong credentials, check if registration attempts are stopped", authenticated_register_with_wrong_credentials_2 },
849
	{ "Digest auth with wrong credentials without 403", authenticated_register_with_wrong_credentials_without_403},
850
	{ "Authenticated register with wrong late credentials", authenticated_register_with_wrong_late_credentials},
Ghislain MARY's avatar
Ghislain MARY committed
851 852 853
	{ "Authenticated register with late credentials", authenticated_register_with_late_credentials },
	{ "Register with refresh", simple_register_with_refresh },
	{ "Authenticated register with refresh", simple_auth_register_with_refresh },
854
	{ "Register with refresh and send error", register_with_refresh_with_send_error },
Ghislain MARY's avatar
Ghislain MARY committed
855
	{ "Multi account", multiple_proxy },
856 857 858 859 860
	{ "Transport changes", transport_change },
	{ "Proxy transport changes", proxy_transport_change},
	{ "Proxy transport changes with wrong address at first", proxy_transport_change_with_wrong_port},
	{ "Proxy transport changes with wrong address, giving up",proxy_transport_change_with_wrong_port_givin_up},
	{ "Change expires", change_expires},
Ghislain MARY's avatar
Ghislain MARY committed
861
	{ "Network state change", network_state_change },
jehan's avatar
jehan committed
862
	{ "Io recv error", io_recv_error },
jehan's avatar
jehan committed
863 864
	{ "Io recv error with recovery", io_recv_error_retry_immediatly},
	{ "Io recv error with late recovery", io_recv_error_late_recovery},
jehan's avatar
jehan committed
865 866
	{ "Io recv error without active registration", io_recv_error_without_active_register},
	{ "Simple redirect", redirect}
Ghislain MARY's avatar
Ghislain MARY committed
867 868 869 870 871 872 873 874 875
};

test_suite_t register_test_suite = {
	"Register",
	NULL,
	NULL,
	sizeof(register_tests) / sizeof(register_tests[0]),
	register_tests
};
jehan's avatar
jehan committed
876