X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Ftests%2Fxestiacalendar_caldav.h;h=f156b2abf744b663cc600124c87b31b44a25e99f;hb=8916c05c5281bf0c97419df6e7ce6d641c56fb3e;hp=fc5a50138248bc5f04e6ecb7bc5569587095a016;hpb=15992dd4b8f9f8d03a0e9e625163ed1cf40a8884;p=xestiacalendar%2F.git diff --git a/source/tests/xestiacalendar_caldav.h b/source/tests/xestiacalendar_caldav.h index fc5a501..f156b2a 100644 --- a/source/tests/xestiacalendar_caldav.h +++ b/source/tests/xestiacalendar_caldav.h @@ -497,26 +497,217 @@ TEST(CalDAV, ListCalendars){ ConnResult = ServerConnection.GetServerResult(); + EXPECT_EQ(CALDAVQUERYRESULT_OK, ConnResult.Result); + ASSERT_EQ(207, ConnResult.HTTPCode); + ASSERT_EQ(CURLE_OK, ConnResult.Code); + +} + +TEST(CalDAV, AddCalendar){ + + 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); - // Get the user principal. + // Add a calendar to the server. - CurrentUserPrincipal = ServerConnection.GetUserPrincipal(); + ConnResult = ServerConnection.AddCalendar("New Calendar"); - // Check the response from the server. + EXPECT_EQ(CALDAVQUERYRESULT_OK, ConnResult.Result); + ASSERT_EQ(201, ConnResult.HTTPCode); + ASSERT_EQ(CURLE_OK, ConnResult.Code); + +} + +TEST(CalDAV, EditCalendar){ + + 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(207, ConnResult.HTTPCode); + ASSERT_EQ(200, ConnResult.HTTPCode); + ASSERT_EQ(CURLE_OK, ConnResult.Code); + ASSERT_EQ(true, ConnSupport.BasicSupport); + + // Add a calendar to the server. + + ConnResult = ServerConnection.AddCalendar("Calendar To Edit"); + + EXPECT_EQ(CALDAVQUERYRESULT_OK, ConnResult.Result); + ASSERT_EQ(201, ConnResult.HTTPCode); ASSERT_EQ(CURLE_OK, ConnResult.Code); // 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); + + // Find the calendar containing the name "Calendar To Edit" + // created earlier. + + int ItemSeek = 0; + bool ItemFound = false; + for (map::iterator CalendarNameIter = CalendarList.Name.begin(); + CalendarNameIter != CalendarList.Name.end(); CalendarNameIter++){ + + if (CalendarNameIter->second == "Calendar To Edit"){ + ItemFound = true; + break; + } + + ItemSeek++; + + } + + ASSERT_NE(false, ItemFound); + + // Edit the name of the calendar. + + string CalendarEditHREF = CalendarList.HREF[ItemSeek]; + string NewCalendarName = "Edited Calendar"; + + ConnResult = ServerConnection.EditCalendar(&CalendarEditHREF, &NewCalendarName); + + EXPECT_EQ(CALDAVQUERYRESULT_OK, ConnResult.Result); + ASSERT_EQ(207, ConnResult.HTTPCode); + ASSERT_EQ(CURLE_OK, ConnResult.Code); + + // Edit the colour of the calendar. + + Colour NewColour; + + NewColour.red = 255; + NewColour.green = 0; + NewColour.blue = 0; + NewColour.alpha = 0; + + ConnResult = ServerConnection.EditCalendar(&CalendarEditHREF, &NewColour); + + EXPECT_EQ(CALDAVQUERYRESULT_OK, ConnResult.Result); + ASSERT_EQ(207, ConnResult.HTTPCode); + ASSERT_EQ(CURLE_OK, ConnResult.Code); + + // Edit the description of the calendar. + + string NewCalendarDescription = "Update Calendar Description"; + + ConnResult = ServerConnection.EditCalendarDescription(&CalendarEditHREF, &NewCalendarDescription); + + EXPECT_EQ(CALDAVQUERYRESULT_OK, ConnResult.Result); + ASSERT_EQ(207, ConnResult.HTTPCode); + ASSERT_EQ(CURLE_OK, ConnResult.Code); + + // Edit the order of the calendar. + + int NewCalendarOrder = 30; + + ConnResult = ServerConnection.EditCalendar(&CalendarEditHREF, &NewCalendarOrder); + + EXPECT_EQ(CALDAVQUERYRESULT_OK, ConnResult.Result); + ASSERT_EQ(207, ConnResult.HTTPCode); + ASSERT_EQ(CURLE_OK, ConnResult.Code); + // Edit all of the available properties of the calendar. + NewCalendarName = "Calendar Edited Again"; + NewCalendarDescription = "Another updated calendar description"; + NewColour.red = 0; + NewColour.green = 255; + NewColour.blue = 0; + NewColour.alpha = 0; + NewCalendarOrder = 40; + ConnResult = ServerConnection.EditCalendar(&CalendarEditHREF, + &NewCalendarName, + &NewColour, + &NewCalendarDescription, + &NewCalendarOrder); + + EXPECT_EQ(CALDAVQUERYRESULT_OK, ConnResult.Result); + ASSERT_EQ(207, ConnResult.HTTPCode); + ASSERT_EQ(CURLE_OK, ConnResult.Code); + +} } \ No newline at end of file