#include <chrono>
#include <thread>
-// TODO: Add tests for the CardDAV object.
-
TEST(CardDAV, Use_Fake_To_Setup_And_Check_Connection_Settings_With_TestMode_True){
std::string ServerAddress1 = "gibberish.invalid";
FakeConnectionObject FakeConnection2(ServerAddress2, 8800, ServerUser2, ServerPass2, true);
FakeConnectionObject FakeConnection3(ServerAddress3, 8008, ServerUser3, ServerPass3, false);
+ FakeConnection1.ResultTestMode = true;
+ FakeConnection2.ResultTestMode = true;
+ FakeConnection3.ResultTestMode = true;
+
EXPECT_EQ("gibberish.invalid", FakeConnection1.GetServerAddress());
EXPECT_EQ(8080, FakeConnection1.GetServerPort());
EXPECT_EQ("user", FakeConnection1.GetServerUser());
FakeConnectionObject FakeConnection2(ServerAddress2, 8800, ServerUser2, ServerPass2, true, "/prefix2", "Account2");
FakeConnectionObject FakeConnection3(ServerAddress3, 8008, ServerUser3, ServerPass3, false, "/prefix3", "Account3");
+ FakeConnection1.ResultTestMode = false;
+ FakeConnection2.ResultTestMode = false;
+ FakeConnection3.ResultTestMode = false;
+
EXPECT_EQ("gibberish.invalid", FakeConnection1.GetServerAddress());
EXPECT_EQ(8080, FakeConnection1.GetServerPort());
EXPECT_EQ("user", FakeConnection1.GetServerUser());
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
FakeConnection.ResultStatus = COCONNECT_OK;
- EXPECT_EQ(COCONNECT_OK, FakeConnection.Connect());
+ EXPECT_EQ(COCONNECT_OK, FakeConnection.Connect(false));
}
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
FakeConnection.ResultStatus = COCONNECT_INVALID;
- EXPECT_EQ(COCONNECT_INVALID, FakeConnection.Connect());
+ EXPECT_EQ(COCONNECT_INVALID, FakeConnection.Connect(false));
}
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
FakeConnection.ResultStatus = COCONNECT_TIMEOUT;
- EXPECT_EQ(COCONNECT_TIMEOUT, FakeConnection.Connect());
+ EXPECT_EQ(COCONNECT_TIMEOUT, FakeConnection.Connect(false));
}
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
FakeConnection.ResultStatus = COCONNECT_AUTHFAIL;
- EXPECT_EQ(COCONNECT_AUTHFAIL, FakeConnection.Connect());
+ EXPECT_EQ(COCONNECT_AUTHFAIL, FakeConnection.Connect(false));
}
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
FakeConnection.ResultAuthPassed = true;
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
EXPECT_EQ(true, FakeConnection.AbleToLogin());
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
FakeConnection.ResultAuthPassed = false;
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
EXPECT_EQ(false, FakeConnection.AbleToLogin());
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
FakeConnection.ResultCanProcess = true;
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
EXPECT_EQ(true, FakeConnection.CanDoProcessing());
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
FakeConnection.ResultSSLStatus = true;
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
EXPECT_EQ(true, FakeConnection.CanDoSSL());
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
FakeConnection.ResultSSLStatus = false;
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
EXPECT_EQ(false, FakeConnection.CanDoSSL());
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
FakeConnection.ResultSSLVerified = COSSL_VERIFIED;
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
EXPECT_EQ(COSSL_VERIFIED, FakeConnection.SSLVerify());
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
FakeConnection.ResultSSLVerified = COSSL_UNABLETOVERIFY;
- FakeConnection.Connect();
+ FakeConnection.ResultStatus = COCONNECT_SSLFAIL;
+ EXPECT_EQ(COCONNECT_SSLFAIL, FakeConnection.Connect(false));
EXPECT_EQ(COSSL_UNABLETOVERIFY, FakeConnection.SSLVerify());
}
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
FakeConnection.ResultSSLVerified = COSSL_VERIFIED_USER;
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
EXPECT_EQ(COSSL_VERIFIED_USER, FakeConnection.SSLVerify());
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, false);
FakeConnection.ResultSSLVerified = COSSL_NOTAPPLICABLE;
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
EXPECT_EQ(COSSL_NOTAPPLICABLE, FakeConnection.SSLVerify());
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
FakeConnection.ResultValidResponse = true;
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
EXPECT_EQ(true, FakeConnection.HasValidResponse());
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
FakeConnection.ResultValidResponse = false;
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
EXPECT_EQ(false, FakeConnection.HasValidResponse());
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
FakeConnection.ResultSelfSigned = true;
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
EXPECT_EQ(true, FakeConnection.IsSelfSigned());
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
FakeConnection.ResultSelfSigned = false;
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
EXPECT_EQ(false, FakeConnection.IsSelfSigned());
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
FakeConnection.ResultServerPrefix = "/prefix/test/a";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
EXPECT_EQ("/prefix/test/a", FakeConnection.GetDefaultPrefix());
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
EXPECT_EQ("/prefix/test/b", FakeConnection.GetDefaultPrefix());
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
std::string ContactFile =
"BEGIN:VCARD\n"
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
std::string ContactFile =
"BEGIN:VCARD\n"
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
std::string ContactFile =
"BEGIN:VCARD\n"
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
std::string ContactFile =
"BEGIN:VCARD\n"
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
std::string ContactFile =
"BEGIN:VCARD\n"
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
std::string ContactFile =
"BEGIN:VCARD\n"
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
std::string ContactFile =
"BEGIN:VCARD\n"
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
std::string ContactFile =
"BEGIN:VCARD\n"
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
FakeConnection.TestRequestResult = COREQUEST_OK;
FakeConnection.TestEntityTag = "";
FakeConnection.TestSessionCode = 0;
FakeConnection.TestResultMessage = "";
- COServerResponse DeleteContactResult = FakeConnection.DeleteContact("testfile.vcf", "a23124sfadfdvxc1646541bsdfaf");
+ COServerResponse DeleteContactResult = FakeConnection.DeleteContact("testfile.vcf");
EXPECT_EQ(COREQUEST_OK, DeleteContactResult.RequestResult);
EXPECT_EQ("", DeleteContactResult.EntityTag);
FakeConnection.TestSessionCode = 0;
FakeConnection.TestResultMessage = "";
- DeleteContactResult = FakeConnection.DeleteContact("testfile.vcf", "asf84sa484saf614as64asvada4s6fas");
+ DeleteContactResult = FakeConnection.DeleteContact("testfile.vcf");
EXPECT_EQ(COREQUEST_OK, DeleteContactResult.RequestResult);
EXPECT_EQ("", DeleteContactResult.EntityTag);
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
FakeConnection.TestEntityTag = "";
FakeConnection.TestSessionCode = 22;
FakeConnection.TestResultMessage = "You do not have permission to delete this resource.";
- COServerResponse DeleteContactResult = FakeConnection.DeleteContact("testfile.vcf", "a23124sfadfdvxc1646541bsdfaf");
+ COServerResponse DeleteContactResult = FakeConnection.DeleteContact("testfile.vcf");
EXPECT_EQ(COREQUEST_ERROR_SERVER, DeleteContactResult.RequestResult);
EXPECT_EQ("", DeleteContactResult.EntityTag);
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
FakeConnection.TestEntityTag = "";
FakeConnection.TestSessionCode = 22;
FakeConnection.TestResultMessage = "The resource could not be found.";
- COServerResponse DeleteContactResult = FakeConnection.DeleteContact("testfile.vcf", "a23124sfadfdvxc1646541bsdfaf");
+ COServerResponse DeleteContactResult = FakeConnection.DeleteContact("testfile.vcf");
EXPECT_EQ(COREQUEST_ERROR_SERVER, DeleteContactResult.RequestResult);
EXPECT_EQ("", DeleteContactResult.EntityTag);
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
FakeConnection.TestRequestResult = COREQUEST_ERROR_NOTCONNECTED;
FakeConnection.TestEntityTag = "";
FakeConnection.TestSessionCode = 0;
FakeConnection.TestResultMessage = "";
- COServerResponse DeleteContactResult = FakeConnection.DeleteContact("testfile.vcf", "a23124sfadfdvxc1646541bsdfaf");
+ COServerResponse DeleteContactResult = FakeConnection.DeleteContact("testfile.vcf");
EXPECT_EQ(COREQUEST_ERROR_NOTCONNECTED, DeleteContactResult.RequestResult);
EXPECT_EQ("", DeleteContactResult.EntityTag);
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
FakeConnection.TestRequestResult = COREQUEST_OK;
FakeConnection.TestEntityTag = "a23124sfadfdvxc1646541bsdfaf";
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
FakeConnection.TestEntityTag = "";
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
FakeConnection.TestEntityTag = "";
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
FakeConnection.TestRequestResult = COREQUEST_ERROR_NOTCONNECTED;
FakeConnection.TestEntityTag = "";
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
std::string ContactFile =
"BEGIN:VCARD\n"
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
FakeConnection.TestRequestResult = COREQUEST_OK;
FakeConnection.TestEntityTag = "";
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
FakeConnection.TestRequestResult = COREQUEST_OK;
FakeConnection.TestEntityTag = "";
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
FakeConnection.TestRequestResult = COREQUEST_ERROR_NOTCONNECTED;
FakeConnection.TestEntityTag = "";
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
std::string ContactFile1 =
"BEGIN:VCARD\n"
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
std::string ContactFile3 =
"BEGIN:VCARD\n"
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
COContactList ContactListSetup;
ContactListSetup.SyncToken = "";
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
COContactList ContactListSetup;
ContactListSetup.SyncToken = "";
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
COContactList ContactListSetup;
ContactListSetup.SyncToken = "";
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
- FakeConnection.Connect();
+ FakeConnection.Connect(false);
FakeConnection.ResultTaskCompleted = false;
while (!FakeConnection.IsTaskCompleted()){