Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added code and unit tests to FakeConnectionObject class
[xestiaab/.git] / source / tests / xestiaab_carddav.cpp
index e3ae7ae..e71f4d5 100644 (file)
@@ -120,8 +120,6 @@ TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_Returning_Success){
        std::string ServerAddress1 = "gibberish.invalid";
        std::string ServerUser1 = "user";
        std::string ServerPass1 = "pass";
-       std::string ServerPrefix1 = "/prefix";
-       std::string ServerAccount1 = "Account1";
        
        FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
        FakeConnection.ResultStatus = COCONNECT_OK;
@@ -135,8 +133,6 @@ TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_Returning_InvalidAddress){
        std::string ServerAddress1 = "gibberish.invalid";
        std::string ServerUser1 = "user";
        std::string ServerPass1 = "pass";
-       std::string ServerPrefix1 = "/prefix";
-       std::string ServerAccount1 = "Account1";
        
        FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
        FakeConnection.ResultStatus = COCONNECT_INVALID;
@@ -150,8 +146,6 @@ TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_Returning_Timeout){
        std::string ServerAddress1 = "gibberish.invalid";
        std::string ServerUser1 = "user";
        std::string ServerPass1 = "pass";
-       std::string ServerPrefix1 = "/prefix";
-       std::string ServerAccount1 = "Account1";
        
        FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
        FakeConnection.ResultStatus = COCONNECT_TIMEOUT;
@@ -165,12 +159,224 @@ TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_Returning_Authentication_Failure
        std::string ServerAddress1 = "gibberish.invalid";
        std::string ServerUser1 = "user";
        std::string ServerPass1 = "pass";
-       std::string ServerPrefix1 = "/prefix";
-       std::string ServerAccount1 = "Account1";
        
        FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
        FakeConnection.ResultStatus = COCONNECT_AUTHFAIL;
        
        EXPECT_EQ(COCONNECT_AUTHFAIL, FakeConnection.Connect());
        
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Is_Able_To_Login){
+       
+       std::string ServerAddress1 = "gibberish.invalid";
+       std::string ServerUser1 = "user";
+       std::string ServerPass1 = "pass";
+       
+       FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
+       FakeConnection.ResultAuthPassed = true;
+       FakeConnection.Connect();
+       
+       EXPECT_EQ(true, FakeConnection.AbleToLogin());
+       
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Is_Unable_To_Login){
+       
+       std::string ServerAddress1 = "gibberish.invalid";
+       std::string ServerUser1 = "user";
+       std::string ServerPass1 = "pass";
+       
+       FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
+       FakeConnection.ResultAuthPassed = false;
+       FakeConnection.Connect();
+       
+       EXPECT_EQ(false, FakeConnection.AbleToLogin());
+       
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Can_Do_Processing){
+       
+       std::string ServerAddress1 = "gibberish.invalid";
+       std::string ServerUser1 = "user";
+       std::string ServerPass1 = "pass";
+       
+       FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
+       FakeConnection.ResultCanProcess = true;
+       FakeConnection.Connect();
+       
+       EXPECT_EQ(true, FakeConnection.CanDoProcessing());
+       
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Supports_SSL){
+       
+       std::string ServerAddress1 = "gibberish.invalid";
+       std::string ServerUser1 = "user";
+       std::string ServerPass1 = "pass";
+       
+       FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
+       FakeConnection.ResultSSLStatus  = true;
+       FakeConnection.Connect();
+       
+       EXPECT_EQ(true, FakeConnection.CanDoSSL());
+       
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Does_Not_Support_SSL){
+       
+       std::string ServerAddress1 = "gibberish.invalid";
+       std::string ServerUser1 = "user";
+       std::string ServerPass1 = "pass";
+       
+       FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
+       FakeConnection.ResultSSLStatus  = false;
+       FakeConnection.Connect();
+       
+       EXPECT_EQ(false, FakeConnection.CanDoSSL());
+       
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Has_Valid_SSL_Certificate_Data){
+       
+       std::string ServerAddress1 = "gibberish.invalid";
+       std::string ServerUser1 = "user";
+       std::string ServerPass1 = "pass";
+       
+       FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
+       FakeConnection.ResultSSLVerified = true;
+       FakeConnection.Connect();
+       
+       EXPECT_EQ(true, FakeConnection.SSLVerify());
+       
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Has_Invalid_SSL_Certificate_Data){
+       
+       std::string ServerAddress1 = "gibberish.invalid";
+       std::string ServerUser1 = "user";
+       std::string ServerPass1 = "pass";
+       
+       FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
+       FakeConnection.ResultSSLVerified = false;
+       FakeConnection.Connect();
+       
+       EXPECT_EQ(false, FakeConnection.SSLVerify());
+       
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Has_A_Valid_Response){
+       
+       std::string ServerAddress1 = "gibberish.invalid";
+       std::string ServerUser1 = "user";
+       std::string ServerPass1 = "pass";
+       
+       FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
+       FakeConnection.ResultValidResponse = true;
+       FakeConnection.Connect();
+       
+       EXPECT_EQ(true, FakeConnection.HasValidResponse());
+       
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Has_A_Invalid_Response){
+       
+       std::string ServerAddress1 = "gibberish.invalid";
+       std::string ServerUser1 = "user";
+       std::string ServerPass1 = "pass";
+       
+       FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
+       FakeConnection.ResultValidResponse = false;
+       FakeConnection.Connect();
+       
+       EXPECT_EQ(false, FakeConnection.HasValidResponse());
+       
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Uses_A_Self_Signed_SSL_Certificate){
+       
+       std::string ServerAddress1 = "gibberish.invalid";
+       std::string ServerUser1 = "user";
+       std::string ServerPass1 = "pass";
+       
+       FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
+       FakeConnection.ResultSelfSigned = true;
+       FakeConnection.Connect();
+       
+       EXPECT_EQ(true, FakeConnection.IsSelfSigned());
+       
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Doesnt_Use_A_Self_Signed_SSL_Certificate){
+       
+       std::string ServerAddress1 = "gibberish.invalid";
+       std::string ServerUser1 = "user";
+       std::string ServerPass1 = "pass";
+       
+       FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
+       FakeConnection.ResultSelfSigned = false;
+       FakeConnection.Connect();
+       
+       EXPECT_EQ(false, FakeConnection.IsSelfSigned());
+       
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Gets_The_Server_Prefix_Of_Prefix_Test_A){
+       
+       std::string ServerAddress1 = "gibberish.invalid";
+       std::string ServerUser1 = "user";
+       std::string ServerPass1 = "pass";
+       
+       FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
+       FakeConnection.ResultServerPrefix = "/prefix/test/a";
+       FakeConnection.Connect();
+       
+       EXPECT_EQ("/prefix/test/a", FakeConnection.GetDefaultPrefix());
+       
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Gets_The_Server_Prefix_Of_Prefix_Test_B){
+       
+       std::string ServerAddress1 = "gibberish.invalid";
+       std::string ServerUser1 = "user";
+       std::string ServerPass1 = "pass";
+       
+       FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
+       FakeConnection.ResultServerPrefix = "/prefix/test/b";
+       FakeConnection.Connect();
+       
+       EXPECT_EQ("/prefix/test/b", FakeConnection.GetDefaultPrefix());
+       
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Adds_A_Contact_Successfully){
+       
+       std::string ServerAddress1 = "gibberish.invalid";
+       std::string ServerUser1 = "user";
+       std::string ServerPass1 = "pass";
+       
+       FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
+       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_OK;
+       FakeConnection.TestEntityTag = "4324svafhuiaffsdhui";
+       FakeConnection.TestResultCode = 200;
+       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("", AddContactResult.ResultMessage);
+       
 }
\ No newline at end of file
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