[gupnp/wip/phako/libsoup3] test: Check redirect for folders
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gupnp/wip/phako/libsoup3] test: Check redirect for folders
- Date: Mon, 27 Dec 2021 08:56:42 +0000 (UTC)
commit 3f8d66c2c3f569427da5be5d00ac3898a32267ff
Author: Jens Georg <mail jensge org>
Date: Mon Dec 27 09:53:10 2021 +0100
test: Check redirect for folders
tests/test-context.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 58 insertions(+), 1 deletion(-)
---
diff --git a/tests/test-context.c b/tests/test-context.c
index 9cb09dc..73e5cff 100644
--- a/tests/test-context.c
+++ b/tests/test-context.c
@@ -762,6 +762,60 @@ test_gupnp_context_http_language_serve_folder ()
g_object_unref (session);
}
+void
+test_gupnp_context_http_folder_redirect ()
+{
+ GError *error = NULL;
+ GUPnPContext *context = create_context (0, &error);
+ DefaultCallbackData d = { .bytes = NULL, .loop = NULL };
+
+ d.loop = g_main_loop_new (NULL, FALSE);
+
+ GSList *uris =
+ soup_server_get_uris (gupnp_context_get_server (context));
+ g_assert_no_error (error);
+
+ gupnp_context_host_path (context, DATA_PATH "/locale", "/foo");
+
+ SoupSession *session = soup_session_new ();
+ char *base = g_uri_to_string (uris->data);
+ char *new_uri =
+ g_uri_resolve_relative (base, "foo", G_URI_FLAGS_NONE, &error);
+ g_free (base);
+
+ SoupMessage *msg = soup_message_new (SOUP_METHOD_GET, new_uri);
+
+ // Do not automatically follow the redirect as we want to check if it happened
+ soup_message_add_flags (msg, SOUP_MESSAGE_NO_REDIRECT);
+
+ soup_session_send_and_read_async (session,
+ msg,
+ G_PRIORITY_DEFAULT,
+ NULL,
+ soup_message_default_callback,
+ &d);
+ g_main_loop_run (d.loop);
+
+ g_assert_cmpint (soup_message_get_status (msg),
+ ==,
+ SOUP_STATUS_MOVED_PERMANENTLY);
+ g_assert_nonnull (d.bytes);
+ g_assert_null (g_bytes_get_data (d.bytes, NULL));
+ g_bytes_unref (d.bytes);
+
+
+ g_slist_free_full (uris, (GDestroyNotify) g_uri_unref);
+ g_object_unref (context);
+ g_object_unref (msg);
+ g_free (new_uri);
+
+ // Make sure the source teardown handlers get run so we don't confuse valgrind
+ g_timeout_add (500, (GSourceFunc) g_main_loop_quit, d.loop);
+ g_main_loop_run (d.loop);
+ g_main_loop_unref (d.loop);
+ g_object_unref (session);
+}
+
void
test_gupnp_context_host_for_agent ()
{
@@ -913,7 +967,10 @@ int main (int argc, char *argv[]) {
g_test_add_func ("/context/http/language/serve-folder",
test_gupnp_context_http_language_serve_folder);
- g_test_add_func ("/context/http/host-for-agent",
+ g_test_add_func ("/context/http/host/folder-rewrite",
+ test_gupnp_context_http_folder_redirect);
+
+ g_test_add_func ("/context/http/host/for-agent",
test_gupnp_context_host_for_agent);
g_test_add_func ("/context/utility/rewrite_uri",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]