belle_sip_refresher_tester.c 18 KB
Newer Older
jehan's avatar
jehan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
	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
    the Free Software Foundation, either version 3 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 <stdio.h>
#include "CUnit/Basic.h"
#include "belle-sip/belle-sip.h"
#include "belle_sip_internal.h"
23
#ifndef _MSC_VER
jehan's avatar
jehan committed
24
#include <sys/time.h>
25
#endif
jehan's avatar
jehan committed
26 27 28
#define USERNAME "toto"
#define SIPDOMAIN "sip.linphone.org"
#define PASSWD "secret"
jehan's avatar
jehan committed
29 30 31 32 33 34 35 36 37

typedef enum auth_mode {
	none
	,digest
	,digest_auth
}auth_mode_t;

typedef struct _stat {
	int twoHundredOk;
jehan's avatar
jehan committed
38
	int fourHundredOne;
jehan's avatar
jehan committed
39 40 41 42 43 44 45
	int refreshOk;
}stat_t;
typedef struct endpoint {
	belle_sip_stack_t* stack;
	belle_sip_listener_callbacks_t* listener_callbacks;
	belle_sip_provider_t* provider;
	belle_sip_listening_point_t *lp;
46
	belle_sip_listener_t *listener;
jehan's avatar
jehan committed
47 48 49
	auth_mode_t auth;
	stat_t stat;
	unsigned char expire_in_contact;
jehan's avatar
jehan committed
50 51
	char nonce[32];
	unsigned int nonce_count;
52 53
	const char* received;
	int rport;
jehan's avatar
jehan committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
} endpoint_t;

static unsigned int  wait_for(belle_sip_stack_t*s1, belle_sip_stack_t*s2,int* counter,int value,int timeout) {
	int retry=0;
#define ITER 100
	while (*counter<value && retry++ <(timeout/ITER)) {
		if (s1) belle_sip_stack_sleep(s1,ITER/2);
		if (s2) belle_sip_stack_sleep(s2,ITER/2);
	}
	if(*counter<value) return FALSE;
	else return TRUE;
}

//static void process_dialog_terminated(void *obj, const belle_sip_dialog_terminated_event_t *event){
//	belle_sip_message("process_dialog_terminated called");
//}
//static void process_io_error(void *obj, const belle_sip_io_error_event_t *event){
//	belle_sip_warning("process_io_error");
//	/*belle_sip_main_loop_quit(belle_sip_stack_get_main_loop(stack));*/
//	/*CU_ASSERT(CU_FALSE);*/
//}
jehan's avatar
jehan committed
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
static void compute_response(const char* username
									,const char* realm
									,const char* passwd
									,const char* nonce
									,const char* method
									,const char* uri
									,char response[33] ) {
	char ha1[33],ha2[33];
	belle_sip_auth_helper_compute_ha1(username,realm,passwd,ha1);
	belle_sip_auth_helper_compute_ha2(method,uri,ha2);
	belle_sip_auth_helper_compute_response(ha1,nonce,ha2,response);
}
static void compute_response_auth_qop(const char* username
										,const char* realm
										,const char* passwd
										,const char* nonce
										,unsigned int nonce_count
										,const char* cnonce
										,const char* qop
										,const char* method
										,const char* uri
										,char response[33] ) {
	char ha1[33],ha2[33];
	belle_sip_auth_helper_compute_ha1(username,realm,passwd,ha1);
	belle_sip_auth_helper_compute_ha2(method,uri,ha2);
	belle_sip_auth_helper_compute_response_qop_auth(ha1, nonce,nonce_count, cnonce,qop,ha2,response);
}

jehan's avatar
jehan committed
103 104 105 106 107
static void server_process_request_event(void *obj, const belle_sip_request_event_t *event){
	endpoint_t* endpoint = (endpoint_t*)obj;
	belle_sip_server_transaction_t* server_transaction =belle_sip_provider_create_server_transaction(endpoint->provider,belle_sip_request_event_get_request(event));
	belle_sip_request_t* req = belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(server_transaction));
	belle_sip_response_t* resp;
