#include <gtest/gtest.h>
#include "classes/FakeConnectionObject.h"
+#include <chrono>
+#include <thread>
// TODO: Add tests for the CardDAV object.
std::string ServerPass1 = "pass";
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
- FakeConnection.ResultSSLVerified = true;
+ FakeConnection.ResultSSLVerified = COSSL_VERIFIED;
FakeConnection.Connect();
- EXPECT_EQ(true, FakeConnection.SSLVerify());
+ EXPECT_EQ(COSSL_VERIFIED, FakeConnection.SSLVerify());
}
std::string ServerPass1 = "pass";
FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
- FakeConnection.ResultSSLVerified = false;
+ FakeConnection.ResultSSLVerified = COSSL_UNABLETOVERIFY;
FakeConnection.Connect();
- EXPECT_EQ(false, FakeConnection.SSLVerify());
+ EXPECT_EQ(COSSL_UNABLETOVERIFY, FakeConnection.SSLVerify());
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Has_User_Verified_SSL_Cerficiate_Data){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, true);
+ FakeConnection.ResultSSLVerified = COSSL_VERIFIED_USER;
+ FakeConnection.Connect();
+
+ EXPECT_EQ(COSSL_VERIFIED_USER, FakeConnection.SSLVerify());
+
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Connection_That_Doesnt_Use_SSL_Return_Not_Applicable_SSL_Result){
+
+ std::string ServerAddress1 = "gibberish.invalid";
+ std::string ServerUser1 = "user";
+ std::string ServerPass1 = "pass";
+
+ FakeConnectionObject FakeConnection(ServerAddress1, 8080, ServerUser1, ServerPass1, false);
+ FakeConnection.ResultSSLVerified = COSSL_NOTAPPLICABLE;
+ FakeConnection.Connect();
+
+ EXPECT_EQ(COSSL_NOTAPPLICABLE, FakeConnection.SSLVerify());
}
EXPECT_EQ(0, ServerDataResult.ListData.size());
+}
+
+TEST(CardDAV, Use_Fake_To_Simulate_A_Wait_For_A_Completed_Task){
+
+ 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.ResultTaskCompleted = false;
+
+ while (!FakeConnection.IsTaskCompleted()){
+
+ std::this_thread::sleep_for(std::chrono::milliseconds(250));
+ FakeConnection.ResultTaskCompleted = true;
+
+ }
+
+ EXPECT_TRUE(FakeConnection.ResultTaskCompleted);
+
}
\ No newline at end of file