std::string ServerUser1 = "user";
std::string ServerPass1 = "pass";
- FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
FakeConnection.ResultServerPrefix = "/prefix/test/b";
FakeConnection.Connect();
FakeConnection.TestRequestResult = COREQUEST_OK;
FakeConnection.TestEntityTag = "4324svafhuiaffsdhui";
- FakeConnection.TestResultCode = 200;
+ FakeConnection.TestResultCode = 201;
+ FakeConnection.TestSessionCode = 0;
FakeConnection.TestResultMessage = "";
COServerResponse AddContactResult = FakeConnection.AddContact("testfile.vcf", ContactFile);
EXPECT_EQ(COREQUEST_OK, AddContactResult.RequestResult);
EXPECT_EQ("4324svafhuiaffsdhui", AddContactResult.EntityTag);
- EXPECT_EQ(200, AddContactResult.ResultCode);
+ EXPECT_EQ(201, AddContactResult.ResultCode);
+ EXPECT_EQ(0, AddContactResult.SessionCode);
EXPECT_EQ("", AddContactResult.ResultMessage);
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Add_A_Contact_Due_To_Permissions){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ std::string ContactFile =
+ "BEGIN:VCARD\n"
+ "VERSION:4.0\n"
+ "UID:84q2ioj13jofiujqwr\n"
+ "N:;;Meep;Moop;;\n"
+ "FN:The Meep Moop\n"
+ "END:VCARD";
+
+ FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
+ FakeConnection.TestEntityTag = "";
+ FakeConnection.TestResultCode = 403;
+ FakeConnection.TestSessionCode = 22;
+ FakeConnection.TestResultMessage = "You do not have permission to add this resource.";
+
+ COServerResponse AddContactResult = FakeConnection.AddContact("testfile.vcf", ContactFile);
+
+ EXPECT_EQ(COREQUEST_ERROR_SERVER, AddContactResult.RequestResult);
+ EXPECT_EQ("", AddContactResult.EntityTag);
+ EXPECT_EQ(403, AddContactResult.ResultCode);
+ EXPECT_EQ(22, AddContactResult.SessionCode);
+ EXPECT_EQ("You do not have permission to add this resource.", AddContactResult.ResultMessage);
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Add_A_Contact_Due_To_Invalid_Path){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ std::string ContactFile =
+ "BEGIN:VCARD\n"
+ "VERSION:4.0\n"
+ "UID:84q2ioj13jofiujqwr\n"
+ "N:;;Meep;Moop;;\n"
+ "FN:The Meep Moop\n"
+ "END:VCARD";
+
+ FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
+ FakeConnection.TestEntityTag = "";
+ FakeConnection.TestResultCode = 404;
+ FakeConnection.TestSessionCode = 22;
+ FakeConnection.TestResultMessage = "The location cannot be found.";
+
+ COServerResponse AddContactResult = FakeConnection.AddContact("testfile.vcf", ContactFile);
+
+ EXPECT_EQ(COREQUEST_ERROR_SERVER, AddContactResult.RequestResult);
+ EXPECT_EQ("", AddContactResult.EntityTag);
+ EXPECT_EQ(404, AddContactResult.ResultCode);
+ EXPECT_EQ(22, AddContactResult.SessionCode);
+ EXPECT_EQ("The location cannot be found.", AddContactResult.ResultMessage);
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Add_A_Contact_Due_To_No_Connection){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ std::string ContactFile =
+ "BEGIN:VCARD\n"
+ "VERSION:4.0\n"
+ "UID:84q2ioj13jofiujqwr\n"
+ "N:;;Meep;Moop;;\n"
+ "FN:The Meep Moop\n"
+ "END:VCARD";
+
+ FakeConnection.TestRequestResult = COREQUEST_ERROR_NOTCONNECTED;
+ FakeConnection.TestEntityTag = "";
+ FakeConnection.TestResultCode = 0;
+ FakeConnection.TestSessionCode = 0;
+ FakeConnection.TestResultMessage = "";
+
+ COServerResponse AddContactResult = FakeConnection.AddContact("testfile.vcf", ContactFile);
+
+ EXPECT_EQ(COREQUEST_ERROR_NOTCONNECTED, AddContactResult.RequestResult);
+ EXPECT_EQ("", AddContactResult.EntityTag);
+ EXPECT_EQ(0, AddContactResult.ResultCode);
+ EXPECT_EQ(0, AddContactResult.SessionCode);
+ EXPECT_EQ("", AddContactResult.ResultMessage);
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Edits_A_Server_Contact){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ std::string ContactFile =
+ "BEGIN:VCARD\n"
+ "VERSION:4.0\n"
+ "UID:84q2ioj13jofiujqwrAAA\n"
+ "N:;;Meep;Moop;;\n"
+ "FN:The Meep Moop\n"
+ "END:VCARD";
+
+ FakeConnection.TestRequestResult = COREQUEST_OK;
+ FakeConnection.TestEntityTag = "a23124sfadfdvxc1646541bsdfaf";
+ FakeConnection.TestResultCode = 200;
+ FakeConnection.TestSessionCode = 0;
+ FakeConnection.TestResultMessage = "";
+
+ COServerResponse EditContactResult = FakeConnection.EditContact("testfile.vcf", ContactFile);
+
+ EXPECT_EQ(COREQUEST_OK, EditContactResult.RequestResult);
+ EXPECT_EQ("a23124sfadfdvxc1646541bsdfaf", EditContactResult.EntityTag);
+ EXPECT_EQ(200, EditContactResult.ResultCode);
+ EXPECT_EQ(0, EditContactResult.SessionCode);
+ EXPECT_EQ("", EditContactResult.ResultMessage);
+
+ FakeConnection.TestRequestResult = COREQUEST_OK;
+ FakeConnection.TestEntityTag = "asf84sa484saf614as64asvada4s6fas";
+ FakeConnection.TestResultCode = 204;
+ FakeConnection.TestSessionCode = 0;
+ FakeConnection.TestResultMessage = "";
+
+ EditContactResult = FakeConnection.EditContact("testfile.vcf", ContactFile);
+
+ EXPECT_EQ(COREQUEST_OK, EditContactResult.RequestResult);
+ EXPECT_EQ("asf84sa484saf614as64asvada4s6fas", EditContactResult.EntityTag);
+ EXPECT_EQ(204, EditContactResult.ResultCode);
+ EXPECT_EQ(0, EditContactResult.SessionCode);
+ EXPECT_EQ("", EditContactResult.ResultMessage);
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Edit_A_Server_Contact_Due_To_Invalid_Permissions){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ std::string ContactFile =
+ "BEGIN:VCARD\n"
+ "VERSION:4.0\n"
+ "UID:84q2ioj13jofiujqwrAAA\n"
+ "N:;;Meep;Moop;;\n"
+ "FN:The Meep Moop\n"
+ "END:VCARD";
+
+ FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
+ FakeConnection.TestEntityTag = "";
+ FakeConnection.TestResultCode = 403;
+ FakeConnection.TestSessionCode = 22;
+ FakeConnection.TestResultMessage = "You do not have permission to add this resource.";
+
+ COServerResponse EditContactResult = FakeConnection.EditContact("testfile.vcf", ContactFile);
+
+ EXPECT_EQ(COREQUEST_ERROR_SERVER, EditContactResult.RequestResult);
+ EXPECT_EQ("", EditContactResult.EntityTag);
+ EXPECT_EQ(403, EditContactResult.ResultCode);
+ EXPECT_EQ(22, EditContactResult.SessionCode);
+ EXPECT_EQ("You do not have permission to add this resource.", EditContactResult.ResultMessage);
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Edit_A_Server_Contact_Due_To_Invalid_Location){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ std::string ContactFile =
+ "BEGIN:VCARD\n"
+ "VERSION:4.0\n"
+ "UID:84q2ioj13jofiujqwrAAA\n"
+ "N:;;Meep;Moop;;\n"
+ "FN:The Meep Moop\n"
+ "END:VCARD";
+
+ FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
+ FakeConnection.TestEntityTag = "";
+ FakeConnection.TestResultCode = 404;
+ FakeConnection.TestSessionCode = 22;
+ FakeConnection.TestResultMessage = "The resource could not be found.";
+
+ COServerResponse EditContactResult = FakeConnection.EditContact("testfile.vcf", ContactFile);
+
+ EXPECT_EQ(COREQUEST_ERROR_SERVER, EditContactResult.RequestResult);
+ EXPECT_EQ("", EditContactResult.EntityTag);
+ EXPECT_EQ(404, EditContactResult.ResultCode);
+ EXPECT_EQ(22, EditContactResult.SessionCode);
+ EXPECT_EQ("The resource could not be found.", EditContactResult.ResultMessage);
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Edit_A_Server_Contact_Due_To_No_Connection){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ std::string ContactFile =
+ "BEGIN:VCARD\n"
+ "VERSION:4.0\n"
+ "UID:84q2ioj13jofiujqwrAAA\n"
+ "N:;;Meep;Moop;;\n"
+ "FN:The Meep Moop\n"
+ "END:VCARD";
+
+ FakeConnection.TestRequestResult = COREQUEST_ERROR_NOTCONNECTED;
+ FakeConnection.TestEntityTag = "";
+ FakeConnection.TestResultCode = 0;
+ FakeConnection.TestSessionCode = 0;
+ FakeConnection.TestResultMessage = "";
+
+ COServerResponse EditContactResult = FakeConnection.EditContact("testfile.vcf", ContactFile);
+
+ EXPECT_EQ(COREQUEST_ERROR_NOTCONNECTED, EditContactResult.RequestResult);
+ EXPECT_EQ("", EditContactResult.EntityTag);
+ EXPECT_EQ(0, EditContactResult.ResultCode);
+ EXPECT_EQ(0, EditContactResult.SessionCode);
+ EXPECT_EQ("", EditContactResult.ResultMessage);
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Deletes_A_Server_Contact){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ FakeConnection.TestRequestResult = COREQUEST_OK;
+ FakeConnection.TestEntityTag = "";
+ FakeConnection.TestResultCode = 200;
+ FakeConnection.TestSessionCode = 0;
+ FakeConnection.TestResultMessage = "";
+
+ COServerResponse DeleteContactResult = FakeConnection.DeleteContact("testfile.vcf", "a23124sfadfdvxc1646541bsdfaf");
+
+ EXPECT_EQ(COREQUEST_OK, DeleteContactResult.RequestResult);
+ EXPECT_EQ("", DeleteContactResult.EntityTag);
+ EXPECT_EQ(200, DeleteContactResult.ResultCode);
+ EXPECT_EQ(0, DeleteContactResult.SessionCode);
+ EXPECT_EQ("", DeleteContactResult.ResultMessage);
+
+ FakeConnection.TestRequestResult = COREQUEST_OK;
+ FakeConnection.TestEntityTag = "";
+ FakeConnection.TestResultCode = 204;
+ FakeConnection.TestSessionCode = 0;
+ FakeConnection.TestResultMessage = "";
+
+ DeleteContactResult = FakeConnection.DeleteContact("testfile.vcf", "asf84sa484saf614as64asvada4s6fas");
+
+ EXPECT_EQ(COREQUEST_OK, DeleteContactResult.RequestResult);
+ EXPECT_EQ("", DeleteContactResult.EntityTag);
+ EXPECT_EQ(204, DeleteContactResult.ResultCode);
+ EXPECT_EQ(0, DeleteContactResult.SessionCode);
+ EXPECT_EQ("", DeleteContactResult.ResultMessage);
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Delete_A_Server_Contact_Due_To_Invalid_Permissions){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
+ FakeConnection.TestEntityTag = "";
+ FakeConnection.TestResultCode = 403;
+ FakeConnection.TestSessionCode = 22;
+ FakeConnection.TestResultMessage = "You do not have permission to delete this resource.";
+
+ COServerResponse DeleteContactResult = FakeConnection.DeleteContact("testfile.vcf", "a23124sfadfdvxc1646541bsdfaf");
+
+ EXPECT_EQ(COREQUEST_ERROR_SERVER, DeleteContactResult.RequestResult);
+ EXPECT_EQ("", DeleteContactResult.EntityTag);
+ EXPECT_EQ(403, DeleteContactResult.ResultCode);
+ EXPECT_EQ(22, DeleteContactResult.SessionCode);
+ EXPECT_EQ("You do not have permission to delete this resource.", DeleteContactResult.ResultMessage);
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Delete_A_Server_Contact_Due_To_Missing_Location){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
+ FakeConnection.TestEntityTag = "";
+ FakeConnection.TestResultCode = 404;
+ FakeConnection.TestSessionCode = 22;
+ FakeConnection.TestResultMessage = "The resource could not be found.";
+
+ COServerResponse DeleteContactResult = FakeConnection.DeleteContact("testfile.vcf", "a23124sfadfdvxc1646541bsdfaf");
+
+ EXPECT_EQ(COREQUEST_ERROR_SERVER, DeleteContactResult.RequestResult);
+ EXPECT_EQ("", DeleteContactResult.EntityTag);
+ EXPECT_EQ(404, DeleteContactResult.ResultCode);
+ EXPECT_EQ(22, DeleteContactResult.SessionCode);
+ EXPECT_EQ("The resource could not be found.", DeleteContactResult.ResultMessage);
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Delete_A_Server_Contact_Due_To_No_Connection){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ FakeConnection.TestRequestResult = COREQUEST_ERROR_NOTCONNECTED;
+ FakeConnection.TestEntityTag = "";
+ FakeConnection.TestResultCode = 0;
+ FakeConnection.TestSessionCode = 0;
+ FakeConnection.TestResultMessage = "";
+
+ COServerResponse DeleteContactResult = FakeConnection.DeleteContact("testfile.vcf", "a23124sfadfdvxc1646541bsdfaf");
+
+ EXPECT_EQ(COREQUEST_ERROR_NOTCONNECTED, DeleteContactResult.RequestResult);
+ EXPECT_EQ("", DeleteContactResult.EntityTag);
+ EXPECT_EQ(0, DeleteContactResult.ResultCode);
+ EXPECT_EQ(0, DeleteContactResult.SessionCode);
+ EXPECT_EQ("", DeleteContactResult.ResultMessage);
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Gets_Server_Entity_Tag_Value){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ FakeConnection.TestRequestResult = COREQUEST_OK;
+ FakeConnection.TestEntityTag = "a23124sfadfdvxc1646541bsdfaf";
+ FakeConnection.TestResultCode = 200;
+ FakeConnection.TestSessionCode = 0;
+ FakeConnection.TestResultMessage = "";
+
+ COServerResponse EntityTagResult = FakeConnection.GetServerEntityTagValue("testfile.vcf");
+
+ EXPECT_EQ(COREQUEST_OK, EntityTagResult.RequestResult);
+ EXPECT_EQ("a23124sfadfdvxc1646541bsdfaf", EntityTagResult.EntityTag);
+ EXPECT_EQ(200, EntityTagResult.ResultCode);
+ EXPECT_EQ(0, EntityTagResult.SessionCode);
+ EXPECT_EQ("", EntityTagResult.ResultMessage);
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Get_Server_Entity_Tag_Value_Due_To_Invalid_Permissions){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
+ FakeConnection.TestEntityTag = "";
+ FakeConnection.TestResultCode = 403;
+ FakeConnection.TestSessionCode = 22;
+ FakeConnection.TestResultMessage = "You do not have permission to access this resource.";
+
+ COServerResponse EntityTagResult = FakeConnection.GetServerEntityTagValue("testfile.vcf");
+
+ EXPECT_EQ(COREQUEST_ERROR_SERVER, EntityTagResult.RequestResult);
+ EXPECT_EQ("", EntityTagResult.EntityTag);
+ EXPECT_EQ(403, EntityTagResult.ResultCode);
+ EXPECT_EQ(22, EntityTagResult.SessionCode);
+ EXPECT_EQ("You do not have permission to access this resource.", EntityTagResult.ResultMessage);
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Get_Server_Entity_Tag_Value_Due_To_Missing_Resource){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
+ FakeConnection.TestEntityTag = "";
+ FakeConnection.TestResultCode = 404;
+ FakeConnection.TestSessionCode = 22;
+ FakeConnection.TestResultMessage = "The resource cannot be found.";
+
+ COServerResponse EntityTagResult = FakeConnection.GetServerEntityTagValue("testfile.vcf");
+
+ EXPECT_EQ(COREQUEST_ERROR_SERVER, EntityTagResult.RequestResult);
+ EXPECT_EQ("", EntityTagResult.EntityTag);
+ EXPECT_EQ(404, EntityTagResult.ResultCode);
+ EXPECT_EQ(22, EntityTagResult.SessionCode);
+ EXPECT_EQ("The resource cannot be found.", EntityTagResult.ResultMessage);
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Get_Server_Entity_Tag_Value_Due_To_No_Connection){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ FakeConnection.TestRequestResult = COREQUEST_ERROR_NOTCONNECTED;
+ FakeConnection.TestEntityTag = "";
+ FakeConnection.TestResultCode = 0;
+ FakeConnection.TestSessionCode = 0;
+ FakeConnection.TestResultMessage = "";
+
+ COServerResponse EntityTagResult = FakeConnection.GetServerEntityTagValue("testfile.vcf");
+
+ EXPECT_EQ(COREQUEST_ERROR_NOTCONNECTED, EntityTagResult.RequestResult);
+ EXPECT_EQ("", EntityTagResult.EntityTag);
+ EXPECT_EQ(0, EntityTagResult.ResultCode);
+ EXPECT_EQ(0, EntityTagResult.SessionCode);
+ EXPECT_EQ("", EntityTagResult.ResultMessage);
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Gets_Server_Contact_Data){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ std::string ContactFile =
+ "BEGIN:VCARD\n"
+ "VERSION:4.0\n"
+ "UID:84q2ioj13jofiujqwrAAA\n"
+ "N:;;Meep;Moop;;\n"
+ "FN:The Meep Moop\n"
+ "END:VCARD";
+
+ FakeConnection.TestRequestResult = COREQUEST_OK;
+ FakeConnection.TestEntityTag = "";
+ FakeConnection.TestResultCode = 200;
+ FakeConnection.TestSessionCode = 0;
+ FakeConnection.TestResultMessage = ContactFile;
+
+ COServerResponse ServerDataResult = FakeConnection.GetContact("/location/testfile.vcf");
+
+ EXPECT_EQ(COREQUEST_OK, ServerDataResult.RequestResult);
+ EXPECT_EQ("", ServerDataResult.EntityTag);
+ EXPECT_EQ(200, ServerDataResult.ResultCode);
+ EXPECT_EQ(0, ServerDataResult.SessionCode);
+ EXPECT_EQ(ContactFile, ServerDataResult.ResultMessage);
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Gets_Server_Contact_Data_Due_To_Invalid_Permissions){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ FakeConnection.TestRequestResult = COREQUEST_OK;
+ FakeConnection.TestEntityTag = "";
+ FakeConnection.TestResultCode = 403;
+ FakeConnection.TestSessionCode = 22;
+ FakeConnection.TestResultMessage = "You do not have permission to access this resource.";
+
+ COServerResponse ServerDataResult = FakeConnection.GetContact("/location/testfile.vcf");
+
+ EXPECT_EQ(COREQUEST_OK, ServerDataResult.RequestResult);
+ EXPECT_EQ("", ServerDataResult.EntityTag);
+ EXPECT_EQ(403, ServerDataResult.ResultCode);
+ EXPECT_EQ(22, ServerDataResult.SessionCode);
+ EXPECT_EQ("You do not have permission to access this resource.", ServerDataResult.ResultMessage);
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Gets_Server_Contact_Data_Due_To_Missing_Resource){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ FakeConnection.TestRequestResult = COREQUEST_OK;
+ FakeConnection.TestEntityTag = "";
+ FakeConnection.TestResultCode = 404;
+ FakeConnection.TestSessionCode = 22;
+ FakeConnection.TestResultMessage = "The resource could not be found.";
+
+ COServerResponse ServerDataResult = FakeConnection.GetContact("/location/testfile.vcf");
+
+ EXPECT_EQ(COREQUEST_OK, ServerDataResult.RequestResult);
+ EXPECT_EQ("", ServerDataResult.EntityTag);
+ EXPECT_EQ(404, ServerDataResult.ResultCode);
+ EXPECT_EQ(22, ServerDataResult.SessionCode);
+ EXPECT_EQ("The resource could not be found.", ServerDataResult.ResultMessage);
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Get_Server_Contact_Data_Due_To_No_Connection){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ FakeConnection.TestRequestResult = COREQUEST_ERROR_NOTCONNECTED;
+ FakeConnection.TestEntityTag = "";
+ FakeConnection.TestResultCode = 0;
+ FakeConnection.TestSessionCode = 0;
+ FakeConnection.TestResultMessage = "";
+
+ COServerResponse ServerDataResult = FakeConnection.GetContact("/location/testfile.vcf");
+
+ EXPECT_EQ(COREQUEST_ERROR_NOTCONNECTED, ServerDataResult.RequestResult);
+ EXPECT_EQ("", ServerDataResult.EntityTag);
+ EXPECT_EQ(0, ServerDataResult.ResultCode);
+ EXPECT_EQ(0, ServerDataResult.SessionCode);
+ EXPECT_EQ("", ServerDataResult.ResultMessage);
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Gets_A_Full_Server_Contact_List){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ std::string ContactFile1 =
+ "BEGIN:VCARD\n"
+ "VERSION:4.0\n"
+ "UID:84q2ioj13jofiujqwrAAA-1\n"
+ "N:;;Meep;Moop;;\n"
+ "FN:The Meep Moop\n"
+ "END:VCARD";
+
+ std::string ContactFile2 =
+ "BEGIN:VCARD\n"
+ "VERSION:4.0\n"
+ "UID:84q2ioj13jofiujqwrAAA-2\n"
+ "N:;;Meep;Moop;;\n"
+ "FN:The Meep Moop\n"
+ "END:VCARD";
+
+ std::string ContactFile3 =
+ "BEGIN:VCARD\n"
+ "VERSION:4.0\n"
+ "UID:84q2ioj13jofiujqwrAAA-3\n"
+ "N:;;Meep;Moop;;\n"
+ "FN:The Meep Moop\n"
+ "END:VCARD";
+
+ COContactList ContactListSetup;
+ COContactData ContactPerson;
+
+ ContactPerson.Location = "/location1.vcf";
+ ContactPerson.Data = ContactFile1;
+ ContactListSetup.ListData.push_back(ContactPerson);
+
+ ContactPerson.Location = "/location2.vcf";
+ ContactPerson.Data = ContactFile2;
+ ContactListSetup.ListData.push_back(ContactPerson);
+
+ ContactPerson.Location = "/location3.vcf";
+ ContactPerson.Data = ContactFile3;
+ ContactListSetup.ListData.push_back(ContactPerson);
+ ContactListSetup.SyncToken = "2312312-12312312";
+
+ FakeConnection.TestContactList = ContactListSetup;
+ FakeConnection.TestRequestResult = COREQUEST_OK;
+ FakeConnection.TestEntityTag = "";
+ FakeConnection.TestResultCode = 200;
+ FakeConnection.TestSessionCode = 0;
+ FakeConnection.TestResultMessage = "";
+
+ COContactList ServerDataResult = FakeConnection.GetContactList("");
+
+ EXPECT_EQ(COREQUEST_OK, ServerDataResult.ServerResponse.RequestResult);
+ EXPECT_EQ("", ServerDataResult.ServerResponse.EntityTag);
+ EXPECT_EQ(200, ServerDataResult.ServerResponse.ResultCode);
+ EXPECT_EQ(0, ServerDataResult.ServerResponse.SessionCode);
+ EXPECT_EQ("", ServerDataResult.ServerResponse.ResultMessage);
+
+ EXPECT_EQ("2312312-12312312", ServerDataResult.SyncToken);
+
+ EXPECT_EQ(3, ServerDataResult.ListData.size());
+
+ EXPECT_EQ("/location1.vcf", ServerDataResult.ListData[0].Location);
+ EXPECT_EQ(ContactFile1, ServerDataResult.ListData[0].Data);
+
+ EXPECT_EQ("/location2.vcf", ServerDataResult.ListData[1].Location);
+ EXPECT_EQ(ContactFile2, ServerDataResult.ListData[1].Data);
+
+ EXPECT_EQ("/location3.vcf", ServerDataResult.ListData[2].Location);
+ EXPECT_EQ(ContactFile3, ServerDataResult.ListData[2].Data);
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Gets_A_Partial_Server_Contact_List){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ std::string ContactFile3 =
+ "BEGIN:VCARD\n"
+ "VERSION:4.0\n"
+ "UID:84q2ioj13jofiujqwrAAA-3\n"
+ "N:;;Meep;Moop;;\n"
+ "FN:The Meep Moop\n"
+ "END:VCARD";
+
+ COContactList ContactListSetup;
+ COContactData ContactPerson;
+
+ ContactPerson.Location = "/location3.vcf";
+ ContactPerson.Data = ContactFile3;
+ ContactListSetup.ListData.push_back(ContactPerson);
+ ContactListSetup.SyncToken = "5964589-43543534";
+
+ FakeConnection.TestContactList = ContactListSetup;
+ FakeConnection.TestRequestResult = COREQUEST_OK;
+ FakeConnection.TestEntityTag = "";
+ FakeConnection.TestResultCode = 200;
+ FakeConnection.TestSessionCode = 0;
+ FakeConnection.TestResultMessage = "";
+
+ COContactList ServerDataResult = FakeConnection.GetContactList("2312312-12312312");
+
+ EXPECT_EQ(COREQUEST_OK, ServerDataResult.ServerResponse.RequestResult);
+ EXPECT_EQ("", ServerDataResult.ServerResponse.EntityTag);
+ EXPECT_EQ(200, ServerDataResult.ServerResponse.ResultCode);
+ EXPECT_EQ(0, ServerDataResult.ServerResponse.SessionCode);
+ EXPECT_EQ("", ServerDataResult.ServerResponse.ResultMessage);
+
+ EXPECT_EQ("5964589-43543534", ServerDataResult.SyncToken);
+
+ EXPECT_EQ(1, ServerDataResult.ListData.size());
+
+ EXPECT_EQ("/location3.vcf", ServerDataResult.ListData[0].Location);
+ EXPECT_EQ(ContactFile3, ServerDataResult.ListData[0].Data);
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Get_A_Contact_List_Due_To_Invalid_Permissions){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ COContactList ContactListSetup;
+ ContactListSetup.SyncToken = "";
+
+ FakeConnection.TestContactList = ContactListSetup;
+ FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
+ FakeConnection.TestEntityTag = "";
+ FakeConnection.TestResultCode = 403;
+ FakeConnection.TestSessionCode = 22;
+ FakeConnection.TestResultMessage = "You do not have permission to access this resource.";
+
+ COContactList ServerDataResult = FakeConnection.GetContactList("");
+
+ EXPECT_EQ(COREQUEST_ERROR_SERVER, ServerDataResult.ServerResponse.RequestResult);
+ EXPECT_EQ("", ServerDataResult.ServerResponse.EntityTag);
+ EXPECT_EQ(403, ServerDataResult.ServerResponse.ResultCode);
+ EXPECT_EQ(22, ServerDataResult.ServerResponse.SessionCode);
+ EXPECT_EQ("You do not have permission to access this resource.", ServerDataResult.ServerResponse.ResultMessage);
+
+ EXPECT_EQ(0, ServerDataResult.ListData.size());
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Get_A_Contact_List_Due_To_Missing_Resource){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ COContactList ContactListSetup;
+ ContactListSetup.SyncToken = "";
+
+ FakeConnection.TestContactList = ContactListSetup;
+ FakeConnection.TestRequestResult = COREQUEST_ERROR_SERVER;
+ FakeConnection.TestEntityTag = "";
+ FakeConnection.TestResultCode = 404;
+ FakeConnection.TestSessionCode = 22;
+ FakeConnection.TestResultMessage = "The resource could not be found.";
+
+ COContactList ServerDataResult = FakeConnection.GetContactList("");
+
+ EXPECT_EQ(COREQUEST_ERROR_SERVER, ServerDataResult.ServerResponse.RequestResult);
+ EXPECT_EQ("", ServerDataResult.ServerResponse.EntityTag);
+ EXPECT_EQ(404, ServerDataResult.ServerResponse.ResultCode);
+ EXPECT_EQ(22, ServerDataResult.ServerResponse.SessionCode);
+ EXPECT_EQ("The resource could not be found.", ServerDataResult.ServerResponse.ResultMessage);
+
+ EXPECT_EQ(0, ServerDataResult.ListData.size());
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Fails_To_Get_A_Contact_List_Due_To_No_Connection){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true, "/prefix", "Account1");
+ FakeConnection.ResultServerPrefix = "/prefix/test/b";
+ FakeConnection.Connect();
+
+ COContactList ContactListSetup;
+ ContactListSetup.SyncToken = "";
+
+ FakeConnection.TestContactList = ContactListSetup;
+ FakeConnection.TestRequestResult = COREQUEST_ERROR_NOTCONNECTED;
+ FakeConnection.TestEntityTag = "";
+ FakeConnection.TestResultCode = 404;
+ FakeConnection.TestSessionCode = 22;
+ FakeConnection.TestResultMessage = "The resource could not be found.";
+
+ COContactList ServerDataResult = FakeConnection.GetContactList("");
+
+ EXPECT_EQ(COREQUEST_ERROR_NOTCONNECTED, ServerDataResult.ServerResponse.RequestResult);
+ EXPECT_EQ("", ServerDataResult.ServerResponse.EntityTag);
+ EXPECT_EQ(404, ServerDataResult.ServerResponse.ResultCode);
+ EXPECT_EQ(22, ServerDataResult.ServerResponse.SessionCode);
+ EXPECT_EQ("The resource could not be found.", ServerDataResult.ServerResponse.ResultMessage);
+
+ EXPECT_EQ(0, ServerDataResult.ListData.size());
+
}
\ No newline at end of file