jehan's avatar
jehan committed
108 109 110
	belle_sip_header_contact_t* contact;
	belle_sip_header_expires_t* expires;
	belle_sip_header_authorization_t* authorization;
111
	belle_sip_header_via_t* via;
jehan's avatar
jehan committed
112 113 114 115 116 117 118 119 120
	const char* raw_authenticate_digest = "WWW-Authenticate: Digest "
			"algorithm=MD5, realm=\"" SIPDOMAIN "\", opaque=\"1bc7f9097684320\"";

	belle_sip_header_www_authenticate_t* www_authenticate=NULL;
	const char* auth_uri;
	const char* qop;
	unsigned char auth_ok=0;
	char local_resp[33];

jehan's avatar
jehan committed
121 122 123 124
	belle_sip_message("caller_process_request_event received [%s] message",belle_sip_request_get_method(belle_sip_request_event_get_request(event)));

	switch (endpoint->auth) {
	case none: {
jehan's avatar
jehan committed
125
		auth_ok=1;
jehan's avatar
jehan committed
126 127
		break;
	}
jehan's avatar
jehan committed
128 129
	case digest_auth:
	case digest: {
130
		if ((authorization=belle_sip_message_get_header_by_type(req,belle_sip_header_authorization_t)) != NULL){
jehan's avatar
jehan committed
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
			qop=belle_sip_header_authorization_get_qop(authorization);

			if (qop && strcmp(qop,"auth")==0) {
				compute_response_auth_qop(	belle_sip_header_authorization_get_username(authorization)
											,belle_sip_header_authorization_get_realm(authorization)
											,PASSWD
											,endpoint->nonce
											,endpoint->nonce_count
											,belle_sip_header_authorization_get_cnonce(authorization)
											,belle_sip_header_authorization_get_qop(authorization)
											,belle_sip_request_get_method(req)
											,auth_uri=belle_sip_uri_to_string(belle_sip_header_authorization_get_uri(authorization))
											,local_resp);
			} else {
				/*digest*/
				compute_response(belle_sip_header_authorization_get_username(authorization)
						,belle_sip_header_authorization_get_realm(authorization)
						,PASSWD
						,endpoint->nonce
						,belle_sip_request_get_method(req)
						,auth_uri=belle_sip_uri_to_string(belle_sip_header_authorization_get_uri(authorization))
						,local_resp);

			}
			belle_sip_free((void*)auth_uri);
			auth_ok=strcmp(belle_sip_header_authorization_get_response(authorization),local_resp)==0;
		}
		if (auth_ok) {
			if (endpoint->auth == digest) {
			sprintf(endpoint->nonce,"%p",authorization); //*change the nonce for next auth*/
			} else {
				endpoint->nonce_count++;
			}
		} else {
			www_authenticate=belle_sip_header_www_authenticate_parse(raw_authenticate_digest);
			belle_sip_header_www_authenticate_set_nonce(www_authenticate,endpoint->nonce);
			if (endpoint->auth == digest_auth) {
				belle_sip_header_www_authenticate_add_qop(www_authenticate,"auth");
			}
		}
	}
	break;
jehan's avatar
jehan committed
173 174 175
	default:
		break;
	}
jehan's avatar
jehan committed
176 177 178 179 180
	if (auth_ok) {
		resp=belle_sip_response_create_from_request(belle_sip_request_event_get_request(event),200);
		if (!endpoint->expire_in_contact) {
			belle_sip_message_add_header(BELLE_SIP_MESSAGE(resp),BELLE_SIP_HEADER(expires=belle_sip_message_get_header_by_type(req,belle_sip_header_expires_t)));
		}
181 182 183 184 185 186 187
		if (strcmp(belle_sip_request_get_method(req),"REGISTER")==0) {
			contact=belle_sip_message_get_header_by_type(req,belle_sip_header_contact_t);
		} else {
			contact=belle_sip_header_contact_new();
		}
		belle_sip_message_add_header(BELLE_SIP_MESSAGE(resp),BELLE_SIP_HEADER(contact));

jehan's avatar
jehan committed
188 189 190 191 192
	} else {
		resp=belle_sip_response_create_from_request(belle_sip_request_event_get_request(event),401);
		if (www_authenticate)
			belle_sip_message_add_header(BELLE_SIP_MESSAGE(resp),BELLE_SIP_HEADER(www_authenticate));
	}
