[glib] GSimpleProxyResolver: Add test case for broken hostname
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GSimpleProxyResolver: Add test case for broken hostname
- Date: Thu, 1 Feb 2018 14:59:29 +0000 (UTC)
commit 88366621eee608013fedd661884e769bbce87321
Author: Bastien Nocera <hadess hadess net>
Date: Thu Oct 27 17:59:49 2016 +0200
GSimpleProxyResolver: Add test case for broken hostname
https://bugzilla.gnome.org/show_bug.cgi?id=772989
gio/tests/simple-proxy.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 54 insertions(+), 0 deletions(-)
---
diff --git a/gio/tests/simple-proxy.c b/gio/tests/simple-proxy.c
index 0f1f63d..00bdb2e 100644
--- a/gio/tests/simple-proxy.c
+++ b/gio/tests/simple-proxy.c
@@ -20,12 +20,66 @@
#include <gio/gio.h>
static void
+async_result_cb (GObject *obj,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GAsyncResult **result_out = user_data;
+ *result_out = g_object_ref (result);
+}
+
+static void
test_uris (void)
{
GProxyResolver *resolver;
gchar *ignore_hosts[2] = { "127.0.0.1", NULL };
gchar **proxies;
GError *error = NULL;
+ const gchar *uri;
+ gchar *str = NULL;
+ GAsyncResult *result = NULL;
+
+ /* Valid URI. */
+ uri = "http://%E0%B4%A8%E0%B4%B2:80/";
+ resolver = g_simple_proxy_resolver_new (NULL, ignore_hosts);
+
+ proxies = g_proxy_resolver_lookup (resolver, uri, NULL, &error);
+ g_assert_no_error (error);
+ g_strfreev (proxies);
+
+ g_proxy_resolver_lookup_async (resolver, uri, NULL, async_result_cb, &result);
+ while (result == NULL)
+ g_main_context_iteration (NULL, TRUE);
+ proxies = g_proxy_resolver_lookup_finish (resolver, result, &error);
+ g_assert_no_error (error);
+ g_strfreev (proxies);
+ g_clear_object (&result);
+
+ g_object_unref (resolver);
+
+ /* Invalid URI. */
+ uri = "%E0%B4%A8%E0%B4%B2";
+ str = g_strdup_printf ("Invalid URI ā%sā", uri);
+ resolver = g_simple_proxy_resolver_new (NULL, ignore_hosts);
+
+ proxies = g_proxy_resolver_lookup (resolver, uri, NULL, &error);
+ g_assert_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT);
+ g_assert_cmpstr (error->message, ==, str);
+ g_clear_error (&error);
+ g_assert_null (proxies);
+ g_clear_object (&result);
+
+ g_proxy_resolver_lookup_async (resolver, uri, NULL, async_result_cb, &result);
+ while (result == NULL)
+ g_main_context_iteration (NULL, TRUE);
+ proxies = g_proxy_resolver_lookup_finish (resolver, result, &error);
+ g_assert_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT);
+ g_assert_cmpstr (error->message, ==, str);
+ g_clear_error (&error);
+ g_assert_null (proxies);
+
+ g_object_unref (resolver);
+ g_free (str);
resolver = g_simple_proxy_resolver_new ("default://", ignore_hosts);
g_simple_proxy_resolver_set_uri_proxy (G_SIMPLE_PROXY_RESOLVER (resolver),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]