// Setup the server address.
- if (ConnectionData.UseSSL == true){
- ServerAddress += "https://";
- } else {
- ServerAddress += "http://";
- }
-
- ServerAddress += ConnectionData.Hostname;
-
- // Check if server port is 80, otherwise
- // specifiy the port number in the address.
-
- if (ConnectionData.Port != 80){
- ServerAddress += ":";
- ServerAddress += to_string(ConnectionData.Port);
- }
-
- ServerAddress += "/principals/";
+ ServerAddress = BuildServerAddress(&ConnectionData, "/principals/");
// Setup the server password.
return true;
+}
+
+string BuildServerAddress(CalDAVConnectionData *ConnData, string URIAddress){
+
+ string ServerAddress;
+
+ // Setup the server address.
+
+ if (ConnData->UseSSL == true){
+ ServerAddress += "https://";
+ } else {
+ ServerAddress += "http://";
+ }
+
+ ServerAddress += ConnData->Hostname;
+
+ // Check if server port is 80, otherwise
+ // specifiy the port number in the address.
+
+ if (ConnData->Port != 80){
+ ServerAddress += ":";
+ ServerAddress += to_string(ConnData->Port);
+ }
+
+ ServerAddress += URIAddress;
+
+ return ServerAddress;
+
}
\ No newline at end of file
}
+TEST(CalDAV, BuildServerAddress){
+
+ CalDAVConnectionData ConnNormal;
+ ProcessConnectionDataFileResult DataFileResult;
+ bool ValidDataNormal = false;
+
+ // Attempt to read the caldavtest.auth file.
+
+ DataFileResult = ProcessConnectionDataFile("caldavtest.auth", &ConnNormal);
+ if (DataFileResult == PROCESSCONNECTIONDATAFILE_OK){
+ ValidDataNormal = true;
+ }
+
+ if (ValidDataNormal == false){
+
+ // Cannot read the caldavtest.auth file properly.
+
+ cout << "The caldavtest.auth file does not exist or is invalid!" << endl;
+ cout << "Please create the caldavtest.auth file using the following format:" << endl << endl;
+ cout << "server=localname" << endl;
+ cout << "port=8080" << endl;
+ cout << "user=username" << endl;
+ cout << "pass=password" << endl;
+ cout << "ssl=false" << endl;
+ cout << "prefix=/lalala/lookatme/thisisa/prefix" << endl << endl;
+
+ }
+
+ ASSERT_EQ(true, ValidDataNormal);
+
+ // Setup the server address to check.
+
+ string ServerAddress;
+
+ // Setup the server address.
+
+ if (ConnNormal.UseSSL == true){
+ ServerAddress += "https://";
+ } else {
+ ServerAddress += "http://";
+ }
+
+ ServerAddress += ConnNormal.Hostname;
+
+ // Check if server port is 80, otherwise
+ // specifiy the port number in the address.
+
+ if (ConnNormal.Port != 80){
+ ServerAddress += ":";
+ ServerAddress += to_string(ConnNormal.Port);
+ }
+
+ ServerAddress += "/principals/";
+
+ ASSERT_EQ(ServerAddress, BuildServerAddress(&ConnNormal, "/principals/"));
+
+}
+
TEST(CalDAV, ListCalendars){
CalDAVConnectionData ConnNormal;