Skip to content

Commit 4ecc14c

Browse files
committed
tests: support optional PROXY_SCHEME
As we want to support HTTPS proxies, support an optional `GITTEST_REMOTE_PROXY_SCHEME` environment variable for tests that will allow for HTTPS support. (When unset, the tests default to HTTP proxies.)
1 parent de60d9b commit 4ecc14c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tests/online/clone.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ static char *_remote_ssh_pubkey = NULL;
2424
static char *_remote_ssh_privkey = NULL;
2525
static char *_remote_ssh_passphrase = NULL;
2626
static char *_remote_ssh_fingerprint = NULL;
27+
static char *_remote_proxy_scheme = NULL;
2728
static char *_remote_proxy_host = NULL;
2829
static char *_remote_proxy_user = NULL;
2930
static char *_remote_proxy_pass = NULL;
@@ -52,6 +53,7 @@ void test_online_clone__initialize(void)
5253
_remote_ssh_privkey = cl_getenv("GITTEST_REMOTE_SSH_KEY");
5354
_remote_ssh_passphrase = cl_getenv("GITTEST_REMOTE_SSH_PASSPHRASE");
5455
_remote_ssh_fingerprint = cl_getenv("GITTEST_REMOTE_SSH_FINGERPRINT");
56+
_remote_proxy_scheme = cl_getenv("GITTEST_REMOTE_PROXY_SCHEME");
5557
_remote_proxy_host = cl_getenv("GITTEST_REMOTE_PROXY_HOST");
5658
_remote_proxy_user = cl_getenv("GITTEST_REMOTE_PROXY_USER");
5759
_remote_proxy_pass = cl_getenv("GITTEST_REMOTE_PROXY_PASS");
@@ -74,6 +76,7 @@ void test_online_clone__cleanup(void)
7476
git__free(_remote_ssh_privkey);
7577
git__free(_remote_ssh_passphrase);
7678
git__free(_remote_ssh_fingerprint);
79+
git__free(_remote_proxy_scheme);
7780
git__free(_remote_proxy_host);
7881
git__free(_remote_proxy_user);
7982
git__free(_remote_proxy_pass);
@@ -731,7 +734,9 @@ void test_online_clone__proxy_credentials_request(void)
731734
if (!_remote_proxy_host || !_remote_proxy_user || !_remote_proxy_pass)
732735
cl_skip();
733736

734-
cl_git_pass(git_buf_printf(&url, "http://%s/", _remote_proxy_host));
737+
cl_git_pass(git_buf_printf(&url, "%s://%s/",
738+
_remote_proxy_scheme ? _remote_proxy_scheme : "http",
739+
_remote_proxy_host));
735740

736741
g_options.fetch_opts.proxy_opts.type = GIT_PROXY_SPECIFIED;
737742
g_options.fetch_opts.proxy_opts.url = url.ptr;
@@ -750,7 +755,9 @@ void test_online_clone__proxy_credentials_in_url(void)
750755
if (!_remote_proxy_host || !_remote_proxy_user || !_remote_proxy_pass)
751756
cl_skip();
752757

753-
cl_git_pass(git_buf_printf(&url, "http://%s:%s@%s/", _remote_proxy_user, _remote_proxy_pass, _remote_proxy_host));
758+
cl_git_pass(git_buf_printf(&url, "%s://%s:%s@%s/",
759+
_remote_proxy_scheme ? _remote_proxy_scheme : "http",
760+
_remote_proxy_user, _remote_proxy_pass, _remote_proxy_host));
754761

755762
g_options.fetch_opts.proxy_opts.type = GIT_PROXY_SPECIFIED;
756763
g_options.fetch_opts.proxy_opts.url = url.ptr;
@@ -774,7 +781,9 @@ void test_online_clone__proxy_credentials_in_environment(void)
774781

775782
g_options.fetch_opts.proxy_opts.type = GIT_PROXY_AUTO;
776783

777-
cl_git_pass(git_buf_printf(&url, "http://%s:%s@%s/", _remote_proxy_user, _remote_proxy_pass, _remote_proxy_host));
784+
cl_git_pass(git_buf_printf(&url, "%s://%s:%s@%s/",
785+
_remote_proxy_scheme ? _remote_proxy_scheme : "http",
786+
_remote_proxy_user, _remote_proxy_pass, _remote_proxy_host));
778787

779788
cl_setenv("HTTP_PROXY", url.ptr);
780789
cl_setenv("HTTPS_PROXY", url.ptr);

0 commit comments

Comments
 (0)