Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added code to build server address from subroutine and also unit tests.
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Wed, 2 Mar 2016 11:26:34 +0000 (11:26 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Wed, 2 Mar 2016 11:26:34 +0000 (11:26 +0000)
source/objects/CalDAV/CalDAV.cpp
source/objects/CalDAV/CalDAV.h
source/tests/xestiacalendar_caldav.h

index 27bc692..21e8ddc 100644 (file)
@@ -92,23 +92,7 @@ CalDAVServerResult CalDAV::Connect(){
 
        // 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.
        
@@ -208,4 +192,32 @@ bool CalDAVObjectValidSettings(CalDAVConnectionData *ConnData){
        
        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
index 9fe29b8..47b9617 100644 (file)
@@ -97,5 +97,6 @@ class CalDAV{
 // CalDAVConnectionData struct.
 
 bool CalDAVObjectValidSettings(CalDAVConnectionData *ConnData);
+string BuildServerAddress(CalDAVConnectionData *ConnData, string URIAddress);
 
 #endif
index 3dff68b..1557685 100644 (file)
@@ -263,6 +263,64 @@ TEST(CalDAV, BasicTests){
        
 }
 
+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;        
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