[glib-networking/mcatanzaro/#195: 8/9] Disable libproxy resolver when running environment proxy test




commit 419f4b8a3850d00b5a951c45dfeac2e32146fea4
Author: Michael Catanzaro <mcatanzaro redhat com>
Date:   Mon Aug 29 12:49:13 2022 -0500

    Disable libproxy resolver when running environment proxy test
    
    After reversing the priority of the environment proxy vs. libproxy
    proxy resolvers, I forgot to also reverse the logic that ensures the
    correct resolver gets used when running tests.
    
    Part-of: <https://gitlab.gnome.org/GNOME/glib-networking/-/merge_requests/222>

 proxy/environment/genvironmentproxyresolver.c | 13 -------------
 proxy/libproxy/glibproxyresolver.c            |  9 ++++++++-
 2 files changed, 8 insertions(+), 14 deletions(-)
---
diff --git a/proxy/environment/genvironmentproxyresolver.c b/proxy/environment/genvironmentproxyresolver.c
index 6b9150c9..e70b3bad 100644
--- a/proxy/environment/genvironmentproxyresolver.c
+++ b/proxy/environment/genvironmentproxyresolver.c
@@ -53,22 +53,9 @@ G_DEFINE_TYPE_EXTENDED (GEnvironmentProxyResolver,
                                                g_environment_proxy_resolver_iface_init))
 #endif
 
-static gboolean
-is_running_libproxy_test (void)
-{
-  const char *gio_proxy_test_name;
-  gio_proxy_test_name = g_getenv ("GIO_PROXY_TEST_NAME");
-  if (g_strcmp0 (gio_proxy_test_name, "libproxy") == 0)
-    return TRUE;
-  return FALSE;
-}
-
 static gboolean
 g_environment_proxy_resolver_is_supported (GProxyResolver *object)
 {
-  if (is_running_libproxy_test ())
-    return FALSE;
-
   return (g_getenv ("ftp_proxy") || g_getenv ("FTP_PROXY") ||
           g_getenv ("https_proxy") || g_getenv ("HTTPS_PROXY") ||
           g_getenv ("http_proxy") || g_getenv ("HTTP_PROXY") ||
diff --git a/proxy/libproxy/glibproxyresolver.c b/proxy/libproxy/glibproxyresolver.c
index e1c5a60b..3d84af52 100644
--- a/proxy/libproxy/glibproxyresolver.c
+++ b/proxy/libproxy/glibproxyresolver.c
@@ -73,10 +73,17 @@ g_libproxy_resolver_finalize (GObject *object)
   G_OBJECT_CLASS (g_libproxy_resolver_parent_class)->finalize (object);
 }
 
+static gboolean
+is_running_environment_proxy_test (void)
+{
+  return g_strcmp0 (g_getenv ("GIO_PROXY_TEST_NAME"), "environment") == 0;
+}
+
 static void
 g_libproxy_resolver_init (GLibproxyResolver *resolver)
 {
-  resolver->factory = px_proxy_factory_new ();
+  if (!is_running_environment_proxy_test ())
+    resolver->factory = px_proxy_factory_new ();
 }
 
 static gboolean


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]