193 194 195 196
	if (endpoint->received) {
		via=belle_sip_message_get_header_by_type(req,belle_sip_header_via_t);
		belle_sip_header_via_set_received(via,endpoint->received);
	}
jehan's avatar
jehan committed
197 198 199 200 201 202 203 204 205
	belle_sip_server_transaction_send_response(server_transaction,resp);
}
static void client_process_response_event(void *obj, const belle_sip_response_event_t *event){
	//belle_sip_client_transaction_t* client_transaction = belle_sip_response_event_get_client_transaction(event);
	endpoint_t* endpoint = (endpoint_t*)obj;
	int status = belle_sip_response_get_status_code(belle_sip_response_event_get_response(event));
	belle_sip_message("caller_process_response_event [%i]",status);
	switch (status) {
	case 200:endpoint->stat.twoHundredOk++; break;
jehan's avatar
jehan committed
206
	case 401:endpoint->stat.fourHundredOne++; break;
jehan's avatar
jehan committed
207 208 209 210 211 212 213 214 215 216 217
	default: break;
	}


}
//static void process_timeout(void *obj, const belle_sip_timeout_event_t *event){
//	belle_sip_message("process_timeout");
//}
//static void process_transaction_terminated(void *obj, const belle_sip_transaction_terminated_event_t *event){
//	belle_sip_message("process_transaction_terminated");
//}
jehan's avatar
jehan committed
218
static void client_process_auth_requested(void *obj, belle_sip_auth_event_t *event){
219
	BELLESIP_UNUSED(obj);
jehan's avatar
jehan committed
220 221 222 223 224
	belle_sip_message("process_auth_requested requested for [%s@%s]"
			,belle_sip_auth_event_get_username(event)
			,belle_sip_auth_event_get_realm(event));
	belle_sip_auth_event_set_passwd(event,PASSWD);
}
jehan's avatar
jehan committed
225 226 227 228 229 230

static void belle_sip_refresher_listener ( const belle_sip_refresher_t* refresher
		,void* user_pointer
		,unsigned int status_code
		,const char* reason_phrase) {
	endpoint_t* endpoint = (endpoint_t*)user_pointer;
231
	BELLESIP_UNUSED(refresher);
jehan's avatar
jehan committed
232 233 234 235 236 237 238 239 240 241 242 243
	belle_sip_message("belle_sip_refresher_listener [%i] reason [%s]",status_code,reason_phrase);
	switch (status_code) {
		case 200:endpoint->stat.refreshOk++; break;
		default: break;
	}
}

