From 31e32ddf35b0710fa528cfc1b7c67c5697207a66 Mon Sep 17 00:00:00 2001 From: Mathieu Parent Date: Tue, 14 Sep 2021 09:34:25 +0200 Subject: Add test to ensure empty proxy env behaves like unset env Signed-off-by: Mathieu Parent --- tests/remote/httpproxy.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/remote/httpproxy.c b/tests/remote/httpproxy.c index 097db4cd5..00115a812 100644 --- a/tests/remote/httpproxy.c +++ b/tests/remote/httpproxy.c @@ -136,4 +136,8 @@ void test_remote_httpproxy__env(void) /* configuration overrides environment variables */ cl_setenv("NO_PROXY", "github.none"); assert_config_match("http.https://github.com.proxy", "http://localhost:11/"); + + /* empty env behaves like unset env */ + cl_setenv("HTTPS_PROXY", ""); + assert_proxy_is(NULL); } -- cgit v1.2.1 From 8e7621241d7246a5cf516df296bc85f3164efbf9 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Mon, 20 Sep 2021 12:19:05 -0400 Subject: httpproxy: move empty string test above config The configuration change will override the environment variable, so the environment variable check needs to come first. --- tests/remote/httpproxy.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/remote/httpproxy.c b/tests/remote/httpproxy.c index 00115a812..0985c8cd5 100644 --- a/tests/remote/httpproxy.c +++ b/tests/remote/httpproxy.c @@ -112,6 +112,11 @@ void test_remote_httpproxy__env(void) orig_no_proxy = cl_getenv("NO_PROXY"); orig_proxies_need_reset = 1; + /* Clear everything for a fresh start */ + cl_setenv("HTTP_PROXY", NULL); + cl_setenv("HTTPS_PROXY", NULL); + cl_setenv("NO_PROXY", NULL); + /* HTTP proxy is ignored for HTTPS */ cl_setenv("HTTP_PROXY", "http://localhost:9/"); assert_proxy_is(NULL); @@ -133,11 +138,11 @@ void test_remote_httpproxy__env(void) cl_setenv("NO_PROXY", "github.dev,github.com,github.foo"); assert_proxy_is(NULL); + cl_setenv("HTTPS_PROXY", ""); + assert_proxy_is(NULL); + /* configuration overrides environment variables */ + cl_setenv("HTTPS_PROXY", "http://localhost:10/"); cl_setenv("NO_PROXY", "github.none"); assert_config_match("http.https://github.com.proxy", "http://localhost:11/"); - - /* empty env behaves like unset env */ - cl_setenv("HTTPS_PROXY", ""); - assert_proxy_is(NULL); } -- cgit v1.2.1