summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2023-02-23 10:51:09 +0000
committerGitHub <noreply@github.com>2023-02-23 10:51:09 +0000
commitbf7d3888d5827fe36e8ef854a18e36376696f51c (patch)
tree5463cef5da494bee5b6c18e0191e1c0e5d684a31
parentc9387a61656cd666d76a0491f6839c1a32835ca0 (diff)
parent80016e0e9658662e67f39a937c52de64fa642ea9 (diff)
downloadlibgit2-bf7d3888d5827fe36e8ef854a18e36376696f51c.tar.gz
Merge pull request #6498 from libgit2/ethomson/httpproxy_env_tests
tests: always unset HTTP_PROXY before starting tests
-rw-r--r--tests/libgit2/remote/httpproxy.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/tests/libgit2/remote/httpproxy.c b/tests/libgit2/remote/httpproxy.c
index 6ba00b7c9..60fc67dec 100644
--- a/tests/libgit2/remote/httpproxy.c
+++ b/tests/libgit2/remote/httpproxy.c
@@ -6,7 +6,6 @@
static git_repository *repo;
static git_net_url url = GIT_NET_URL_INIT;
-static int orig_proxies_need_reset = 0;
static char *orig_http_proxy = NULL;
static char *orig_https_proxy = NULL;
static char *orig_no_proxy = NULL;
@@ -21,20 +20,25 @@ void test_remote_httpproxy__initialize(void)
git_remote_free(remote);
- orig_proxies_need_reset = 0;
+ /* Clear everything for a fresh start */
+ orig_http_proxy = cl_getenv("HTTP_PROXY");
+ orig_https_proxy = cl_getenv("HTTPS_PROXY");
+ orig_no_proxy = cl_getenv("NO_PROXY");
+
+ cl_setenv("HTTP_PROXY", NULL);
+ cl_setenv("HTTPS_PROXY", NULL);
+ cl_setenv("NO_PROXY", NULL);
}
void test_remote_httpproxy__cleanup(void)
{
- if (orig_proxies_need_reset) {
- cl_setenv("HTTP_PROXY", orig_http_proxy);
- cl_setenv("HTTPS_PROXY", orig_https_proxy);
- cl_setenv("NO_PROXY", orig_no_proxy);
-
- git__free(orig_http_proxy);
- git__free(orig_https_proxy);
- git__free(orig_no_proxy);
- }
+ cl_setenv("HTTP_PROXY", orig_http_proxy);
+ cl_setenv("HTTPS_PROXY", orig_https_proxy);
+ cl_setenv("NO_PROXY", orig_no_proxy);
+
+ git__free(orig_http_proxy);
+ git__free(orig_https_proxy);
+ git__free(orig_no_proxy);
git_net_url_dispose(&url);
cl_git_sandbox_cleanup();
@@ -145,16 +149,6 @@ void test_remote_httpproxy__config_overrides_detached_remote(void)
void test_remote_httpproxy__env(void)
{
- orig_http_proxy = cl_getenv("HTTP_PROXY");
- orig_https_proxy = cl_getenv("HTTPS_PROXY");
- 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);