Commit 2a090655 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Fixed vcard tests using new dav server

parent 2381e157
......@@ -430,10 +430,11 @@ static void linphone_carddav_send_query(LinphoneCardDavQuery *query) {
belle_generic_uri_t *uri = NULL;
belle_http_request_t *req = NULL;
belle_sip_memory_body_handler_t *bh = NULL;
LinphoneCardDavContext *cdc = query->context;
char* ua = NULL;
uri = belle_generic_uri_parse(query->url);
if (!uri) {
LinphoneCardDavContext *cdc = query->context;
if (cdc && cdc->sync_done_cb) {
cdc->sync_done_cb(cdc, FALSE, "Could not send request, URL is invalid");
}
......@@ -443,7 +444,6 @@ static void linphone_carddav_send_query(LinphoneCardDavQuery *query) {
req = belle_http_request_create(query->method, uri, belle_sip_header_content_type_create("application", "xml; charset=utf-8"), NULL);
if (!req) {
LinphoneCardDavContext *cdc = query->context;
if (cdc && cdc->sync_done_cb) {
cdc->sync_done_cb(cdc, FALSE, "Could not create belle_http_request_t");
}
......@@ -452,6 +452,9 @@ static void linphone_carddav_send_query(LinphoneCardDavQuery *query) {
return;
}
ua = ms_strdup_printf("%s/%s", linphone_core_get_user_agent(cdc->friend_list->lc), linphone_core_get_version());
belle_sip_message_add_header((belle_sip_message_t *)req, belle_sip_header_create("User-Agent", ua));
ms_free(ua);
if (query->depth) {
belle_sip_message_add_header((belle_sip_message_t *)req, belle_sip_header_create("Depth", query->depth));
} else if (query->ifmatch) {
......
......@@ -7,6 +7,6 @@ sip_random_port=1
[auth_info_0]
domain=dav.linphone.org
username=sylvain
ha1=4747ce2517a985f2fc20234a38f068b6
realm=SabreDAV
\ No newline at end of file
username=tester
ha1=102bdd8ccafef75cf7572c97969afd9a
realm=BaikalDAV
\ No newline at end of file
......@@ -23,6 +23,8 @@
#include <time.h>
#define CARDDAV_SERVER "http://dav.linphone.org/card.php/addressbooks/tester/default"
#ifdef VCARD_ENABLED
static char *create_filepath(const char *dir, const char *filename, const char *ext) {
return ms_strdup_printf("%s/%s.%s", dir, filename, ext);
......@@ -390,7 +392,7 @@ static void carddav_sync(void) {
LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc);
LinphoneCardDavContext *c = NULL;
linphone_friend_list_set_uri(lfl, "http://dav.linphone.org/sabredav/addressbookserver.php/addressbooks/sylvain/default");
linphone_friend_list_set_uri(lfl, CARDDAV_SERVER);
linphone_core_add_friend_list(manager->lc, lfl);
linphone_friend_list_unref(lfl);
c = linphone_carddav_context_new(lfl);
......@@ -421,7 +423,7 @@ static void carddav_sync_2(void) {
LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc);
LinphoneCardDavContext *c = NULL;
linphone_friend_list_set_uri(lfl, "http://dav.linphone.org/sabredav/addressbookserver.php/addressbooks/sylvain/default");
linphone_friend_list_set_uri(lfl, CARDDAV_SERVER);
linphone_core_add_friend_list(manager->lc, lfl);
linphone_friend_list_unref(lfl);
c = linphone_carddav_context_new(lfl);
......@@ -463,7 +465,7 @@ static void carddav_sync_3(void) {
LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc);
LinphoneCardDavContext *c = NULL;
linphone_friend_list_set_uri(lfl, "http://dav.linphone.org/sabredav/addressbookserver.php/addressbooks/sylvain/default");
linphone_friend_list_set_uri(lfl, CARDDAV_SERVER);
linphone_core_add_friend_list(manager->lc, lfl);
linphone_friend_list_unref(lfl);
c = linphone_carddav_context_new(lfl);
......@@ -502,7 +504,7 @@ static void carddav_sync_4(void) {
LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc);
LinphoneCardDavContext *c = NULL;
linphone_friend_list_set_uri(lfl, "http://dav.linphone.org/sabredav/addressbookserver.php/addressbooks/sylvain/default");
linphone_friend_list_set_uri(lfl, CARDDAV_SERVER);
linphone_core_add_friend_list(manager->lc, lfl);
linphone_friend_list_unref(lfl);
c = linphone_carddav_context_new(lfl);
......@@ -566,7 +568,7 @@ static void carddav_integration(void) {
LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1);
const char *refkey = "toto";
linphone_friend_list_set_uri(lfl, "http://dav.linphone.org/sabredav/addressbookserver.php/addressbooks/sylvain/default");
linphone_friend_list_set_uri(lfl, CARDDAV_SERVER);
cbs = linphone_friend_list_get_callbacks(lfl);
linphone_friend_list_cbs_set_user_data(cbs, stats);
linphone_friend_list_cbs_set_contact_created(cbs, carddav_contact_created);
......@@ -596,7 +598,7 @@ static void carddav_integration(void) {
linphone_friend_unref(lf);
lvc2 = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sberfini@sip.linphone.org\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nEND:VCARD\r\n");
linphone_vcard_set_url(lvc2, "/sabredav/addressbookserver.php/addressbooks/sylvain/default/me.vcf");
linphone_vcard_set_url(lvc2, "/card.php/addressbooks/tester/default/me.vcf");
lf2 = linphone_friend_new_from_vcard(lvc2);
linphone_friend_set_ref_key(lf2, refkey);
BC_ASSERT_EQUAL(linphone_friend_list_add_local_friend(lfl, lf2), LinphoneFriendListOK, int, "%d");
......@@ -650,7 +652,7 @@ static void carddav_clean(void) { // This is to ensure the content of the test
linphone_friend_list_cbs_set_contact_updated(cbs, carddav_contact_updated);
linphone_friend_list_cbs_set_sync_status_changed(cbs, carddav_sync_status_changed);
linphone_core_add_friend_list(manager->lc, lfl);
linphone_friend_list_set_uri(lfl, "http://dav.linphone.org/sabredav/addressbookserver.php/addressbooks/sylvain/default");
linphone_friend_list_set_uri(lfl, CARDDAV_SERVER);
linphone_friend_list_synchronize_friends_from_server(lfl);
wait_for_until(manager->lc, NULL, &stats->sync_done_count, 1, 2000);
......@@ -669,7 +671,7 @@ static void carddav_clean(void) { // This is to ensure the content of the test
}
lvc = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sylvain@sip.linphone.org\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nEND:VCARD\r\n");
linphone_vcard_set_url(lvc, "http://dav.linphone.org/sabredav/addressbookserver.php/addressbooks/sylvain/default/me.vcf");
linphone_vcard_set_url(lvc, "http://dav.linphone.org/card.php/addressbooks/tester/default/me.vcf");
lf = linphone_friend_new_from_vcard(lvc);
linphone_friend_list_add_friend(lfl, lf);
wait_for_until(manager->lc, NULL, &stats->sync_done_count, 1, 2000);
......@@ -693,7 +695,7 @@ static void carddav_multiple_sync(void) {
linphone_friend_list_cbs_set_contact_updated(cbs, carddav_contact_updated);
linphone_friend_list_cbs_set_sync_status_changed(cbs, carddav_sync_status_changed);
linphone_core_add_friend_list(manager->lc, lfl);
linphone_friend_list_set_uri(lfl, "http://dav.linphone.org/sabredav/addressbookserver.php/addressbooks/sylvain/default");
linphone_friend_list_set_uri(lfl, CARDDAV_SERVER);
linphone_friend_list_synchronize_friends_from_server(lfl);
wait_for_until(manager->lc, NULL, &stats->sync_done_count, 1, 2000);
......
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