8000 Merge pull request #6498 from libgit2/ethomson/httpproxy_env_tests · libgit2/libgit2@bf7d388 · GitHub
[go: up one dir, main page]

Skip to content

Commit bf7d388

Browse files
authored
Merge pull request #6498 from libgit2/ethomson/httpproxy_env_tests
tests: always unset HTTP_PROXY before starting tests
2 parents c9387a6 + 80016e0 commit bf7d388

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

tests/libgit2/remote/httpproxy.c

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
static git_repository *repo;
77
static git_net_url url = GIT_NET_URL_INIT;
88

9-
static int orig_proxies_need_reset = 0;
109
static char *orig_http_proxy = NULL;
1110
static char *orig_https_proxy = NULL;
1211
static char *orig_no_proxy = NULL;
@@ -21,20 +20,25 @@ void test_remote_httpproxy__initialize(void)
2120

2221
git_remote_free(remote);
2322

24-
orig_proxies_need_reset = 0;
23+
/* Clear everything for a fresh start */
24+
orig_http_proxy = cl_getenv("HTTP_PROXY");
25+
orig_https_proxy = cl_getenv("HTTPS_PROXY");
26+
orig_no 8000 _proxy = cl_getenv("NO_PROXY");
27+
28+
cl_setenv("HTTP_PROXY", NULL);
29+
cl_setenv("HTTPS_PROXY", NULL);
30+
cl_setenv("NO_PROXY", NULL);
2531
}
2632

2733
void test_remote_httpproxy__cleanup(void)
2834
{
29-
if (orig_proxies_need_reset) {
30-
cl_setenv("HTTP_PROXY", orig_http_proxy);
31-
cl_setenv("HTTPS_PROXY", orig_https_proxy);
32-
cl_setenv("NO_PROXY", orig_no_proxy);
33-
34-
git__free(orig_http_proxy);
35-
git__free(orig_https_proxy);
36-
git__free(orig_no_proxy);
37-
}
35+
cl_setenv("HTTP_PROXY", orig_http_proxy);
36+
cl_setenv("HTTPS_PROXY", orig_https_proxy);
37+
cl_setenv("NO_PROXY", orig_no_proxy);
38+
39+
git__free(orig_http_proxy);
40+
git__free(orig_https_proxy);
41+
git__free(orig_no_proxy);
3842

3943
git_net_url_dispose(&url);
4044
cl_git_sandbox_cleanup();
@@ -145,16 +149,6 @@ void test_remote_httpproxy__config_overrides_detached_remote(void)
145149

146150
void test_remote_httpproxy__env(void)
147151
{
148-
orig_http_proxy = cl_getenv("HTTP_PROXY");
149-
orig_https_proxy = cl_getenv("HTTPS_PROXY");
150-
orig_no_proxy = cl_getenv("NO_PROXY");
151-
orig_proxies_need_reset = 1;
152-
153-
/* Clear everything for a fresh start */
154-
cl_setenv("HTTP_PROXY", NULL);
155-
cl_setenv("HTTPS_PROXY", NULL);
156-
cl_setenv("NO_PROXY", NULL);
157-
158152
/* HTTP proxy is ignored for HTTPS */
159153
cl_setenv("HTTP_PROXY", "http://localhost:9/");
160154
assert_proxy_is(NULL);

0 commit comments

Comments
 (0)
0