tests/discoverer: Add file variations
Enables testing properly the ICS header check which is ignored if content-type is text/calendar. Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/814>
This commit is contained in:
@@ -49,17 +49,50 @@ process_get (SoupServerMessage *message,
|
||||
const gchar *prefix,
|
||||
const gchar *path)
|
||||
{
|
||||
g_autofree gchar *calendar_path = g_strdup_printf ("%s/calendar", prefix);
|
||||
g_autofree gchar *crlf_calendar_path = g_strdup_printf ("%s/crlf-calendar", prefix);
|
||||
g_autofree gchar *crlf_calendar_stream_path = g_strdup_printf ("%s/crlf-calendar-stream", prefix);
|
||||
g_autofree gchar *lf_calendar_path = g_strdup_printf ("%s/lf-calendar", prefix);
|
||||
g_autofree gchar *lf_calendar_stream_path = g_strdup_printf ("%s/lf-calendar-stream", prefix);
|
||||
g_autofree gchar *calendar_file = g_strdup_printf ("%s/calendar.ics", prefix);
|
||||
|
||||
if (g_strcmp0 (path, calendar_path) == 0)
|
||||
if (g_strcmp0 (path, crlf_calendar_path) == 0)
|
||||
{
|
||||
g_debug ("Serving empty calendar");
|
||||
g_debug ("Serving empty CRLF calendar as text/calendar");
|
||||
soup_server_message_set_response (message,
|
||||
"text/calendar",
|
||||
SOUP_MEMORY_STATIC,
|
||||
GCAL_TEST_SERVER_EMPTY_CALENDAR,
|
||||
strlen (GCAL_TEST_SERVER_EMPTY_CALENDAR));
|
||||
GCAL_TEST_SERVER_EMPTY_CRLF_CALENDAR,
|
||||
strlen (GCAL_TEST_SERVER_EMPTY_CRLF_CALENDAR));
|
||||
}
|
||||
|
||||
if (g_strcmp0 (path, crlf_calendar_stream_path) == 0)
|
||||
{
|
||||
g_debug ("Serving empty CRLF calendar as application/octet-stream");
|
||||
soup_server_message_set_response (message,
|
||||
"application/octet-stream",
|
||||
SOUP_MEMORY_STATIC,
|
||||
GCAL_TEST_SERVER_EMPTY_CRLF_CALENDAR,
|
||||
strlen (GCAL_TEST_SERVER_EMPTY_CRLF_CALENDAR));
|
||||
}
|
||||
|
||||
if (g_strcmp0 (path, lf_calendar_path) == 0)
|
||||
{
|
||||
g_debug ("Serving empty LF calendar as text/calendar");
|
||||
soup_server_message_set_response (message,
|
||||
"text/calendar",
|
||||
SOUP_MEMORY_STATIC,
|
||||
GCAL_TEST_SERVER_EMPTY_LF_CALENDAR,
|
||||
strlen (GCAL_TEST_SERVER_EMPTY_LF_CALENDAR));
|
||||
}
|
||||
|
||||
if (g_strcmp0 (path, lf_calendar_stream_path) == 0)
|
||||
{
|
||||
g_debug ("Serving empty LF calendar as application/octet-stream");
|
||||
soup_server_message_set_response (message,
|
||||
"application/octet-stream",
|
||||
SOUP_MEMORY_STATIC,
|
||||
GCAL_TEST_SERVER_EMPTY_LF_CALENDAR,
|
||||
strlen (GCAL_TEST_SERVER_EMPTY_LF_CALENDAR));
|
||||
}
|
||||
|
||||
if (g_strcmp0 (path, calendar_file) == 0)
|
||||
|
||||
@@ -25,11 +25,14 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define _GCAL_TEST_SERVER_CALENDAR_BEGIN "BEGIN:VCALENDAR"
|
||||
#define _GCAL_TEST_SERVER_CALENDAR_END "END:VCALENDAR"
|
||||
|
||||
#define GCAL_TEST_SERVER_EMPTY_CALENDAR \
|
||||
"BEGIN:VCALENDAR\n" \
|
||||
"END:VCALENDAR"
|
||||
#define GCAL_TEST_SERVER_EMPTY_CRLF_CALENDAR \
|
||||
_GCAL_TEST_SERVER_CALENDAR_BEGIN "\r\n" _GCAL_TEST_SERVER_CALENDAR_END
|
||||
|
||||
#define GCAL_TEST_SERVER_EMPTY_LF_CALENDAR \
|
||||
_GCAL_TEST_SERVER_CALENDAR_BEGIN "\n" _GCAL_TEST_SERVER_CALENDAR_END
|
||||
|
||||
#define GCAL_TYPE_SIMPLE_SERVER (gcal_simple_server_get_type())
|
||||
G_DECLARE_FINAL_TYPE (GcalSimpleServer, gcal_simple_server, GCAL, SIMPLE_SERVER, GObject)
|
||||
|
||||
+30
-12
@@ -57,27 +57,45 @@ discovered_file_cb (GObject *source_object,
|
||||
static void
|
||||
discoverer_file (void)
|
||||
{
|
||||
const gchar *const paths[] = {
|
||||
/* content-type: text-calendar - CRLF line break - ICS header check result ignored */
|
||||
"/public/crlf-calendar",
|
||||
/* content-type: text-calendar - LF line break - ICS header check result ignored */
|
||||
"/public/lf-calendar",
|
||||
/* content-type: application/octet-stream - CRLF line break - ICS header check result used */
|
||||
"/public/crlf-calendar-stream",
|
||||
/* content-type: application/octet-stream - LF line break - ICS header check result used */
|
||||
"/public/lf-calendar-stream",
|
||||
};
|
||||
g_autoptr (GcalSimpleServer) server = NULL;
|
||||
g_autoptr (GMainLoop) mainloop = NULL;
|
||||
g_autoptr (GUri) uri = NULL;
|
||||
g_autofree gchar *uri_str = NULL;
|
||||
guint i;
|
||||
|
||||
g_test_bug ("1274");
|
||||
|
||||
server = init_server ();
|
||||
uri = gcal_simple_server_get_uri (server);
|
||||
e_util_change_uri_component (&uri, SOUP_URI_PATH, "/public/calendar");
|
||||
|
||||
uri_str = g_uri_to_string_partial (uri, G_URI_HIDE_PASSWORD);
|
||||
|
||||
mainloop = g_main_loop_new (NULL, FALSE);
|
||||
|
||||
gcal_discover_sources_from_uri (uri_str,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
discovered_file_cb,
|
||||
mainloop);
|
||||
for (i = 0; i < G_N_ELEMENTS (paths); i++)
|
||||
{
|
||||
g_autofree gchar *uri_str = NULL;
|
||||
|
||||
g_main_loop_run (mainloop);
|
||||
e_util_change_uri_component (&uri, SOUP_URI_PATH, paths[i]);
|
||||
|
||||
uri_str = g_uri_to_string_partial (uri, G_URI_HIDE_PASSWORD);
|
||||
|
||||
gcal_discover_sources_from_uri (uri_str,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
discovered_file_cb,
|
||||
mainloop);
|
||||
|
||||
g_main_loop_run (mainloop);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************************************************************/
|
||||
@@ -146,7 +164,7 @@ discoverer_webdav_unauthorized (void)
|
||||
|
||||
server = init_server ();
|
||||
uri = gcal_simple_server_get_uri (server);
|
||||
e_util_change_uri_component (&uri, SOUP_URI_PATH, "/secret-area/calendar");
|
||||
e_util_change_uri_component (&uri, SOUP_URI_PATH, "/secret-area/lf-calendar");
|
||||
|
||||
uri_str = g_uri_to_string_partial (uri, G_URI_HIDE_PASSWORD);
|
||||
|
||||
|
||||
+2
-2
@@ -153,7 +153,7 @@ server_request_no_auth_calendar (void)
|
||||
|
||||
server = init_server ();
|
||||
uri = gcal_simple_server_get_uri (server);
|
||||
e_util_change_uri_component (&uri, SOUP_URI_PATH, "/public/calendar");
|
||||
e_util_change_uri_component (&uri, SOUP_URI_PATH, "/public/lf-calendar");
|
||||
|
||||
session = gcal_create_soup_session ();
|
||||
|
||||
@@ -203,7 +203,7 @@ server_request_auth_calendar (void)
|
||||
|
||||
server = init_server ();
|
||||
uri = gcal_simple_server_get_uri (server);
|
||||
e_util_change_uri_component (&uri, SOUP_URI_PATH, "/secret-area/calendar");
|
||||
e_util_change_uri_component (&uri, SOUP_URI_PATH, "/secret-area/lf-calendar");
|
||||
|
||||
session = gcal_create_soup_session ();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user