static endpoint_t* create_endpoint(int port,const char* transport,belle_sip_listener_callbacks_t* listener_callbacks) {
	endpoint_t* endpoint = belle_sip_new0(endpoint_t);
	endpoint->stack=belle_sip_stack_new(NULL);
	endpoint->listener_callbacks=listener_callbacks;
	endpoint->lp=belle_sip_stack_create_listening_point(endpoint->stack,"0.0.0.0",port,transport);
244
	belle_sip_object_ref(endpoint->lp);
jehan's avatar
jehan committed
245
	endpoint->provider=belle_sip_stack_create_provider(endpoint->stack,endpoint->lp);
246
	belle_sip_provider_add_sip_listener(endpoint->provider,(endpoint->listener=belle_sip_listener_create_from_callbacks(endpoint->listener_callbacks,endpoint)));
jehan's avatar
jehan committed
247 248
	sprintf(endpoint->nonce,"%p",endpoint); /*initial nonce*/
	endpoint->nonce_count=1;
jehan's avatar
jehan committed
249 250
	return endpoint;
}
jehan's avatar
jehan committed
251 252 253 254
static void destroy_endpoint(endpoint_t* endpoint) {
	belle_sip_object_unref(endpoint->lp);
	belle_sip_object_unref(endpoint->provider);
	belle_sip_object_unref(endpoint->stack);
255
	belle_sip_object_unref(endpoint->listener);
jehan's avatar
jehan committed
256 257
	belle_sip_free(endpoint);
}
jehan's avatar
jehan committed
258 259 260
static endpoint_t* create_udp_endpoint(int port,belle_sip_listener_callbacks_t* listener_callbacks) {
	return create_endpoint(port,"udp",listener_callbacks);
}
jehan's avatar
jehan committed
261
static void register_test_with_param(unsigned char expire_in_contact,auth_mode_t auth_mode) {
jehan's avatar
jehan committed
262 263 264 265 266
	belle_sip_listener_callbacks_t client_callbacks;
	belle_sip_listener_callbacks_t server_callbacks;
	belle_sip_request_t* req;
	belle_sip_client_transaction_t* trans;
	belle_sip_header_route_t* destination_route;
267
	belle_sip_refresher_t* refresher;
jehan's avatar
jehan committed
268 269 270
	const char* identity = "sip:" USERNAME "@" SIPDOMAIN ;
	const char* domain="sip:" SIPDOMAIN ;
	belle_sip_header_contact_t* contact=belle_sip_header_contact_new();
271 272
	belle_sip_uri_t *dest_uri;
	endpoint_t* client,*server;
273 274 275
	struct timeval begin;
	struct timeval end;

jehan's avatar
jehan committed
276 277 278 279
	memset(&client_callbacks,0,sizeof(belle_sip_listener_callbacks_t));
	memset(&server_callbacks,0,sizeof(belle_sip_listener_callbacks_t));

	if (expire_in_contact) belle_sip_header_contact_set_expires(contact,1);
jehan's avatar
jehan committed
280

jehan's avatar
jehan committed
281 282
	client_callbacks.process_response_event=client_process_response_event;
	client_callbacks.process_auth_requested=client_process_auth_requested;
jehan's avatar
jehan committed
283 284
	server_callbacks.process_request_event=server_process_request_event;

285 286
	client = create_udp_endpoint(3452,&client_callbacks);
	server = create_udp_endpoint(6788,&server_callbacks);
jehan's avatar
jehan committed
287 288
	server->expire_in_contact=expire_in_contact;
	server->auth=auth_mode;
289 290 291 292
	
	dest_uri=(belle_sip_uri_t*)belle_sip_object_clone((belle_sip_object_t*)belle_sip_listening_point_get_uri(server->lp));
	belle_sip_uri_set_host(dest_uri,"127.0.0.1");
	destination_route=belle_sip_header_route_create(belle_sip_header_address_create(NULL,dest_uri));
jehan's avatar
jehan committed
293 294 295 296 297 298 299 300 301 302 303


	req=belle_sip_request_create(
		                    belle_sip_uri_parse(domain),
		                    "REGISTER",
		                    belle_sip_provider_create_call_id(client->provider),
		                    belle_sip_header_cseq_create(20,"REGISTER"),
		                    belle_sip_header_from_create2(identity,BELLE_SIP_RANDOM_TAG),
		                    belle_sip_header_to_create2(identity,NULL),
		                    belle_sip_header_via_new(),
		                    70);
jehan's avatar
jehan committed
304 305 306 307
	belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(contact));
	if (!expire_in_contact)
		belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_expires_create(1)));

jehan's avatar
jehan committed
308 309
	belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(destination_route));
	trans=belle_sip_provider_create_client_transaction(client->provider,req);
jehan's avatar
jehan committed
310
	belle_sip_object_ref(trans);/*to avoid trans from being deleted before refresher can use it*/
jehan's avatar
jehan committed
311 312
	belle_sip_client_transaction_send_request(trans);

