Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Initial work started on using ConnectionObject on Win32 systems
[xestiaab/.git] / source / tests / xestiaab_carddav.cpp
1 // xestiaab_carddav.h - Xestia Address Book CardDAV Object Unit Tests.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include <gtest/gtest.h>
20 #include "classes/FakeConnectionObject.h"
21 #include <chrono>
22 #include <thread>
24 // TODO: Add tests for the CardDAV object.
26 TEST(CardDAV, Use_Fake_To_Setup_And_Check_Connection_Settings_With_TestMode_True){
27         
28         std::string ServerAddress1 = "gibberish.invalid";
29         std::string ServerUser1 = "user";
30         std::string ServerPass1 = "pass";
32         std::string ServerAddress2 = "gibberish2.invalid";
33         std::string ServerUser2 = "user2";
34         std::string ServerPass2 = "pass2";
35         
36         std::string ServerAddress3 = "gibberish3.invalid";
37         std::string ServerUser3 = "user3";
38         std::string ServerPass3 = "pass3";
39         
40         FakeConnectionObject FakeConnection1(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
41         FakeConnectionObject FakeConnection2(ServerAddress2, 8800, ServerUser2, ServerPass2, true);
42         FakeConnectionObject FakeConnection3(ServerAddress3, 8008, ServerUser3, ServerPass3, false);
43         
44         EXPECT_EQ("gibberish.invalid", FakeConnection1.GetServerAddress());
45         EXPECT_EQ(8080, FakeConnection1.GetServerPort());
46         EXPECT_EQ("user", FakeConnection1.GetServerUser());
47         EXPECT_EQ("pass", FakeConnection1.GetServerPass());
48         EXPECT_EQ(true, FakeConnection1.GetServerSSL());
49         EXPECT_EQ(true, FakeConnection1.GetTestMode());
51         EXPECT_EQ("gibberish2.invalid", FakeConnection2.GetServerAddress());
52         EXPECT_EQ(8800, FakeConnection2.GetServerPort());
53         EXPECT_EQ("user2", FakeConnection2.GetServerUser());
54         EXPECT_EQ("pass2", FakeConnection2.GetServerPass());
55         EXPECT_EQ(true, FakeConnection2.GetServerSSL());
56         EXPECT_EQ(true, FakeConnection2.GetTestMode());
58         EXPECT_EQ("gibberish3.invalid", FakeConnection3.GetServerAddress());
59         EXPECT_EQ(8008, FakeConnection3.GetServerPort());
60         EXPECT_EQ("user3", FakeConnection3.GetServerUser());
61         EXPECT_EQ("pass3", FakeConnection3.GetServerPass());
62         EXPECT_EQ(false, FakeConnection3.GetServerSSL());
63         EXPECT_EQ(true, FakeConnection3.GetTestMode());
65 }
67 TEST(CardDAV, Use_Fake_To_Setup_And_Check_Connection_Settings_With_TestMode_False){
68         
69         std::string ServerAddress1 = "gibberish.invalid";
70         std::string ServerUser1 = "user";
71         std::string ServerPass1 = "pass";
72         std::string ServerPrefix1 = "/prefix";
73         std::string ServerAccount1 = "Account1";
75         std::string ServerAddress2 = "gibberish2.invalid";
76         std::string ServerUser2 = "user2";
77         std::string ServerPass2 = "pass2";
78         std::string ServerPrefix2 = "/prefix2";
79         std::string ServerAccount2 = "Account2";
80         
81         std::string ServerAddress3 = "gibberish3.invalid";
82         std::string ServerUser3 = "user3";
83         std::string ServerPass3 = "pass3";
84         std::string ServerPrefix3 = "/prefix3";
85         std::string ServerAccount3 = "Account3";
86         
87         FakeConnectionObject FakeConnection1(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
88         FakeConnectionObject FakeConnection2(ServerAddress2, 8800, ServerUser2, ServerPass2, true, "/prefix2", "Account2");
89         FakeConnectionObject FakeConnection3(ServerAddress3, 8008, ServerUser3, ServerPass3, false, "/prefix3", "Account3");
90         
91         EXPECT_EQ("gibberish.invalid", FakeConnection1.GetServerAddress());
92         EXPECT_EQ(8080, FakeConnection1.GetServerPort());
93         EXPECT_EQ("user", FakeConnection1.GetServerUser());
94         EXPECT_EQ("pass", FakeConnection1.GetServerPass());
95         EXPECT_EQ(true, FakeConnection1.GetServerSSL());
96         EXPECT_EQ(false, FakeConnection1.GetTestMode());
97         EXPECT_EQ("/prefix", FakeConnection1.GetServerPrefix());
98         EXPECT_EQ("Account1", FakeConnection1.GetServerAccount());
100         EXPECT_EQ("gibberish2.invalid", FakeConnection2.GetServerAddress());
101         EXPECT_EQ(8800, FakeConnection2.GetServerPort());
102         EXPECT_EQ("user2", FakeConnection2.GetServerUser());
103         EXPECT_EQ("pass2", FakeConnection2.GetServerPass());
104         EXPECT_EQ(true, FakeConnection2.GetServerSSL());
105         EXPECT_EQ(false, FakeConnection2.GetTestMode());
106         EXPECT_EQ("/prefix2", FakeConnection2.GetServerPrefix());
107         EXPECT_EQ("Account2", FakeConnection2.GetServerAccount());
109         EXPECT_EQ("gibberish3.invalid", FakeConnection3.GetServerAddress());
110         EXPECT_EQ(8008, FakeConnection3.GetServerPort());
111         EXPECT_EQ("user3", FakeConnection3.GetServerUser());
112         EXPECT_EQ("pass3", FakeConnection3.GetServerPass());
113         EXPECT_EQ(false, FakeConnection3.GetServerSSL());
114         EXPECT_EQ(false, FakeConnection3.GetTestMode());
115         EXPECT_EQ("/prefix3", FakeConnection3.GetServerPrefix());
116         EXPECT_EQ("Account3", FakeConnection3.GetServerAccount());
120 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_Returning_Success){
121         
122         std::string ServerAddress1 = "gibberish.invalid";
123         std::string ServerUser1 = "user";
124         std::string ServerPass1 = "pass";
125         
126         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
127         FakeConnection.ResultStatus = COCONNECT_OK;
128         
129         EXPECT_EQ(COCONNECT_OK, FakeConnection.Connect(false));
130         
133 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_Returning_InvalidAddress){
134         
135         std::string ServerAddress1 = "gibberish.invalid";
136         std::string ServerUser1 = "user";
137         std::string ServerPass1 = "pass";
138         
139         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
140         FakeConnection.ResultStatus = COCONNECT_INVALID;
141         
142         EXPECT_EQ(COCONNECT_INVALID, FakeConnection.Connect(false));
143         
146 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_Returning_Timeout){
148         std::string ServerAddress1 = "gibberish.invalid";
149         std::string ServerUser1 = "user";
150         std::string ServerPass1 = "pass";
151         
152         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
153         FakeConnection.ResultStatus = COCONNECT_TIMEOUT;
154         
155         EXPECT_EQ(COCONNECT_TIMEOUT, FakeConnection.Connect(false));
156         
159 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_Returning_Authentication_Failure){
161         std::string ServerAddress1 = "gibberish.invalid";
162         std::string ServerUser1 = "user";
163         std::string ServerPass1 = "pass";
164         
165         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
166         FakeConnection.ResultStatus = COCONNECT_AUTHFAIL;
167         
168         EXPECT_EQ(COCONNECT_AUTHFAIL, FakeConnection.Connect(false));
169         
172 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Is_Able_To_Login){
173         
174         std::string ServerAddress1 = "gibberish.invalid";
175         std::string ServerUser1 = "user";
176         std::string ServerPass1 = "pass";
177         
178         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
179         FakeConnection.ResultAuthPassed = true;
180         FakeConnection.Connect(false);
181         
182         EXPECT_EQ(true, FakeConnection.AbleToLogin());
183         
186 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Is_Unable_To_Login){
187         
188         std::string ServerAddress1 = "gibberish.invalid";
189         std::string ServerUser1 = "user";
190         std::string ServerPass1 = "pass";
191         
192         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
193         FakeConnection.ResultAuthPassed = false;
194         FakeConnection.Connect(false);
195         
196         EXPECT_EQ(false, FakeConnection.AbleToLogin());
197         
200 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Can_Do_Processing){
201         
202         std::string ServerAddress1 = "gibberish.invalid";
203         std::string ServerUser1 = "user";
204         std::string ServerPass1 = "pass";
205         
206         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
207         FakeConnection.ResultCanProcess = true;
208         FakeConnection.Connect(false);
209         
210         EXPECT_EQ(true, FakeConnection.CanDoProcessing());
211         
214 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Supports_SSL){
215         
216         std::string ServerAddress1 = "gibberish.invalid";
217         std::string ServerUser1 = "user";
218         std::string ServerPass1 = "pass";
219         
220         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
221         FakeConnection.ResultSSLStatus  = true;
222         FakeConnection.Connect(false);
223         
224         EXPECT_EQ(true, FakeConnection.CanDoSSL());
225         
228 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Does_Not_Support_SSL){
229         
230         std::string ServerAddress1 = "gibberish.invalid";
231         std::string ServerUser1 = "user";
232         std::string ServerPass1 = "pass";
233         
234         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
235         FakeConnection.ResultSSLStatus  = false;
236         FakeConnection.Connect(false);
237         
238         EXPECT_EQ(false, FakeConnection.CanDoSSL());
239         
242 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Has_Valid_SSL_Certificate_Data){
243         
244         std::string ServerAddress1 = "gibberish.invalid";
245         std::string ServerUser1 = "user";
246         std::string ServerPass1 = "pass";
247         
248         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
249         FakeConnection.ResultSSLVerified = COSSL_VERIFIED;
250         FakeConnection.Connect(false);
251         
252         EXPECT_EQ(COSSL_VERIFIED, FakeConnection.SSLVerify());
253         
256 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Has_Invalid_SSL_Certificate_Data){
257         
258         std::string ServerAddress1 = "gibberish.invalid";
259         std::string ServerUser1 = "user";
260         std::string ServerPass1 = "pass";
261         
262         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
263         FakeConnection.ResultSSLVerified = COSSL_UNABLETOVERIFY;
264         FakeConnection.ResultStatus = COCONNECT_SSLFAIL;
265         
266         EXPECT_EQ(COCONNECT_SSLFAIL, FakeConnection.Connect(false));
267         EXPECT_EQ(COSSL_UNABLETOVERIFY, FakeConnection.SSLVerify());
268         
271 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Has_User_Verified_SSL_Cerficiate_Data){
272         
273         std::string ServerAddress1 = "gibberish.invalid";
274         std::string ServerUser1 = "user";
275         std::string ServerPass1 = "pass";
276         
277         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
278         FakeConnection.ResultSSLVerified = COSSL_VERIFIED_USER;
279         FakeConnection.Connect(false);
280         
281         EXPECT_EQ(COSSL_VERIFIED_USER, FakeConnection.SSLVerify());
282         
285 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Doesnt_Use_SSL_Return_Not_Applicable_SSL_Result){
286         
287         std::string ServerAddress1 = "gibberish.invalid";
288         std::string ServerUser1 = "user";
289         std::string ServerPass1 = "pass";
290         
291         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, false);
292         FakeConnection.ResultSSLVerified = COSSL_NOTAPPLICABLE;
293         FakeConnection.Connect(false);
294         
295         EXPECT_EQ(COSSL_NOTAPPLICABLE, FakeConnection.SSLVerify());
296         
299 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Has_A_Valid_Response){
300         
301         std::string ServerAddress1 = "gibberish.invalid";
302         std::string ServerUser1 = "user";
303         std::string ServerPass1 = "pass";
304         
305         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
306         FakeConnection.ResultValidResponse = true;
307         FakeConnection.Connect(false);
308         
309         EXPECT_EQ(true, FakeConnection.HasValidResponse());
310         
313 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Has_A_Invalid_Response){
314         
315         std::string ServerAddress1 = "gibberish.invalid";
316         std::string ServerUser1 = "user";
317         std::string ServerPass1 = "pass";
318         
319         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
320         FakeConnection.ResultValidResponse = false;
321         FakeConnection.Connect(false);
322         
323         EXPECT_EQ(false, FakeConnection.HasValidResponse());
324         
327 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Uses_A_Self_Signed_SSL_Certificate){
328         
329         std::string ServerAddress1 = "gibberish.invalid";
330         std::string ServerUser1 = "user";
331         std::string ServerPass1 = "pass";
332         
333         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
334         FakeConnection.ResultSelfSigned = true;
335         FakeConnection.Connect(false);
336         
337         EXPECT_EQ(true, FakeConnection.IsSelfSigned());
338         
341 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Doesnt_Use_A_Self_Signed_SSL_Certificate){
342         
343         std::string ServerAddress1 = "gibberish.invalid";
344         std::string ServerUser1 = "user";
345         std::string ServerPass1 = "pass";
346         
347         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
348         FakeConnection.ResultSelfSigned = false;
349         FakeConnection.Connect(false);
350         
351         EXPECT_EQ(false, FakeConnection.IsSelfSigned());
352         
355 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Gets_The_Server_Prefix_Of_Prefix_Test_A){
356         
357         std::string ServerAddress1 = "gibberish.invalid";
358         std::string ServerUser1 = "user";
359         std::string ServerPass1 = "pass";
360         
361         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
362         FakeConnection.ResultServerPrefix = "/prefix/test/a";
363         FakeConnection.Connect(false);
364         
365         EXPECT_EQ("/prefix/test/a", FakeConnection.GetDefaultPrefix());
366         
369 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Gets_The_Server_Prefix_Of_Prefix_Test_B){
370         
371         std::string ServerAddress1 = "gibberish.invalid";
372         std::string ServerUser1 = "user";
373         std::string ServerPass1 = "pass";
374         
375         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
376         FakeConnection.ResultServerPrefix = "/prefix/test/b";
377         FakeConnection.Connect(false);
378         
379         EXPECT_EQ("/prefix/test/b", FakeConnection.GetDefaultPrefix());
380         
383 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Adds_A_Contact_Successfully){
384         
385         std::string ServerAddress1 = "gibberish.invalid";
386         std::string ServerUser1 = "user";
387         std::string ServerPass1 = "pass";
388         
389         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
390         FakeConnection.ResultServerPrefix = "/prefix/test/b";
391         FakeConnection.Connect(false);
392         
393         std::string ContactFile =
394         "BEGIN:VCARD\n"
395         "VERSION:4.0\n"
396         "UID:84q2ioj13jofiujqwr\n"
397         "N:;;Meep;Moop;;\n"
398         "FN:The Meep Moop\n"
399         "END:VCARD";
400         
401         FakeConnection.TestRequestResult = COREQUEST_OK;
402         FakeConnection.TestEntityTag = "4324svafhuiaffsdhui";
403         FakeConnection.TestResultCode = 201;
404         FakeConnection.TestSessionCode = 0;
405         FakeConnection.TestResultMessage = "";
406         
407         COServerResponse AddContactResult = FakeConnection.AddContact("testfile.vcf", ContactFile);
408         
409         EXPECT_EQ(COREQUEST_OK, AddContactResult.RequestResult);
410         EXPECT_EQ("4324svafhuiaffsdhui", AddContactResult.EntityTag);
411         EXPECT_EQ(201, AddContactResult.ResultCode);
412         EXPECT_EQ(0, AddContactResult.SessionCode);
413         EXPECT_EQ("", AddContactResult.ResultMessage);
414         
417 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Add_A_Contact_Due_To_Permissions){
418         
419         std::string ServerAddress1 = "gibberish.invalid";
420         std::string ServerUser1 = "user";
421         std::string ServerPass1 = "pass";
422         
423         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
424         FakeConnection.ResultServerPrefix = "/prefix/test/b";
425         FakeConnection.Connect(false);
426         
427         std::string ContactFile =
428         "BEGIN:VCARD\n"
429         "VERSION:4.0\n"
430         "UID:84q2ioj13jofiujqwr\n"
431         "N:;;Meep;Moop;;\n"
432         "FN:The Meep Moop\n"
433         "END:VCARD";
434         
435         FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
436         FakeConnection.TestEntityTag = "";
437         FakeConnection.TestResultCode = 403;
438         FakeConnection.TestSessionCode = 22;
439         FakeConnection.TestResultMessage = "You do not have permission to add this resource.";
440         
441         COServerResponse AddContactResult = FakeConnection.AddContact("testfile.vcf", ContactFile);
442         
443         EXPECT_EQ(COREQUEST_ERROR_SERVER, AddContactResult.RequestResult);
444         EXPECT_EQ("", AddContactResult.EntityTag);
445         EXPECT_EQ(403, AddContactResult.ResultCode);
446         EXPECT_EQ(22, AddContactResult.SessionCode);
447         EXPECT_EQ("You do not have permission to add this resource.", AddContactResult.ResultMessage);
448         
451 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Add_A_Contact_Due_To_Invalid_Path){
452         
453         std::string ServerAddress1 = "gibberish.invalid";
454         std::string ServerUser1 = "user";
455         std::string ServerPass1 = "pass";
456         
457         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
458         FakeConnection.ResultServerPrefix = "/prefix/test/b";
459         FakeConnection.Connect(false);
460         
461         std::string ContactFile =
462         "BEGIN:VCARD\n"
463         "VERSION:4.0\n"
464         "UID:84q2ioj13jofiujqwr\n"
465         "N:;;Meep;Moop;;\n"
466         "FN:The Meep Moop\n"
467         "END:VCARD";
468         
469         FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
470         FakeConnection.TestEntityTag = "";
471         FakeConnection.TestResultCode = 404;
472         FakeConnection.TestSessionCode = 22;
473         FakeConnection.TestResultMessage = "The location cannot be found.";
474         
475         COServerResponse AddContactResult = FakeConnection.AddContact("testfile.vcf", ContactFile);
476         
477         EXPECT_EQ(COREQUEST_ERROR_SERVER, AddContactResult.RequestResult);
478         EXPECT_EQ("", AddContactResult.EntityTag);
479         EXPECT_EQ(404, AddContactResult.ResultCode);
480         EXPECT_EQ(22, AddContactResult.SessionCode);
481         EXPECT_EQ("The location cannot be found.", AddContactResult.ResultMessage);     
482         
485 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Add_A_Contact_Due_To_No_Connection){
486         
487         std::string ServerAddress1 = "gibberish.invalid";
488         std::string ServerUser1 = "user";
489         std::string ServerPass1 = "pass";
490         
491         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
492         FakeConnection.ResultServerPrefix = "/prefix/test/b";
493         FakeConnection.Connect(false);
494         
495         std::string ContactFile =
496         "BEGIN:VCARD\n"
497         "VERSION:4.0\n"
498         "UID:84q2ioj13jofiujqwr\n"
499         "N:;;Meep;Moop;;\n"
500         "FN:The Meep Moop\n"
501         "END:VCARD";
502         
503         FakeConnection.TestRequestResult = COREQUEST_ERROR_NOTCONNECTED;
504         FakeConnection.TestEntityTag = "";
505         FakeConnection.TestResultCode = 0;
506         FakeConnection.TestSessionCode = 0;
507         FakeConnection.TestResultMessage = "";
508         
509         COServerResponse AddContactResult = FakeConnection.AddContact("testfile.vcf", ContactFile);
510         
511         EXPECT_EQ(COREQUEST_ERROR_NOTCONNECTED, AddContactResult.RequestResult);
512         EXPECT_EQ("", AddContactResult.EntityTag);
513         EXPECT_EQ(0, AddContactResult.ResultCode);
514         EXPECT_EQ(0, AddContactResult.SessionCode);
515         EXPECT_EQ("", AddContactResult.ResultMessage);  
516         
519 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Edits_A_Server_Contact){
520         
521         std::string ServerAddress1 = "gibberish.invalid";
522         std::string ServerUser1 = "user";
523         std::string ServerPass1 = "pass";
524         
525         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
526         FakeConnection.ResultServerPrefix = "/prefix/test/b";
527         FakeConnection.Connect(false);
528         
529         std::string ContactFile =
530         "BEGIN:VCARD\n"
531         "VERSION:4.0\n"
532         "UID:84q2ioj13jofiujqwrAAA\n"
533         "N:;;Meep;Moop;;\n"
534         "FN:The Meep Moop\n"
535         "END:VCARD";
536         
537         FakeConnection.TestRequestResult = COREQUEST_OK;
538         FakeConnection.TestEntityTag = "a23124sfadfdvxc1646541bsdfaf";
539         FakeConnection.TestResultCode = 200;
540         FakeConnection.TestSessionCode = 0;
541         FakeConnection.TestResultMessage = "";
542         
543         COServerResponse EditContactResult = FakeConnection.EditContact("testfile.vcf", ContactFile);
544         
545         EXPECT_EQ(COREQUEST_OK, EditContactResult.RequestResult);
546         EXPECT_EQ("a23124sfadfdvxc1646541bsdfaf", EditContactResult.EntityTag);
547         EXPECT_EQ(200, EditContactResult.ResultCode);
548         EXPECT_EQ(0, EditContactResult.SessionCode);
549         EXPECT_EQ("", EditContactResult.ResultMessage);
551         FakeConnection.TestRequestResult = COREQUEST_OK;
552         FakeConnection.TestEntityTag = "asf84sa484saf614as64asvada4s6fas";
553         FakeConnection.TestResultCode = 204;
554         FakeConnection.TestSessionCode = 0;
555         FakeConnection.TestResultMessage = "";
557         EditContactResult = FakeConnection.EditContact("testfile.vcf", ContactFile);
559         EXPECT_EQ(COREQUEST_OK, EditContactResult.RequestResult);
560         EXPECT_EQ("asf84sa484saf614as64asvada4s6fas", EditContactResult.EntityTag);
561         EXPECT_EQ(204, EditContactResult.ResultCode);
562         EXPECT_EQ(0, EditContactResult.SessionCode);
563         EXPECT_EQ("", EditContactResult.ResultMessage);
567 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Edit_A_Server_Contact_Due_To_Invalid_Permissions){
568         
569         std::string ServerAddress1 = "gibberish.invalid";
570         std::string ServerUser1 = "user";
571         std::string ServerPass1 = "pass";
572         
573         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
574         FakeConnection.ResultServerPrefix = "/prefix/test/b";
575         FakeConnection.Connect(false);
576         
577         std::string ContactFile =
578         "BEGIN:VCARD\n"
579         "VERSION:4.0\n"
580         "UID:84q2ioj13jofiujqwrAAA\n"
581         "N:;;Meep;Moop;;\n"
582         "FN:The Meep Moop\n"
583         "END:VCARD";
584         
585         FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
586         FakeConnection.TestEntityTag = "";
587         FakeConnection.TestResultCode = 403;
588         FakeConnection.TestSessionCode = 22;
589         FakeConnection.TestResultMessage = "You do not have permission to add this resource.";
590         
591         COServerResponse EditContactResult = FakeConnection.EditContact("testfile.vcf", ContactFile);
592         
593         EXPECT_EQ(COREQUEST_ERROR_SERVER, EditContactResult.RequestResult);
594         EXPECT_EQ("", EditContactResult.EntityTag);
595         EXPECT_EQ(403, EditContactResult.ResultCode);
596         EXPECT_EQ(22, EditContactResult.SessionCode);
597         EXPECT_EQ("You do not have permission to add this resource.", EditContactResult.ResultMessage);
601 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Edit_A_Server_Contact_Due_To_Invalid_Location){
602         
603         std::string ServerAddress1 = "gibberish.invalid";
604         std::string ServerUser1 = "user";
605         std::string ServerPass1 = "pass";
606         
607         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
608         FakeConnection.ResultServerPrefix = "/prefix/test/b";
609         FakeConnection.Connect(false);
610         
611         std::string ContactFile =
612         "BEGIN:VCARD\n"
613         "VERSION:4.0\n"
614         "UID:84q2ioj13jofiujqwrAAA\n"
615         "N:;;Meep;Moop;;\n"
616         "FN:The Meep Moop\n"
617         "END:VCARD";
618         
619         FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
620         FakeConnection.TestEntityTag = "";
621         FakeConnection.TestResultCode = 404;
622         FakeConnection.TestSessionCode = 22;
623         FakeConnection.TestResultMessage = "The resource could not be found.";
624         
625         COServerResponse EditContactResult = FakeConnection.EditContact("testfile.vcf", ContactFile);
626         
627         EXPECT_EQ(COREQUEST_ERROR_SERVER, EditContactResult.RequestResult);
628         EXPECT_EQ("", EditContactResult.EntityTag);
629         EXPECT_EQ(404, EditContactResult.ResultCode);
630         EXPECT_EQ(22, EditContactResult.SessionCode);
631         EXPECT_EQ("The resource could not be found.", EditContactResult.ResultMessage);
635 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Edit_A_Server_Contact_Due_To_No_Connection){
636         
637         std::string ServerAddress1 = "gibberish.invalid";
638         std::string ServerUser1 = "user";
639         std::string ServerPass1 = "pass";
640         
641         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
642         FakeConnection.ResultServerPrefix = "/prefix/test/b";
643         FakeConnection.Connect(false);
644         
645         std::string ContactFile =
646         "BEGIN:VCARD\n"
647         "VERSION:4.0\n"
648         "UID:84q2ioj13jofiujqwrAAA\n"
649         "N:;;Meep;Moop;;\n"
650         "FN:The Meep Moop\n"
651         "END:VCARD";
652         
653         FakeConnection.TestRequestResult = COREQUEST_ERROR_NOTCONNECTED;
654         FakeConnection.TestEntityTag = "";
655         FakeConnection.TestResultCode = 0;
656         FakeConnection.TestSessionCode = 0;
657         FakeConnection.TestResultMessage = "";
658         
659         COServerResponse EditContactResult = FakeConnection.EditContact("testfile.vcf", ContactFile);
660         
661         EXPECT_EQ(COREQUEST_ERROR_NOTCONNECTED, EditContactResult.RequestResult);
662         EXPECT_EQ("", EditContactResult.EntityTag);
663         EXPECT_EQ(0, EditContactResult.ResultCode);
664         EXPECT_EQ(0, EditContactResult.SessionCode);
665         EXPECT_EQ("", EditContactResult.ResultMessage);
669 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Deletes_A_Server_Contact){
670         
671         std::string ServerAddress1 = "gibberish.invalid";
672         std::string ServerUser1 = "user";
673         std::string ServerPass1 = "pass";
674         
675         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
676         FakeConnection.ResultServerPrefix = "/prefix/test/b";
677         FakeConnection.Connect(false);
678         
679         FakeConnection.TestRequestResult = COREQUEST_OK;
680         FakeConnection.TestEntityTag = "";
681         FakeConnection.TestResultCode = 200;
682         FakeConnection.TestSessionCode = 0;
683         FakeConnection.TestResultMessage = "";
684         
685         COServerResponse DeleteContactResult = FakeConnection.DeleteContact("testfile.vcf");
686         
687         EXPECT_EQ(COREQUEST_OK, DeleteContactResult.RequestResult);
688         EXPECT_EQ("", DeleteContactResult.EntityTag);
689         EXPECT_EQ(200, DeleteContactResult.ResultCode);
690         EXPECT_EQ(0, DeleteContactResult.SessionCode);
691         EXPECT_EQ("", DeleteContactResult.ResultMessage);
693         FakeConnection.TestRequestResult = COREQUEST_OK;
694         FakeConnection.TestEntityTag = "";
695         FakeConnection.TestResultCode = 204;
696         FakeConnection.TestSessionCode = 0;
697         FakeConnection.TestResultMessage = "";
699         DeleteContactResult = FakeConnection.DeleteContact("testfile.vcf");
701         EXPECT_EQ(COREQUEST_OK, DeleteContactResult.RequestResult);
702         EXPECT_EQ("", DeleteContactResult.EntityTag);
703         EXPECT_EQ(204, DeleteContactResult.ResultCode);
704         EXPECT_EQ(0, DeleteContactResult.SessionCode);
705         EXPECT_EQ("", DeleteContactResult.ResultMessage);
709 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Delete_A_Server_Contact_Due_To_Invalid_Permissions){
710         
711         std::string ServerAddress1 = "gibberish.invalid";
712         std::string ServerUser1 = "user";
713         std::string ServerPass1 = "pass";
714         
715         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
716         FakeConnection.ResultServerPrefix = "/prefix/test/b";
717         FakeConnection.Connect(false);
718         
719         FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
720         FakeConnection.TestEntityTag = "";
721         FakeConnection.TestResultCode = 403;
722         FakeConnection.TestSessionCode = 22;
723         FakeConnection.TestResultMessage = "You do not have permission to delete this resource.";
724         
725         COServerResponse DeleteContactResult = FakeConnection.DeleteContact("testfile.vcf");
726         
727         EXPECT_EQ(COREQUEST_ERROR_SERVER, DeleteContactResult.RequestResult);
728         EXPECT_EQ("", DeleteContactResult.EntityTag);
729         EXPECT_EQ(403, DeleteContactResult.ResultCode);
730         EXPECT_EQ(22, DeleteContactResult.SessionCode);
731         EXPECT_EQ("You do not have permission to delete this resource.", DeleteContactResult.ResultMessage);
735 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Delete_A_Server_Contact_Due_To_Missing_Location){
736         
737         std::string ServerAddress1 = "gibberish.invalid";
738         std::string ServerUser1 = "user";
739         std::string ServerPass1 = "pass";
740         
741         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
742         FakeConnection.ResultServerPrefix = "/prefix/test/b";
743         FakeConnection.Connect(false);
744         
745         FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
746         FakeConnection.TestEntityTag = "";
747         FakeConnection.TestResultCode = 404;
748         FakeConnection.TestSessionCode = 22;
749         FakeConnection.TestResultMessage = "The resource could not be found.";
750         
751         COServerResponse DeleteContactResult = FakeConnection.DeleteContact("testfile.vcf");
752         
753         EXPECT_EQ(COREQUEST_ERROR_SERVER, DeleteContactResult.RequestResult);
754         EXPECT_EQ("", DeleteContactResult.EntityTag);
755         EXPECT_EQ(404, DeleteContactResult.ResultCode);
756         EXPECT_EQ(22, DeleteContactResult.SessionCode);
757         EXPECT_EQ("The resource could not be found.", DeleteContactResult.ResultMessage);
761 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Delete_A_Server_Contact_Due_To_No_Connection){
762         
763         std::string ServerAddress1 = "gibberish.invalid";
764         std::string ServerUser1 = "user";
765         std::string ServerPass1 = "pass";
766         
767         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
768         FakeConnection.ResultServerPrefix = "/prefix/test/b";
769         FakeConnection.Connect(false);
770         
771         FakeConnection.TestRequestResult = COREQUEST_ERROR_NOTCONNECTED;
772         FakeConnection.TestEntityTag = "";
773         FakeConnection.TestResultCode = 0;
774         FakeConnection.TestSessionCode = 0;
775         FakeConnection.TestResultMessage = "";
776         
777         COServerResponse DeleteContactResult = FakeConnection.DeleteContact("testfile.vcf");
778         
779         EXPECT_EQ(COREQUEST_ERROR_NOTCONNECTED, DeleteContactResult.RequestResult);
780         EXPECT_EQ("", DeleteContactResult.EntityTag);
781         EXPECT_EQ(0, DeleteContactResult.ResultCode);
782         EXPECT_EQ(0, DeleteContactResult.SessionCode);
783         EXPECT_EQ("", DeleteContactResult.ResultMessage);
787 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Gets_Server_Entity_Tag_Value){
788         
789         std::string ServerAddress1 = "gibberish.invalid";
790         std::string ServerUser1 = "user";
791         std::string ServerPass1 = "pass";
792         
793         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
794         FakeConnection.ResultServerPrefix = "/prefix/test/b";
795         FakeConnection.Connect(false);
796         
797         FakeConnection.TestRequestResult = COREQUEST_OK;
798         FakeConnection.TestEntityTag = "a23124sfadfdvxc1646541bsdfaf";
799         FakeConnection.TestResultCode = 200;
800         FakeConnection.TestSessionCode = 0;
801         FakeConnection.TestResultMessage = "";
802         
803         COServerResponse EntityTagResult = FakeConnection.GetServerEntityTagValue("testfile.vcf");
804         
805         EXPECT_EQ(COREQUEST_OK, EntityTagResult.RequestResult);
806         EXPECT_EQ("a23124sfadfdvxc1646541bsdfaf", EntityTagResult.EntityTag);
807         EXPECT_EQ(200, EntityTagResult.ResultCode);
808         EXPECT_EQ(0, EntityTagResult.SessionCode);
809         EXPECT_EQ("", EntityTagResult.ResultMessage);   
810         
813 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Get_Server_Entity_Tag_Value_Due_To_Invalid_Permissions){
814         
815         std::string ServerAddress1 = "gibberish.invalid";
816         std::string ServerUser1 = "user";
817         std::string ServerPass1 = "pass";
818         
819         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
820         FakeConnection.ResultServerPrefix = "/prefix/test/b";
821         FakeConnection.Connect(false);
822         
823         FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
824         FakeConnection.TestEntityTag = "";
825         FakeConnection.TestResultCode = 403;
826         FakeConnection.TestSessionCode = 22;
827         FakeConnection.TestResultMessage = "You do not have permission to access this resource.";
828         
829         COServerResponse EntityTagResult = FakeConnection.GetServerEntityTagValue("testfile.vcf");
830         
831         EXPECT_EQ(COREQUEST_ERROR_SERVER, EntityTagResult.RequestResult);
832         EXPECT_EQ("", EntityTagResult.EntityTag);
833         EXPECT_EQ(403, EntityTagResult.ResultCode);
834         EXPECT_EQ(22, EntityTagResult.SessionCode);
835         EXPECT_EQ("You do not have permission to access this resource.", EntityTagResult.ResultMessage);        
836         
839 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Get_Server_Entity_Tag_Value_Due_To_Missing_Resource){
840         
841         std::string ServerAddress1 = "gibberish.invalid";
842         std::string ServerUser1 = "user";
843         std::string ServerPass1 = "pass";
844         
845         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
846         FakeConnection.ResultServerPrefix = "/prefix/test/b";
847         FakeConnection.Connect(false);
848         
849         FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
850         FakeConnection.TestEntityTag = "";
851         FakeConnection.TestResultCode = 404;
852         FakeConnection.TestSessionCode = 22;
853         FakeConnection.TestResultMessage = "The resource cannot be found.";
854         
855         COServerResponse EntityTagResult = FakeConnection.GetServerEntityTagValue("testfile.vcf");
856         
857         EXPECT_EQ(COREQUEST_ERROR_SERVER, EntityTagResult.RequestResult);
858         EXPECT_EQ("", EntityTagResult.EntityTag);
859         EXPECT_EQ(404, EntityTagResult.ResultCode);
860         EXPECT_EQ(22, EntityTagResult.SessionCode);
861         EXPECT_EQ("The resource cannot be found.", EntityTagResult.ResultMessage);      
862         
865 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Get_Server_Entity_Tag_Value_Due_To_No_Connection){
866         
867         std::string ServerAddress1 = "gibberish.invalid";
868         std::string ServerUser1 = "user";
869         std::string ServerPass1 = "pass";
870         
871         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
872         FakeConnection.ResultServerPrefix = "/prefix/test/b";
873         FakeConnection.Connect(false);
874         
875         FakeConnection.TestRequestResult = COREQUEST_ERROR_NOTCONNECTED;
876         FakeConnection.TestEntityTag = "";
877         FakeConnection.TestResultCode = 0;
878         FakeConnection.TestSessionCode = 0;
879         FakeConnection.TestResultMessage = "";
880         
881         COServerResponse EntityTagResult = FakeConnection.GetServerEntityTagValue("testfile.vcf");
882         
883         EXPECT_EQ(COREQUEST_ERROR_NOTCONNECTED, EntityTagResult.RequestResult);
884         EXPECT_EQ("", EntityTagResult.EntityTag);
885         EXPECT_EQ(0, EntityTagResult.ResultCode);
886         EXPECT_EQ(0, EntityTagResult.SessionCode);
887         EXPECT_EQ("", EntityTagResult.ResultMessage);
888         
891 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Gets_Server_Contact_Data){
892         
893         std::string ServerAddress1 = "gibberish.invalid";
894         std::string ServerUser1 = "user";
895         std::string ServerPass1 = "pass";
896         
897         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
898         FakeConnection.ResultServerPrefix = "/prefix/test/b";
899         FakeConnection.Connect(false);
900         
901         std::string ContactFile =
902         "BEGIN:VCARD\n"
903         "VERSION:4.0\n"
904         "UID:84q2ioj13jofiujqwrAAA\n"
905         "N:;;Meep;Moop;;\n"
906         "FN:The Meep Moop\n"
907         "END:VCARD";
908         
909         FakeConnection.TestRequestResult = COREQUEST_OK;
910         FakeConnection.TestEntityTag = "";
911         FakeConnection.TestResultCode = 200;
912         FakeConnection.TestSessionCode = 0;
913         FakeConnection.TestResultMessage = ContactFile;
914         
915         COServerResponse ServerDataResult = FakeConnection.GetContact("/location/testfile.vcf");
916         
917         EXPECT_EQ(COREQUEST_OK, ServerDataResult.RequestResult);
918         EXPECT_EQ("", ServerDataResult.EntityTag);
919         EXPECT_EQ(200, ServerDataResult.ResultCode);
920         EXPECT_EQ(0, ServerDataResult.SessionCode);
921         EXPECT_EQ(ContactFile, ServerDataResult.ResultMessage); 
922         
925 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Gets_Server_Contact_Data_Due_To_Invalid_Permissions){
926         
927         std::string ServerAddress1 = "gibberish.invalid";
928         std::string ServerUser1 = "user";
929         std::string ServerPass1 = "pass";
930         
931         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
932         FakeConnection.ResultServerPrefix = "/prefix/test/b";
933         FakeConnection.Connect(false);
934         
935         FakeConnection.TestRequestResult = COREQUEST_OK;
936         FakeConnection.TestEntityTag = "";
937         FakeConnection.TestResultCode = 403;
938         FakeConnection.TestSessionCode = 22;
939         FakeConnection.TestResultMessage = "You do not have permission to access this resource.";
940         
941         COServerResponse ServerDataResult = FakeConnection.GetContact("/location/testfile.vcf");
942         
943         EXPECT_EQ(COREQUEST_OK, ServerDataResult.RequestResult);
944         EXPECT_EQ("", ServerDataResult.EntityTag);
945         EXPECT_EQ(403, ServerDataResult.ResultCode);
946         EXPECT_EQ(22, ServerDataResult.SessionCode);
947         EXPECT_EQ("You do not have permission to access this resource.", ServerDataResult.ResultMessage);       
948         
951 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Gets_Server_Contact_Data_Due_To_Missing_Resource){
952         
953         std::string ServerAddress1 = "gibberish.invalid";
954         std::string ServerUser1 = "user";
955         std::string ServerPass1 = "pass";
956         
957         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
958         FakeConnection.ResultServerPrefix = "/prefix/test/b";
959         FakeConnection.Connect(false);
960         
961         FakeConnection.TestRequestResult = COREQUEST_OK;
962         FakeConnection.TestEntityTag = "";
963         FakeConnection.TestResultCode = 404;
964         FakeConnection.TestSessionCode = 22;
965         FakeConnection.TestResultMessage = "The resource could not be found.";
966         
967         COServerResponse ServerDataResult = FakeConnection.GetContact("/location/testfile.vcf");
968         
969         EXPECT_EQ(COREQUEST_OK, ServerDataResult.RequestResult);
970         EXPECT_EQ("", ServerDataResult.EntityTag);
971         EXPECT_EQ(404, ServerDataResult.ResultCode);
972         EXPECT_EQ(22, ServerDataResult.SessionCode);
973         EXPECT_EQ("The resource could not be found.", ServerDataResult.ResultMessage);  
974         
977 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Get_Server_Contact_Data_Due_To_No_Connection){
978         
979         std::string ServerAddress1 = "gibberish.invalid";
980         std::string ServerUser1 = "user";
981         std::string ServerPass1 = "pass";
982         
983         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
984         FakeConnection.ResultServerPrefix = "/prefix/test/b";
985         FakeConnection.Connect(false);
986         
987         FakeConnection.TestRequestResult = COREQUEST_ERROR_NOTCONNECTED;
988         FakeConnection.TestEntityTag = "";
989         FakeConnection.TestResultCode = 0;
990         FakeConnection.TestSessionCode = 0;
991         FakeConnection.TestResultMessage = "";
992         
993         COServerResponse ServerDataResult = FakeConnection.GetContact("/location/testfile.vcf");
994         
995         EXPECT_EQ(COREQUEST_ERROR_NOTCONNECTED, ServerDataResult.RequestResult);
996         EXPECT_EQ("", ServerDataResult.EntityTag);
997         EXPECT_EQ(0, ServerDataResult.ResultCode);
998         EXPECT_EQ(0, ServerDataResult.SessionCode);
999         EXPECT_EQ("", ServerDataResult.ResultMessage);
1000         
1003 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Gets_A_Full_Server_Contact_List){
1004         
1005         std::string ServerAddress1 = "gibberish.invalid";
1006         std::string ServerUser1 = "user";
1007         std::string ServerPass1 = "pass";
1008         
1009         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
1010         FakeConnection.ResultServerPrefix = "/prefix/test/b";
1011         FakeConnection.Connect(false);  
1012         
1013         std::string ContactFile1 =
1014         "BEGIN:VCARD\n"
1015         "VERSION:4.0\n"
1016         "UID:84q2ioj13jofiujqwrAAA-1\n"
1017         "N:;;Meep;Moop;;\n"
1018         "FN:The Meep Moop\n"
1019         "END:VCARD";
1021         std::string ContactFile2 =
1022         "BEGIN:VCARD\n"
1023         "VERSION:4.0\n"
1024         "UID:84q2ioj13jofiujqwrAAA-2\n"
1025         "N:;;Meep;Moop;;\n"
1026         "FN:The Meep Moop\n"
1027         "END:VCARD";
1028         
1029         std::string ContactFile3 =
1030         "BEGIN:VCARD\n"
1031         "VERSION:4.0\n"
1032         "UID:84q2ioj13jofiujqwrAAA-3\n"
1033         "N:;;Meep;Moop;;\n"
1034         "FN:The Meep Moop\n"
1035         "END:VCARD";
1036         
1037         COContactList ContactListSetup;
1038         COContactData ContactPerson;
1039         
1040         ContactPerson.Location = "/location1.vcf";
1041         ContactPerson.Data = ContactFile1;
1042         ContactListSetup.ListData.push_back(ContactPerson);
1044         ContactPerson.Location = "/location2.vcf";
1045         ContactPerson.Data = ContactFile2;
1046         ContactListSetup.ListData.push_back(ContactPerson);
1048         ContactPerson.Location = "/location3.vcf";
1049         ContactPerson.Data = ContactFile3;
1050         ContactListSetup.ListData.push_back(ContactPerson);
1051         ContactListSetup.SyncToken = "2312312-12312312";
1053         FakeConnection.TestContactList = ContactListSetup;
1054         FakeConnection.TestRequestResult = COREQUEST_OK;
1055         FakeConnection.TestEntityTag = "";
1056         FakeConnection.TestResultCode = 200;
1057         FakeConnection.TestSessionCode = 0;
1058         FakeConnection.TestResultMessage = "";
1059         
1060         COContactList ServerDataResult = FakeConnection.GetContactList("");
1061         
1062         EXPECT_EQ(COREQUEST_OK, ServerDataResult.ServerResponse.RequestResult);
1063         EXPECT_EQ("", ServerDataResult.ServerResponse.EntityTag);
1064         EXPECT_EQ(200, ServerDataResult.ServerResponse.ResultCode);
1065         EXPECT_EQ(0, ServerDataResult.ServerResponse.SessionCode);
1066         EXPECT_EQ("", ServerDataResult.ServerResponse.ResultMessage);
1068         EXPECT_EQ("2312312-12312312", ServerDataResult.SyncToken);
1070         EXPECT_EQ(3, ServerDataResult.ListData.size());
1072         EXPECT_EQ("/location1.vcf", ServerDataResult.ListData[0].Location);
1073         EXPECT_EQ(ContactFile1, ServerDataResult.ListData[0].Data);
1075         EXPECT_EQ("/location2.vcf", ServerDataResult.ListData[1].Location);
1076         EXPECT_EQ(ContactFile2, ServerDataResult.ListData[1].Data);
1077         
1078         EXPECT_EQ("/location3.vcf", ServerDataResult.ListData[2].Location);
1079         EXPECT_EQ(ContactFile3, ServerDataResult.ListData[2].Data);
1083 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Gets_A_Partial_Server_Contact_List){
1084         
1085         std::string ServerAddress1 = "gibberish.invalid";
1086         std::string ServerUser1 = "user";
1087         std::string ServerPass1 = "pass";
1088         
1089         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
1090         FakeConnection.ResultServerPrefix = "/prefix/test/b";
1091         FakeConnection.Connect(false);  
1092         
1093         std::string ContactFile3 =
1094         "BEGIN:VCARD\n"
1095         "VERSION:4.0\n"
1096         "UID:84q2ioj13jofiujqwrAAA-3\n"
1097         "N:;;Meep;Moop;;\n"
1098         "FN:The Meep Moop\n"
1099         "END:VCARD";
1100         
1101         COContactList ContactListSetup;
1102         COContactData ContactPerson;
1104         ContactPerson.Location = "/location3.vcf";
1105         ContactPerson.Data = ContactFile3;
1106         ContactListSetup.ListData.push_back(ContactPerson);
1107         ContactListSetup.SyncToken = "5964589-43543534";
1109         FakeConnection.TestContactList = ContactListSetup;
1110         FakeConnection.TestRequestResult = COREQUEST_OK;
1111         FakeConnection.TestEntityTag = "";
1112         FakeConnection.TestResultCode = 200;
1113         FakeConnection.TestSessionCode = 0;
1114         FakeConnection.TestResultMessage = "";
1115         
1116         COContactList ServerDataResult = FakeConnection.GetContactList("2312312-12312312");
1117         
1118         EXPECT_EQ(COREQUEST_OK, ServerDataResult.ServerResponse.RequestResult);
1119         EXPECT_EQ("", ServerDataResult.ServerResponse.EntityTag);
1120         EXPECT_EQ(200, ServerDataResult.ServerResponse.ResultCode);
1121         EXPECT_EQ(0, ServerDataResult.ServerResponse.SessionCode);
1122         EXPECT_EQ("", ServerDataResult.ServerResponse.ResultMessage);
1124         EXPECT_EQ("5964589-43543534", ServerDataResult.SyncToken);
1126         EXPECT_EQ(1, ServerDataResult.ListData.size());
1128         EXPECT_EQ("/location3.vcf", ServerDataResult.ListData[0].Location);
1129         EXPECT_EQ(ContactFile3, ServerDataResult.ListData[0].Data);
1133 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Get_A_Contact_List_Due_To_Invalid_Permissions){
1134         
1135         std::string ServerAddress1 = "gibberish.invalid";
1136         std::string ServerUser1 = "user";
1137         std::string ServerPass1 = "pass";
1138         
1139         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
1140         FakeConnection.ResultServerPrefix = "/prefix/test/b";
1141         FakeConnection.Connect(false);
1142         
1143         COContactList ContactListSetup;
1144         ContactListSetup.SyncToken = "";
1146         FakeConnection.TestContactList = ContactListSetup;
1147         FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
1148         FakeConnection.TestEntityTag = "";
1149         FakeConnection.TestResultCode = 403;
1150         FakeConnection.TestSessionCode = 22;
1151         FakeConnection.TestResultMessage = "You do not have permission to access this resource.";
1152         
1153         COContactList ServerDataResult = FakeConnection.GetContactList("");
1154         
1155         EXPECT_EQ(COREQUEST_ERROR_SERVER, ServerDataResult.ServerResponse.RequestResult);
1156         EXPECT_EQ("", ServerDataResult.ServerResponse.EntityTag);
1157         EXPECT_EQ(403, ServerDataResult.ServerResponse.ResultCode);
1158         EXPECT_EQ(22, ServerDataResult.ServerResponse.SessionCode);
1159         EXPECT_EQ("You do not have permission to access this resource.", ServerDataResult.ServerResponse.ResultMessage);
1161         EXPECT_EQ(0, ServerDataResult.ListData.size());
1165 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Get_A_Contact_List_Due_To_Missing_Resource){
1166         
1167         std::string ServerAddress1 = "gibberish.invalid";
1168         std::string ServerUser1 = "user";
1169         std::string ServerPass1 = "pass";
1170         
1171         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
1172         FakeConnection.ResultServerPrefix = "/prefix/test/b";
1173         FakeConnection.Connect(false);
1174         
1175         COContactList ContactListSetup;
1176         ContactListSetup.SyncToken = "";
1178         FakeConnection.TestContactList = ContactListSetup;
1179         FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
1180         FakeConnection.TestEntityTag = "";
1181         FakeConnection.TestResultCode = 404;
1182         FakeConnection.TestSessionCode = 22;
1183         FakeConnection.TestResultMessage = "The resource could not be found.";
1184         
1185         COContactList ServerDataResult = FakeConnection.GetContactList("");
1186         
1187         EXPECT_EQ(COREQUEST_ERROR_SERVER, ServerDataResult.ServerResponse.RequestResult);
1188         EXPECT_EQ("", ServerDataResult.ServerResponse.EntityTag);
1189         EXPECT_EQ(404, ServerDataResult.ServerResponse.ResultCode);
1190         EXPECT_EQ(22, ServerDataResult.ServerResponse.SessionCode);
1191         EXPECT_EQ("The resource could not be found.", ServerDataResult.ServerResponse.ResultMessage);
1193         EXPECT_EQ(0, ServerDataResult.ListData.size());
1197 TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Get_A_Contact_List_Due_To_No_Connection){
1198         
1199         std::string ServerAddress1 = "gibberish.invalid";
1200         std::string ServerUser1 = "user";
1201         std::string ServerPass1 = "pass";
1202         
1203         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
1204         FakeConnection.ResultServerPrefix = "/prefix/test/b";
1205         FakeConnection.Connect(false);
1206         
1207         COContactList ContactListSetup;
1208         ContactListSetup.SyncToken = "";
1210         FakeConnection.TestContactList = ContactListSetup;
1211         FakeConnection.TestRequestResult = COREQUEST_ERROR_NOTCONNECTED;
1212         FakeConnection.TestEntityTag = "";
1213         FakeConnection.TestResultCode = 404;
1214         FakeConnection.TestSessionCode = 22;
1215         FakeConnection.TestResultMessage = "The resource could not be found.";
1216         
1217         COContactList ServerDataResult = FakeConnection.GetContactList("");
1218         
1219         EXPECT_EQ(COREQUEST_ERROR_NOTCONNECTED, ServerDataResult.ServerResponse.RequestResult);
1220         EXPECT_EQ("", ServerDataResult.ServerResponse.EntityTag);
1221         EXPECT_EQ(404, ServerDataResult.ServerResponse.ResultCode);
1222         EXPECT_EQ(22, ServerDataResult.ServerResponse.SessionCode);
1223         EXPECT_EQ("The resource could not be found.", ServerDataResult.ServerResponse.ResultMessage);
1225         EXPECT_EQ(0, ServerDataResult.ListData.size());
1229 TEST(CardDAV, Use_Fake_To_Simulate_A_Wait_For_A_Completed_Task){
1230         
1231         std::string ServerAddress1 = "gibberish.invalid";
1232         std::string ServerUser1 = "user";
1233         std::string ServerPass1 = "pass";
1234         
1235         FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
1236         FakeConnection.ResultServerPrefix = "/prefix/test/b";
1237         FakeConnection.Connect(false);
1238         FakeConnection.ResultTaskCompleted = false;
1239         
1240         while (!FakeConnection.IsTaskCompleted()){
1241                 
1242                 std::this_thread::sleep_for(std::chrono::milliseconds(250));
1243                 FakeConnection.ResultTaskCompleted = true;
1244                 
1245         }
1246         
1247         EXPECT_TRUE(FakeConnection.ResultTaskCompleted);
1248         
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy