+
+TEST(CalDAV, GetEntryETag){
+
+ 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);
+
+ // Get the entry entity tag.
+
+ string eTagValue;
+
+ connResult = serverConnection.GetEntryETag(&entryCalendarHREFProcessing, &eTagValue);
+
+ EXPECT_EQ(CALDAVQUERYRESULT_OK, connResult.result);
+ ASSERT_EQ(207, connResult.httpCode);
+ ASSERT_EQ(CURLE_OK, connResult.code);
+
+}
+
+TEST(CalDAV, EditEntry){
+
+ // Check that EntryCalendarHREFProcessing is not blank.
+
+ ASSERT_NE("", entryCalendarHREFProcessing);
+
+ 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);
+
+ // Get the entry entity tag.
+
+ string eTagValue;
+
+ connResult = serverConnection.GetEntryETag(&entryCalendarHREFProcessing, &eTagValue);
+
+ EXPECT_EQ(CALDAVQUERYRESULT_OK, connResult.result);
+ ASSERT_EQ(207, connResult.httpCode);
+ ASSERT_EQ(CURLE_OK, connResult.code);
+
+ // Update the contact with new information.
+
+ string editEntryData = "BEGIN:VCALENDAR\n"
+ "VERSION:2.0\n"
+ "PRODID:-//Xestia//Calendar Unit Testing//KW\n"
+ "BEGIN:VEVENT\n"
+ "UID:";
+ editEntryData += entryUUID;
+ editEntryData += "\n"
+ "DTSTAMP:20160116T190200Z\n"
+ "DTSTART:20160116T190200Z\n"
+ "DTEND:20160116T190200Z\n"
+ "SUMMARY:Unit Test Event 1 which has to be a really long summary as we don't k\n"
+ " now if multiple line processing is going to work without it. I mean seriousl\n"
+ " y, how annoying can this potentially be?\n"
+ "END:VEVENT\n"
+ "END:VCALENDAR\n";
+
+ connResult = serverConnection.EditEntry(&entryCalendarHREFProcessing, &editEntryData, &eTagValue);
+
+ EXPECT_EQ(CALDAVQUERYRESULT_OK, connResult.result);
+ ASSERT_EQ(204, connResult.httpCode);
+ ASSERT_EQ(CURLE_OK, connResult.code);