jehan's avatar
jehan committed
313 314 315 316 317 318 319 320 321 322 323 324
	if (server->auth == none) {
		CU_ASSERT_TRUE(wait_for(server->stack,client->stack,&client->stat.twoHundredOk,1,1000));
	} else {
		CU_ASSERT_TRUE(wait_for(server->stack,client->stack,&client->stat.fourHundredOne,1,1000));
		/*update cseq*/
		req=belle_sip_client_transaction_create_authenticated_request(trans);
		belle_sip_object_unref(trans);
		trans=belle_sip_provider_create_client_transaction(client->provider,req);
		belle_sip_object_ref(trans);
		belle_sip_client_transaction_send_request(trans);
		CU_ASSERT_TRUE_FATAL(wait_for(server->stack,client->stack,&client->stat.twoHundredOk,1,1000));
	}
325
	refresher = belle_sip_client_transaction_create_refresher(trans);
jehan's avatar
jehan committed
326
	belle_sip_object_unref(trans);
jehan's avatar
jehan committed
327 328
	belle_sip_refresher_set_listener(refresher,belle_sip_refresher_listener,client);

jehan's avatar
jehan committed
329 330 331 332 333
	gettimeofday(&begin, NULL);
	CU_ASSERT_TRUE(wait_for(server->stack,client->stack,&client->stat.refreshOk,3,4000));
	gettimeofday(&end, NULL);
	CU_ASSERT_TRUE(end.tv_sec-begin.tv_sec>=3);
	CU_ASSERT_TRUE(end.tv_sec-begin.tv_sec<5);
334 335 336
	/*unregister*/
	belle_sip_refresher_refresh(refresher,0);
	CU_ASSERT_TRUE(wait_for(server->stack,client->stack,&client->stat.refreshOk,4,1000));
jehan's avatar
jehan committed
337 338 339 340
	belle_sip_refresher_stop(refresher);
	belle_sip_object_unref(refresher);
	destroy_endpoint(client);
	destroy_endpoint(server);
jehan's avatar
jehan committed
341 342
}

343
static void subscribe_test(void) {
344 345 346 347 348 349 350
	belle_sip_listener_callbacks_t client_callbacks;
	belle_sip_listener_callbacks_t server_callbacks;
	belle_sip_request_t* req;
	belle_sip_client_transaction_t* trans;
	belle_sip_header_route_t* destination_route;
	const char* identity = "sip:" USERNAME "@" SIPDOMAIN ;
	const char* domain="sip:" SIPDOMAIN ;
351 352
	endpoint_t* client,*server;
	belle_sip_uri_t *dest_uri;
353
	belle_sip_refresher_t* refresher;
354
	belle_sip_header_contact_t* contact=belle_sip_header_contact_new();
355 356
	struct timeval begin;
	struct timeval end;
357 358 359 360 361 362 363
	memset(&client_callbacks,0,sizeof(belle_sip_listener_callbacks_t));
	memset(&server_callbacks,0,sizeof(belle_sip_listener_callbacks_t));

	client_callbacks.process_response_event=client_process_response_event;
	client_callbacks.process_auth_requested=client_process_auth_requested;
	server_callbacks.process_request_event=server_process_request_event;

364 365
	client = create_udp_endpoint(3452,&client_callbacks);
	server = create_udp_endpoint(6788,&server_callbacks);
366 367
	server->expire_in_contact=0;
	server->auth=digest_auth;
368 369 370 371
	
	dest_uri=(belle_sip_uri_t*)belle_sip_object_clone((belle_sip_object_t*)belle_sip_listening_point_get_uri(server->lp));
	belle_sip_uri_set_host(dest_uri,"127.0.0.1");
	destination_route=belle_sip_header_route_create(belle_sip_header_address_create(NULL,dest_uri));
372 373 374 375 376 377 378 379 380 381 382 383 384


	req=belle_sip_request_create(
		                    belle_sip_uri_parse(domain),
		                    "SUBSCRIBE",
		                    belle_sip_provider_create_call_id(client->provider),
		                    belle_sip_header_cseq_create(20,"SUBSCRIBE"),
		                    belle_sip_header_from_create2(identity,BELLE_SIP_RANDOM_TAG),
		                    belle_sip_header_to_create2(identity,NULL),
		                    belle_sip_header_via_new(),
		                    70);
	belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(contact));
	belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_expires_create(1)));
