Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added code and unit tests to list calendars from the server.
[xestiacalendar/.git] / source / tests / xestiacalendar_caldav.h
index 7d4c005..8c9860b 100644 (file)
@@ -368,10 +368,9 @@ TEST(CalDAV, CalendarServerSupport){
        
 }
 
-TEST(CalDAV, ListCalendars){
-       
-       CalDAVConnectionData ConnNormal;
-       string CurrentUserPrincipal;
+TEST(CalDAV, GetCalendarHome){
+       CalDAVConnectionData ConnNormal;        
 
        bool ValidDataNormal = false;
        
@@ -404,35 +403,31 @@ TEST(CalDAV, ListCalendars){
        
        CalDAVServerResult ConnResult = ServerConnection.Connect();
        
-       EXPECT_EQ(CALDAVQUERYRESULT_OK, ConnResult.Result);
+       ASSERT_EQ(CALDAVQUERYRESULT_OK, ConnResult.Result);
        ASSERT_EQ(200, ConnResult.HTTPCode);
        ASSERT_EQ(CURLE_OK, ConnResult.Code);
        
-       // Check that the server supports CalDAV.
+       // Check for basic support of the calendar server.
        
        CalDAVServerSupport ConnSupport = ServerConnection.GetServerSupport();
-       ConnResult = ServerConnection.GetServerResult();
        
-       EXPECT_EQ(CALDAVQUERYRESULT_OK, ConnResult.Result);
-       ASSERT_EQ(200, ConnResult.HTTPCode);
-       ASSERT_EQ(CURLE_OK, ConnResult.Code);
        ASSERT_EQ(true, ConnSupport.BasicSupport);
        
-       // Get the list of calendars.
+       // Get the user principal.
        
-       CalDAVCalendarList CalendarList = ServerConnection.GetCalendars();
+       string CurrentUserPrincipal = ServerConnection.GetUserPrincipal();
        
-       // Check the response result from the server.
+       // Check the response from the server.
        
        ConnResult = ServerConnection.GetServerResult();
        
        EXPECT_EQ(CALDAVQUERYRESULT_OK, ConnResult.Result);
-       ASSERT_EQ(200, ConnResult.HTTPCode);
+       ASSERT_EQ(207, ConnResult.HTTPCode);
        ASSERT_EQ(CURLE_OK, ConnResult.Code);
        
-       // Get the user principal.
+       // Get the calendar home.
        
-       CurrentUserPrincipal = ServerConnection.GetUserPrincipal();
+       string CalendarHome = ServerConnection.GetCalendarHome(CurrentUserPrincipal);
        
        // Check the response from the server.
        
@@ -441,11 +436,69 @@ TEST(CalDAV, ListCalendars){
        EXPECT_EQ(CALDAVQUERYRESULT_OK, ConnResult.Result);
        ASSERT_EQ(207, ConnResult.HTTPCode);
        ASSERT_EQ(CURLE_OK, ConnResult.Code);
+  
+}
+
+TEST(CalDAV, ListCalendars){
+       
+       CalDAVConnectionData ConnNormal;
+       string CurrentUserPrincipal;
+
+       bool ValidDataNormal = false;
+       
+       // Attempt to read the caldavtest.auth file.
+
+       ProcessConnectionDataFileResult DataFileResult = ProcessConnectionDataFile("caldavtest.auth", &ConnNormal);
+       if (DataFileResult == PROCESSCONNECTIONDATAFILE_OK){
+               ValidDataNormal = true;
+       }
+
+       ASSERT_EQ(true, ValidDataNormal);
+       
+       // Setup the connection.
+       
+       CalDAV ServerConnection;
+       
+       ServerConnection.SetupConnectionData(&ConnNormal);
+       
+       // Verify the connection settings.
+       
+       CalDAVStatus CalDAVStatus = ServerConnection.GetConnectionData();
+       
+       ASSERT_EQ(CalDAVStatus.Hostname, ConnNormal.Hostname);
+       ASSERT_EQ(CalDAVStatus.Username, ConnNormal.Username);
+       ASSERT_EQ(CalDAVStatus.Port, ConnNormal.Port);
+       ASSERT_EQ(CalDAVStatus.Prefix, ConnNormal.Prefix);
+       ASSERT_EQ(CalDAVStatus.UseSSL, ConnNormal.UseSSL);
+       
+       // Connect to the server.
+       
+       CalDAVServerResult ConnResult = ServerConnection.Connect();
+       
+       EXPECT_EQ(CALDAVQUERYRESULT_OK, ConnResult.Result);
+       ASSERT_EQ(200, ConnResult.HTTPCode);
+       ASSERT_EQ(CURLE_OK, ConnResult.Code);
+       
+       // Check that the server supports CalDAV.
+       
+       CalDAVServerSupport ConnSupport = ServerConnection.GetServerSupport();
+       ConnResult = ServerConnection.GetServerResult();
+       
+       EXPECT_EQ(CALDAVQUERYRESULT_OK, ConnResult.Result);
+       ASSERT_EQ(200, ConnResult.HTTPCode);
+       ASSERT_EQ(CURLE_OK, ConnResult.Code);
+       ASSERT_EQ(true, ConnSupport.BasicSupport);
        
        // Get the list of calendars.
        
+       CalDAVCalendarList CalendarList = ServerConnection.GetCalendars();
        
+       // Check the response result from the server.
        
+       ConnResult = ServerConnection.GetServerResult();
        
+       EXPECT_EQ(CALDAVQUERYRESULT_OK, ConnResult.Result);
+       ASSERT_EQ(207, ConnResult.HTTPCode);
+       ASSERT_EQ(CURLE_OK, ConnResult.Code);
        
 }
\ 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