diff options
author | Patrick Steinhardt <ps@pks.im> | 2017-06-07 12:48:48 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2018-01-03 11:50:39 +0000 |
commit | fea6092079d5c09b499e472efead2f7aa81ce8a1 (patch) | |
tree | ec55be6b41fd09d010ec8e8999c5c40f0d117da4 /tests/online/clone.c | |
parent | 543ec149b86a68e12dd141a6141e82850dabbf21 (diff) | |
download | libgit2-fea6092079d5c09b499e472efead2f7aa81ce8a1.tar.gz |
tests: online::clone: construct credential-URL from environment
We support two types of passing credentials to the proxy, either via the
URL or explicitly by specifying user and password. We test these types
by modifying the proxy URL and executing the tests twice, which is
in fact unnecessary and requires us to maintain the list of environment
variables and test executions across multiple CI infrastructures.
To fix the situation, we can just always pass the host, port, user and
password to the tests. The tests can then assemble the complete URL
either with or without included credentials, allowing us to test both
cases in-process.
Diffstat (limited to 'tests/online/clone.c')
-rw-r--r-- | tests/online/clone.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/tests/online/clone.c b/tests/online/clone.c index 5eda73f87..b6709869e 100644 --- a/tests/online/clone.c +++ b/tests/online/clone.c @@ -677,24 +677,34 @@ static int proxy_creds(git_cred **out, const char *url, const char *username, un void test_online_clone__proxy_credentials_request(void) { + git_buf url = GIT_BUF_INIT; + if (!_remote_proxy_url || !_remote_proxy_user || !_remote_proxy_pass) cl_skip(); + cl_git_pass(git_buf_printf(&url, "http://%s/", _remote_proxy_url)); + g_options.fetch_opts.proxy_opts.type = GIT_PROXY_SPECIFIED; - g_options.fetch_opts.proxy_opts.url = _remote_proxy_url; + g_options.fetch_opts.proxy_opts.url = url.ptr; g_options.fetch_opts.proxy_opts.credentials = proxy_creds; called_proxy_creds = 0; cl_git_pass(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options)); cl_assert(called_proxy_creds); + + git_buf_free(&url); } void test_online_clone__proxy_credentials_in_url(void) { - if (!_remote_proxy_url) + git_buf url = GIT_BUF_INIT; + + if (!_remote_proxy_url || !_remote_proxy_user || !_remote_proxy_pass) cl_skip(); + cl_git_pass(git_buf_printf(&url, "http://%s:%s@%s/", _remote_proxy_user, _remote_proxy_pass, _remote_proxy_url)); + g_options.fetch_opts.proxy_opts.type = GIT_PROXY_SPECIFIED; - g_options.fetch_opts.proxy_opts.url = _remote_proxy_url; + g_options.fetch_opts.proxy_opts.url = url.ptr; called_proxy_creds = 0; cl_git_pass(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options)); cl_assert(called_proxy_creds == 0); |