X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Ftests%2Fxestiacalendar_caldav.h;h=f3a7c3ef9f5685c5e49854084c696652c133dc58;hb=19736989bf2de4c5007659958373445ab40b0956;hp=f2f765424d15c3fad34a64c1b069982bb5b67395;hpb=00dff59febad28b9588ceca2aa8cde1d0438971f;p=xestiacalendar%2F.git diff --git a/source/tests/xestiacalendar_caldav.h b/source/tests/xestiacalendar_caldav.h index f2f7654..f3a7c3e 100644 --- a/source/tests/xestiacalendar_caldav.h +++ b/source/tests/xestiacalendar_caldav.h @@ -1,4 +1,4 @@ -// xestiacalendar_icaleventload.h - Xestia Calendar CalDAV Object Unit Tests +// xestiacalendar_caldav.h - Xestia Calendar CalDAV Object Unit Tests // // (c) 2016 Xestia Software Development. // @@ -25,15 +25,44 @@ using namespace std; TEST(CalDAV, BasicTests){ + CalDAVConnectionData ConnPlain; + CalDAVConnectionData ConnNormal; + CalDAVConnectionData ConnFail; + CalDAVConnectionData ConnTimeout; + ProcessConnectionDataFileResult DataFileResult; + bool ValidDataPlain = false; bool ValidDataNormal = false; bool ValidDataFail = false; bool ValidDataTimeout = false; // Attempt to read the caldavtest-plain.auth file. + + DataFileResult = ProcessConnectionDataFile("caldavtest-plain.auth", &ConnPlain); + if (DataFileResult == PROCESSCONNECTIONDATAFILE_OK){ + ValidDataPlain = true; + } + + // Attempt to read the caldavtest.auth file. + + DataFileResult = ProcessConnectionDataFile("caldavtest.auth", &ConnNormal); + if (DataFileResult == PROCESSCONNECTIONDATAFILE_OK){ + ValidDataNormal = true; + } + // Attempt to read the caldavtest-fail.auth file. + + DataFileResult = ProcessConnectionDataFile("caldavtest-fail.auth", &ConnFail); + if (DataFileResult == PROCESSCONNECTIONDATAFILE_OK){ + ValidDataFail = true; + } + // Attempt to read the caldavtest-timeout.auth file. - // Attempt to read the caldavtest.auth file. + + DataFileResult = ProcessConnectionDataFile("caldavtest-fail.auth", &ConnTimeout); + if (DataFileResult == PROCESSCONNECTIONDATAFILE_OK){ + ValidDataTimeout = true; + } if (ValidDataPlain == false){ @@ -103,8 +132,55 @@ TEST(CalDAV, BasicTests){ // (*nix version) Setup an initial connection (just plain // text). + CalDAV CalDAVPlain; + CalDAVPlain.SetupConnectionData(&ConnPlain); + + // Verify that the settings match with the CalDAVConnectionData + // passed. + + CalDAVStatus CalDAVPlainStatus = CalDAVPlain.GetConnectionData(); + + ASSERT_EQ(CalDAVPlainStatus.Hostname, ConnPlain.Hostname); + ASSERT_EQ(CalDAVPlainStatus.Username, ConnPlain.Username); + ASSERT_EQ(CalDAVPlainStatus.Port, ConnPlain.Port); + ASSERT_EQ(CalDAVPlainStatus.Prefix, ConnPlain.Prefix); + ASSERT_EQ(CalDAVPlainStatus.UseSSL, ConnPlain.UseSSL); + // Verify that the connection was successful. + CalDAVServerResult ConnResult = CalDAVPlain.Connect(); + + ASSERT_EQ(CALDAVQUERYRESULT_OK, ConnResult.Result); + ASSERT_EQ(200, ConnResult.HTTPCode); + ASSERT_EQ(CURLE_OK, ConnResult.Code); + + // Do another connection and this time the connection should + // fail due to being an invalid host name. + + CalDAVConnectionData ConnPlainFail; + ConnPlainFail.Hostname = "server.invalid"; + ConnPlainFail.Username = "fail"; + ConnPlainFail.Password = "fail"; + ConnPlainFail.Port = 80; + ConnPlainFail.UseSSL = false; + + // Setup the CalDAV connection object. + + CalDAV CalDAVPlainFail; + CalDAVPlainFail.SetupConnectionData(&ConnPlainFail); + + // Setup the CalDAVStatus object. + + CalDAVStatus CalDAVPlainFailStatus = CalDAVPlain.GetConnectionData(); + + // Connect and fail. + + ConnResult = CalDAVPlainFail.Connect(); + + ASSERT_EQ(CALDAVQUERYRESULT_SERVERERROR, ConnResult.Result); + ASSERT_EQ(0, ConnResult.HTTPCode); + ASSERT_EQ(CURLE_COULDNT_RESOLVE_HOST, ConnResult.Code); + // (*nix version) Setup an initial connection (with a valid // SSL certificate).