jehan's avatar
jehan committed
385
	belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_create("Event","Presence")));
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402

	belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(destination_route));
	trans=belle_sip_provider_create_client_transaction(client->provider,req);
	belle_sip_object_ref(trans);/*to avoid trans from being deleted before refresher can use it*/
	belle_sip_client_transaction_send_request(trans);

	CU_ASSERT_TRUE(wait_for(server->stack,client->stack,&client->stat.fourHundredOne,1,1000));

	req=belle_sip_client_transaction_create_authenticated_request(trans);
	belle_sip_object_unref(trans);
	trans=belle_sip_provider_create_client_transaction(client->provider,req);
	belle_sip_object_ref(trans);
	belle_sip_client_transaction_send_request(trans);
	CU_ASSERT_TRUE_FATAL(wait_for(server->stack,client->stack,&client->stat.twoHundredOk,1,1000));
	 /*maybe dialog should be automatically created*/
	CU_ASSERT_PTR_NOT_NULL_FATAL(belle_sip_transaction_get_dialog(BELLE_SIP_TRANSACTION(trans)))

403
	refresher = belle_sip_client_transaction_create_refresher(trans);
404 405 406 407 408 409 410 411 412 413 414 415 416 417
	belle_sip_object_unref(trans);
	belle_sip_refresher_set_listener(refresher,belle_sip_refresher_listener,client);

	gettimeofday(&begin, NULL);
	CU_ASSERT_TRUE(wait_for(server->stack,client->stack,&client->stat.refreshOk,3,4000));
	gettimeofday(&end, NULL);
	CU_ASSERT_TRUE(end.tv_sec-begin.tv_sec>=3);
	CU_ASSERT_TRUE(end.tv_sec-begin.tv_sec<5);
	belle_sip_refresher_stop(refresher);
	belle_sip_object_unref(refresher);
	destroy_endpoint(client);
	destroy_endpoint(server);
}

418
static void register_expires_header(void) {
jehan's avatar
jehan committed
419 420
	register_test_with_param(0,none);
}
421
static void register_expires_in_contact(void) {
jehan's avatar
jehan committed
422 423
	register_test_with_param(1,none);
}
424
static void register_expires_header_digest(void) {
jehan's avatar
jehan committed
425 426
	register_test_with_param(0,digest);
}
jehan's avatar
jehan committed
427

428
static void register_expires_in_contact_header_digest_auth(void) {
jehan's avatar
jehan committed
429 430
	register_test_with_param(1,digest_auth);
}
jehan's avatar
jehan committed
431 432 433 434

int belle_sip_refresher_test_suite(){
	CU_pSuite pSuite = CU_add_suite("Refresher", NULL, NULL);

jehan's avatar
jehan committed
435 436 437 438 439 440 441 442 443 444
	if (NULL == CU_add_test(pSuite, "register_expires_header", register_expires_header)) {
		return CU_get_error();
	}
	if (NULL == CU_add_test(pSuite, "register_expires_in_contact", register_expires_in_contact)) {
		return CU_get_error();
	}
	if (NULL == CU_add_test(pSuite, "register_expires_header_digest", register_expires_header_digest)) {
		return CU_get_error();
	}
	if (NULL == CU_add_test(pSuite, "register_expires_in_contact_header_digest_auth", register_expires_in_contact_header_digest_auth)) {
jehan's avatar
jehan committed
445 446
		return CU_get_error();
	}
447 448 449
	if (NULL == CU_add_test(pSuite, "subscribe_test", subscribe_test)) {
		return CU_get_error();
	}
jehan's avatar
jehan committed
450 451 452
	return 0;
}