Commit 6c40a924 authored by jehan's avatar jehan

add bad request over tcp test

parent 6c838542
......@@ -31,6 +31,14 @@
typedef struct _belle_sip_header_address belle_sip_header_address_t;
belle_sip_header_address_t* belle_sip_header_address_new();
/*
* creates an address from a display name and an uri
* Note the uri not copied but only its ref count is incremented
* @param display display name. May be null.
* @param uri uri set to the newly created header_address
* @return
* */
belle_sip_header_address_t* belle_sip_header_address_create(const char* display, belle_sip_uri_t* uri);
belle_sip_header_address_t* belle_sip_header_address_parse (const char* address) ;
......
......@@ -86,7 +86,7 @@ void belle_sip_message_remove_header(belle_sip_message_t *msg, const char *heade
char *belle_sip_message_to_string(belle_sip_message_t *msg);
const char* belle_sip_message_get_body(belle_sip_message_t *msg);
void belle_sip_message_set_body(belle_sip_message_t *msg,char* body,unsigned int size);
void belle_sip_message_set_body(belle_sip_message_t *msg,const char* body,unsigned int size);
/*message keep ownership of the null terminated body buffer
void belle_sip_message_assign_body(belle_sip_message_t *msg,char* body);*/
......
......@@ -25,6 +25,11 @@ typedef struct _belle_sip_uri belle_sip_uri_t;
*
*/
belle_sip_uri_t* belle_sip_uri_parse (const char* uri) ;
/**
*
*/
belle_sip_uri_t* belle_sip_uri_create (const char* username,const char* host) ;
/**
* Returns the value of the named header, or null if it is not set.
......
......@@ -138,6 +138,12 @@ void belle_sip_header_address_set_uri(belle_sip_header_address_t* address, belle
address->uri=(belle_sip_uri_t*)belle_sip_object_ref(uri);
}
belle_sip_header_address_t* belle_sip_header_address_create(const char* display, belle_sip_uri_t* uri) {
belle_sip_header_address_t* address = belle_sip_header_address_new();
belle_sip_header_address_set_displayname(address,display);
belle_sip_header_address_set_uri(address,uri);
return address;
}
/******************************
* Extension header inherits from header
......@@ -263,6 +269,7 @@ belle_sip_header_from_t* belle_sip_header_from_create2(const char *address, cons
belle_sip_header_from_t* belle_sip_header_from_create(const belle_sip_header_address_t* address, const char *tag) {
belle_sip_header_from_t* header= belle_sip_header_from_new();
_belle_sip_object_copy((belle_sip_object_t*)header,(belle_sip_object_t*)address);
/*belle_sip_header_set_name(BELLE_SIP_HEADER(header),BELLE_SIP_FROM);*/ /*restaure header name*/
if (tag) belle_sip_header_from_set_tag(header,tag);
return header;
}
......@@ -318,6 +325,7 @@ belle_sip_header_to_t* belle_sip_header_to_create2(const char *address, const ch
belle_sip_header_to_t* belle_sip_header_to_create(const belle_sip_header_address_t* address, const char *tag) {
belle_sip_header_to_t* header= belle_sip_header_to_new();
_belle_sip_object_copy((belle_sip_object_t*)header,(belle_sip_object_t*)address);
belle_sip_header_set_name(BELLE_SIP_HEADER(header),BELLE_SIP_TO); /*restaure header name*/
if (tag) belle_sip_header_to_set_tag(header,tag);
return header;
}
......@@ -601,7 +609,8 @@ BELLE_SIP_NEW_HEADER(header_route,header_address,BELLE_SIP_ROUTE)
BELLE_SIP_PARSE(header_route)
belle_sip_header_route_t* belle_sip_header_route_create(const belle_sip_header_address_t* route) {
belle_sip_header_route_t* header= belle_sip_header_route_new();
belle_sip_header_address_clone(BELLE_SIP_HEADER_ADDRESS(header),BELLE_SIP_HEADER_ADDRESS(route));
_belle_sip_object_copy((belle_sip_object_t*)header,(belle_sip_object_t*)route);
belle_sip_header_set_name(BELLE_SIP_HEADER(header),BELLE_SIP_ROUTE); /*restaure header name*/
return header;
}
/**************************
......
......@@ -107,7 +107,12 @@ belle_sip_uri_t* belle_sip_uri_new () {
l_object->header_list = belle_sip_parameters_new();
return l_object;
}
belle_sip_uri_t* belle_sip_uri_create (const char* username,const char* host) {
belle_sip_uri_t* uri = belle_sip_uri_new();
belle_sip_uri_set_user(uri,username);
belle_sip_uri_set_host(uri,host);
return uri;
}
char* belle_sip_uri_to_string(belle_sip_uri_t* uri) {
......
......@@ -33,6 +33,8 @@ const char *belle_sip_channel_state_to_string(belle_sip_channel_state_t state){
return "READY";
case BELLE_SIP_CHANNEL_ERROR:
return "ERROR";
case BELLE_SIP_CHANNEL_DISCONNECTED:
return "BELLE_SIP_CHANNEL_DISCONNECTED";
}
return "BAD";
}
......@@ -190,8 +192,11 @@ void belle_sip_channel_process_data(belle_sip_channel_t *obj,unsigned int revent
belle_sip_channel_process_data(obj,revents);
}
return;
} else if (num == 0) {
channel_set_state(obj,BELLE_SIP_CHANNEL_DISCONNECTED);
} else {
belle_sip_error("Receive error on channel [%p]",obj);
channel_set_state(obj,BELLE_SIP_CHANNEL_ERROR);
}
return;
}
......
......@@ -33,7 +33,8 @@ typedef enum belle_sip_channel_state{
BELLE_SIP_CHANNEL_RES_DONE,
BELLE_SIP_CHANNEL_CONNECTING,
BELLE_SIP_CHANNEL_READY,
BELLE_SIP_CHANNEL_ERROR
BELLE_SIP_CHANNEL_ERROR,
BELLE_SIP_CHANNEL_DISCONNECTED
}belle_sip_channel_state_t;
const char * belle_sip_channel_state_to_string(belle_sip_channel_state_t state);
......
......@@ -302,7 +302,7 @@ const char* belle_sip_message_get_body(belle_sip_message_t *msg) {
return msg->body;
}
void belle_sip_message_set_body(belle_sip_message_t *msg,char* body,unsigned int size) {
void belle_sip_message_set_body(belle_sip_message_t *msg,const char* body,unsigned int size) {
if (msg->body) {
belle_sip_free((void*)body);
}
......
......@@ -27,7 +27,7 @@ static void belle_sip_provider_uninit(belle_sip_provider_t *p){
static void channel_state_changed(belle_sip_channel_listener_t *obj, belle_sip_channel_t *chan, belle_sip_channel_state_t state){
belle_sip_io_error_event_t ev;
if (state == BELLE_SIP_CHANNEL_ERROR) {
if (state == BELLE_SIP_CHANNEL_ERROR || state == BELLE_SIP_CHANNEL_DISCONNECTED) {
ev.transport=belle_sip_channel_get_transport_name(chan);
ev.source=(belle_sip_provider_t*)obj;
ev.port=chan->peer_port;
......
......@@ -151,7 +151,7 @@ static int stream_channel_process_data(belle_sip_channel_t *obj,unsigned int rev
} else if ( obj->state == BELLE_SIP_CHANNEL_READY) {
belle_sip_channel_process_data(obj,revents);
} else {
belle_sip_warning("Unexpected event [%i], for channel [%p]",revents,obj);
belle_sip_warning("Unexpected event [%i], in state [%s] for channel [%p]",revents,belle_sip_channel_state_to_string(obj->state),obj);
}
return BELLE_SIP_CONTINUE;
}
......
......@@ -11,7 +11,8 @@ belle_sip_tester_SOURCES= belle_sip_tester.c \
belle_sip_message_tester.c \
auth_helper_tester.c \
cast_test.c \
belle_sip_register_tester.c
belle_sip_register_tester.c \
belle_sip_dialog_tester.c
belle_sip_tester_CFLAGS=$(CUNIT_CFLAGS) $(STRICT_OPTIONS)
......
/*
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 "pthread.h"
extern belle_sip_stack_t * stack;
extern belle_sip_provider_t *prov;
extern const char *test_domain;
extern int register_init(void);
extern int register_uninit(void);
extern belle_sip_request_t* register_user(belle_sip_stack_t * stack
,belle_sip_provider_t *prov
,const char *transport
,int use_transaction
,const char* username) ;
extern void unregister_user(belle_sip_stack_t * stack
,belle_sip_provider_t *prov
,belle_sip_request_t* initial_request
,int use_transaction);
static int init(void) {
register_init();
return 0;
}
static int uninit(void) {
register_uninit();
return 0;
}
belle_sip_request_t* build_request(belle_sip_stack_t * stack
, belle_sip_provider_t *prov
,belle_sip_header_address_t* from
,belle_sip_header_address_t* to
,belle_sip_header_address_t* route
,const char* method) {
belle_sip_header_from_t* from_header;
belle_sip_header_to_t* to_header;
belle_sip_request_t *req;
belle_sip_uri_t* req_uri;
belle_sip_header_contact_t* contact_header;
from_header = belle_sip_header_from_create(from,BELLE_SIP_RANDOM_TAG);
to_header = belle_sip_header_to_create(to,NULL);
req_uri = (belle_sip_uri_t*)belle_sip_object_clone((belle_sip_object_t*)belle_sip_header_address_get_uri((belle_sip_header_address_t*)to_header));
contact_header= belle_sip_header_contact_new();
belle_sip_header_address_set_uri((belle_sip_header_address_t*)contact_header,belle_sip_uri_new());
belle_sip_uri_set_user(belle_sip_header_address_get_uri((belle_sip_header_address_t*)contact_header),belle_sip_uri_get_user(req_uri));
req=belle_sip_request_create(
req_uri,
method,
belle_sip_provider_create_call_id(prov),
belle_sip_header_cseq_create(20,method),
from_header,
to_header,
belle_sip_header_via_new(),
70);
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(contact_header));
if (route) {
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_route_create(route)));
}
return req;
}
static void process_dialog_terminated(void *user_ctx, const belle_sip_dialog_terminated_event_t *event){
belle_sip_message("process_dialog_terminated not implemented yet");
}
static void process_io_error(void *user_ctx, const belle_sip_io_error_event_t *event){
belle_sip_message("process_io_error not implemented yet");
}
static void process_request_event(void *user_ctx, const belle_sip_request_event_t *event) {
/*belle_sip_server_transaction_t* server_transaction = belle_sip_request_event_get_server_transaction(event);
SalOp* op = (SalOp*)belle_sip_transaction_get_application_data(BELLE_SIP_TRANSACTION(server_transaction));*/
belle_sip_message("process_request_event not implemented yet");
}
static void process_response_event(void *user_ctx, const belle_sip_response_event_t *event){
belle_sip_message("process_response_event not implemented yet");
}
static void process_timeout(void *user_ctx, const belle_sip_timeout_event_t *event) {
/* belle_sip_client_transaction_t* client_transaction = belle_sip_timeout_event_get_client_transaction(event);
SalOp* op = (SalOp*)belle_sip_transaction_get_application_data(BELLE_SIP_TRANSACTION(client_transaction));
if (op->callbacks.process_timeout) {
op->callbacks.process_timeout(op,event);
} else*/ {
belle_sip_message("Unhandled event timeout [%p]",event);
}
}
static void process_transaction_terminated(void *user_ctx, const belle_sip_transaction_terminated_event_t *event) {
/* belle_sip_client_transaction_t* client_transaction = belle_sip_transaction_terminated_event_get_client_transaction(event);
SalOp* op = (SalOp*)belle_sip_transaction_get_application_data(client_transaction);
if (op->calbacks.process_transaction_terminated) {
op->calbacks.process_transaction_terminated(op,event);
} else */{
belle_sip_message("Unhandled transaction terminated [%p]",event);
}
}
static const char* sdp = "v=0\r\n"\
"o=jehan-mac 1239 1239 IN IP4 192.168.0.18\r\n"\
"s=Talk\r\n"\
"c=IN IP4 192.168.0.18\r\n"\
"t=0 0\r\n"\
"m=audio 7078 RTP/AVP 111 110 3 0 8 101\r\n"\
"a=rtpmap:111 speex/16000\r\n"\
"a=fmtp:111 vbr=on\r\n"\
"a=rtpmap:110 speex/8000\r\n"\
"a=fmtp:110 vbr=on\r\n"\
"a=rtpmap:101 telephone-event/8000\r\n"\
"a=fmtp:101 0-11\r\n"\
"m=video 8078 RTP/AVP 99 97 98\r\n"\
"c=IN IP4 192.168.0.18\r\n"\
"b=AS:380\r\n"\
"a=rtpmap:99 MP4V-ES/90000\r\n"\
"a=fmtp:99 profile-level-id=3\r\n"\
"a=rtpmap:97 theora/90000\r\n"\
"a=rtpmap:98 H263-1998/90000\r\n"\
"a=fmtp:98 CIF=1;QCIF=1\r\n";
static void simple_call(void) {
#define CALLER "marie"
#define CALLEE "pauline"
belle_sip_request_t *pauline_register_req;
belle_sip_request_t *marie_register_req;
belle_sip_listener_callbacks_t caller_listener_callbacks;
belle_sip_listener_callbacks_t callee_listener_callbacks;
belle_sip_request_t* req;
belle_sip_header_address_t* from;
belle_sip_header_address_t* to;
belle_sip_header_address_t* route;
belle_sip_header_allow_t* header_allow;
belle_sip_header_content_type_t* content_type ;
belle_sip_header_content_length_t* content_length;
belle_sip_client_transaction_t* client_transaction;
caller_listener_callbacks.process_dialog_terminated=process_dialog_terminated;
caller_listener_callbacks.process_io_error=process_io_error;
caller_listener_callbacks.process_request_event=process_request_event;
caller_listener_callbacks.process_response_event=process_response_event;
caller_listener_callbacks.process_timeout=process_timeout;
caller_listener_callbacks.process_transaction_terminated=process_transaction_terminated;
callee_listener_callbacks.process_dialog_terminated=process_dialog_terminated;
callee_listener_callbacks.process_io_error=process_io_error;
callee_listener_callbacks.process_request_event=process_request_event;
callee_listener_callbacks.process_response_event=process_response_event;
callee_listener_callbacks.process_timeout=process_timeout;
callee_listener_callbacks.process_transaction_terminated=process_transaction_terminated;
pauline_register_req=register_user(stack, prov, "TCP" ,1 ,CALLER);
marie_register_req=register_user(stack, prov, "TLS" ,1 ,CALLEE);
belle_sip_provider_add_sip_listener(prov,belle_sip_listener_create_from_callbacks(&caller_listener_callbacks,NULL));
belle_sip_provider_add_sip_listener(prov,belle_sip_listener_create_from_callbacks(&callee_listener_callbacks,NULL));
from=belle_sip_header_address_create(NULL,belle_sip_uri_create(CALLER,test_domain));
to=belle_sip_header_address_create(NULL,belle_sip_uri_create(CALLEE,test_domain));
route = belle_sip_header_address_create(NULL,belle_sip_uri_create(NULL,test_domain));
belle_sip_uri_set_transport_param(belle_sip_header_address_get_uri(route),"tcp");
req=build_request(stack,prov,from,to,route,"INVITE");
header_allow = belle_sip_header_allow_create("INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO");
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(header_allow));
content_length= belle_sip_header_content_length_create(strlen(sdp));
content_type = belle_sip_header_content_type_create("application","sdp");
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(content_type));
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(content_length));
belle_sip_message_set_body(BELLE_SIP_MESSAGE(req),sdp,strlen(sdp));
client_transaction = belle_sip_provider_create_client_transaction(prov,req);
//belle_sip_transaction_set_application_data(BELLE_SIP_TRANSACTION(client_transaction),op);
belle_sip_client_transaction_send_request(client_transaction);
belle_sip_stack_sleep(stack,3000);
unregister_user(stack, prov, pauline_register_req ,1);
unregister_user(stack, prov, marie_register_req ,1);
}
int belle_sip_dialog_test_suite(){
CU_pSuite pSuite = CU_add_suite("Dialog", init, uninit);
if (NULL == CU_add_test(pSuite, "simple call", simple_call)) {
return CU_get_error();
}
return 0;
}
......@@ -24,8 +24,9 @@
const char *test_domain="test.linphone.org";
static int is_register_ok;
static int using_transaction;
static belle_sip_stack_t * stack;
static belle_sip_provider_t *prov;
belle_sip_stack_t * stack;
belle_sip_provider_t *prov;
static belle_sip_listener_t* l;
static void process_dialog_terminated(belle_sip_listener_t *obj, const belle_sip_dialog_terminated_event_t *event){
belle_sip_message("process_dialog_terminated called");
......@@ -84,7 +85,7 @@ BELLE_SIP_INSTANCIATE_VPTR(test_listener_t,belle_sip_object_t,NULL,NULL,NULL,FAL
static test_listener_t *listener;
static int init(void) {
int register_init(void) {
stack=belle_sip_stack_new(NULL);
belle_sip_listening_point_t *lp=belle_sip_stack_create_listening_point(stack,"0.0.0.0",7060,"UDP");
prov=belle_sip_stack_create_provider(stack,lp);
......@@ -98,16 +99,43 @@ static int init(void) {
belle_sip_object_unref(lp);
}
listener=belle_sip_object_new(test_listener_t);
belle_sip_provider_add_sip_listener(prov,BELLE_SIP_LISTENER(listener));
return 0;
}
static int uninit(void) {
int register_uninit(void) {
belle_sip_object_unref(prov);
belle_sip_object_unref(stack);
belle_sip_object_unref(listener);
return 0;
}
static void register_test(const char *transport, int use_transaction) {
void unregister_user(belle_sip_stack_t * stack
,belle_sip_provider_t *prov
,belle_sip_request_t* initial_request
,int use_transaction) {
belle_sip_request_t *req;
belle_sip_provider_add_sip_listener(prov,l);
is_register_ok=0;
using_transaction=0;
req=(belle_sip_request_t*)belle_sip_object_clone((belle_sip_object_t*)initial_request);
belle_sip_header_cseq_t* cseq=(belle_sip_header_cseq_t*)belle_sip_message_get_header((belle_sip_message_t*)req,BELLE_SIP_CSEQ);
belle_sip_header_cseq_set_seq_number(cseq,belle_sip_header_cseq_get_seq_number(cseq)+1);
belle_sip_header_expires_t* expires_header=(belle_sip_header_expires_t*)belle_sip_message_get_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_EXPIRES);
belle_sip_header_expires_set_expires(expires_header,0);
if (use_transaction){
belle_sip_client_transaction_t *t=belle_sip_provider_create_client_transaction(prov,req);
belle_sip_client_transaction_send_request(t);
}else belle_sip_provider_send_request(prov,req);
belle_sip_stack_sleep(stack,33000);
CU_ASSERT_EQUAL(is_register_ok,1);
CU_ASSERT_EQUAL(using_transaction,use_transaction);
belle_sip_provider_remove_sip_listener(prov,l);
}
belle_sip_request_t* register_user(belle_sip_stack_t * stack
,belle_sip_provider_t *prov
,const char *transport
,int use_transaction
,const char* username) {
belle_sip_request_t *req;
char identity[256];
char uri[256];
......@@ -118,10 +146,10 @@ static void register_test(const char *transport, int use_transaction) {
if (transport && strcasecmp("tls",transport)==0 && belle_sip_provider_get_listening_point(prov,"tls")==NULL){
belle_sip_error("No TLS support, test skipped.");
return;
return NULL;
}
snprintf(identity,sizeof(identity),"Tester <sip:tester@%s>",test_domain);
snprintf(identity,sizeof(identity),"Tester <sip:%s@%s>",username,test_domain);
req=belle_sip_request_create(
belle_sip_uri_parse(uri),
"REGISTER",
......@@ -136,6 +164,7 @@ static void register_test(const char *transport, int use_transaction) {
using_transaction=0;
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_expires_create(600)));
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_contact_new()));
belle_sip_provider_add_sip_listener(prov,l=BELLE_SIP_LISTENER(listener));
if (use_transaction){
belle_sip_client_transaction_t *t=belle_sip_provider_create_client_transaction(prov,req);
belle_sip_client_transaction_send_request(t);
......@@ -143,25 +172,17 @@ static void register_test(const char *transport, int use_transaction) {
belle_sip_stack_sleep(stack,33000);
CU_ASSERT_EQUAL(is_register_ok,1);
CU_ASSERT_EQUAL(using_transaction,use_transaction);
/*unregister*/
is_register_ok=0;
using_transaction=0;
req=(belle_sip_request_t*)belle_sip_object_clone((belle_sip_object_t*)req);
belle_sip_header_cseq_t* cseq=(belle_sip_header_cseq_t*)belle_sip_message_get_header((belle_sip_message_t*)req,BELLE_SIP_CSEQ);
belle_sip_header_cseq_set_seq_number(cseq,belle_sip_header_cseq_get_seq_number(cseq)+1);
belle_sip_header_expires_t* expires_header=(belle_sip_header_expires_t*)belle_sip_message_get_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_EXPIRES);
belle_sip_header_expires_set_expires(expires_header,0);
if (use_transaction){
belle_sip_client_transaction_t *t=belle_sip_provider_create_client_transaction(prov,req);
belle_sip_client_transaction_send_request(t);
}else belle_sip_provider_send_request(prov,req);
belle_sip_stack_sleep(stack,33000);
CU_ASSERT_EQUAL(is_register_ok,1);
CU_ASSERT_EQUAL(using_transaction,use_transaction);
return;
belle_sip_provider_remove_sip_listener(prov,l);
return req;
}
static void register_test(const char *transport, int use_transaction) {
belle_sip_request_t *req;
req=register_user(stack, prov, transport,use_transaction,"tester");
unregister_user(stack,prov,req,use_transaction);
}
static void stateless_register_udp(void){
register_test(NULL,0);
......@@ -193,8 +214,52 @@ static void stateful_register_tls(void){
register_test("tls",1);
}
static void bad_req_process_io_error(void *user_ctx, const belle_sip_io_error_event_t *event){
belle_sip_message("bad_req_process_io_error not implemented yet");
}
static void bad_req_process_response_event(void *user_ctx, const belle_sip_response_event_t *event){
belle_sip_message("bad_req_process_response_event not implemented yet");
}
static void test_bad_request() {
belle_sip_request_t *req;
belle_sip_header_address_t* route_address=belle_sip_header_address_create(NULL,belle_sip_uri_create(NULL,test_domain));
belle_sip_header_route_t* route;
belle_sip_header_to_t* to = belle_sip_header_to_create2("sip:toto@titi.com",NULL);
belle_sip_listener_callbacks_t cbs;
memset(&cbs,0,sizeof(cbs));
belle_sip_listener_t* bad_req_listener = belle_sip_listener_create_from_callbacks(&cbs,NULL);
cbs.process_io_error=bad_req_process_io_error;
cbs.process_response_event=bad_req_process_response_event;
req=belle_sip_request_create(
BELLE_SIP_URI(belle_sip_object_clone(BELLE_SIP_OBJECT(belle_sip_header_address_get_uri(route_address)))),
"REGISTER",
belle_sip_provider_create_call_id(prov),
belle_sip_header_cseq_create(20,"REGISTER"),
belle_sip_header_from_create2("sip:toto@titi.com",BELLE_SIP_RANDOM_TAG),
to,
belle_sip_header_via_new(),
70);
belle_sip_uri_set_transport_param(belle_sip_header_address_get_uri(route_address),"tcp");
route = belle_sip_header_route_create(route_address);
belle_sip_header_set_name(BELLE_SIP_HEADER(to),"BrokenHeader");
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_expires_create(600)));
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(route));
belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_contact_new()));
belle_sip_provider_add_sip_listener(prov,bad_req_listener);
belle_sip_client_transaction_t *t=belle_sip_provider_create_client_transaction(prov,req);
belle_sip_client_transaction_send_request(t);
belle_sip_stack_sleep(stack,100);
belle_sip_provider_remove_sip_listener(prov,bad_req_listener);
}
int belle_sip_register_test_suite(){
CU_pSuite pSuite = CU_add_suite("Register test suite", init, uninit);
CU_pSuite pSuite = CU_add_suite("Register", register_init, register_uninit);
if (NULL == CU_add_test(pSuite, "stateful udp register", stateful_register_udp)) {
return CU_get_error();
......@@ -217,6 +282,9 @@ int belle_sip_register_test_suite(){
if (NULL == CU_add_test(pSuite, "stateless tls register", stateless_register_tls)) {
return CU_get_error();
}
if (NULL == CU_add_test(pSuite, "Bad request tcp", test_bad_request)) {
return CU_get_error();
}
return 0;
}
......@@ -27,9 +27,12 @@ extern int belle_sdp_test_suite();
extern int belle_sip_authentication_helper_suite ();
extern int belle_sip_cast_test_suite();
extern int belle_sip_register_test_suite();
extern int belle_sip_dialog_test_suite();
int main (int argc, char *argv[]) {
int i;
char *suite_name;
CU_pSuite suite;
const char *env_domain=getenv("TEST_DOMAIN");
if (env_domain)
test_domain=env_domain;
......@@ -43,6 +46,9 @@ int main (int argc, char *argv[]) {
}else if (strcmp(argv[i],"--domain")==0){
i++;
test_domain=argv[i];
}else if (strcmp(argv[i],"--suite")==0){
i++;
suite_name=argv[i];
}
}
......@@ -63,9 +69,16 @@ int main (int argc, char *argv[]) {
belle_sip_authentication_helper_suite();
belle_sip_register_test_suite();
belle_sip_dialog_test_suite ();
/* Run all tests using the CUnit Basic interface */
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
if (suite_name && (suite=CU_get_suite(suite_name))) {
CU_basic_run_suite(suite);
} else
CU_basic_run_tests();
CU_cleanup_registry();
return CU_get_error();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment