diff options
Diffstat (limited to 'tests/online/clone.c')
-rw-r--r-- | tests/online/clone.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/online/clone.c b/tests/online/clone.c index b84be405c..0fc8d4271 100644 --- a/tests/online/clone.c +++ b/tests/online/clone.c @@ -24,6 +24,9 @@ static char *_remote_ssh_pubkey = NULL; static char *_remote_ssh_privkey = NULL; static char *_remote_ssh_passphrase = NULL; static char *_remote_ssh_fingerprint = NULL; +static char *_remote_proxy_url = NULL; +static char *_remote_proxy_user = NULL; +static char *_remote_proxy_pass = NULL; void test_online_clone__initialize(void) @@ -46,6 +49,9 @@ void test_online_clone__initialize(void) _remote_ssh_privkey = cl_getenv("GITTEST_REMOTE_SSH_KEY"); _remote_ssh_passphrase = cl_getenv("GITTEST_REMOTE_SSH_PASSPHRASE"); _remote_ssh_fingerprint = cl_getenv("GITTEST_REMOTE_SSH_FINGERPRINT"); + _remote_proxy_url = cl_getenv("GITTEST_REMOTE_PROXY_URL"); + _remote_proxy_user = cl_getenv("GITTEST_REMOTE_PROXY_USER"); + _remote_proxy_pass = cl_getenv("GITTEST_REMOTE_PROXY_PASS"); } void test_online_clone__cleanup(void) @@ -63,6 +69,9 @@ void test_online_clone__cleanup(void) git__free(_remote_ssh_privkey); git__free(_remote_ssh_passphrase); git__free(_remote_ssh_fingerprint); + git__free(_remote_proxy_url); + git__free(_remote_proxy_user); + git__free(_remote_proxy_pass); } void test_online_clone__network_full(void) @@ -653,3 +662,38 @@ void test_online_clone__start_with_http(void) cl_git_pass(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options)); } + +static int called_proxy_creds; +static int proxy_creds(git_cred **out, const char *url, const char *username, unsigned int allowed, void *payload) +{ + GIT_UNUSED(payload); + GIT_UNUSED(username); + + called_proxy_creds = 1; + return git_cred_userpass_plaintext_new(out, _remote_proxy_user, _remote_proxy_pass); +} + +void test_online_clone__proxy_credentials_request(void) +{ + if (!_remote_proxy_url || !_remote_proxy_user || !_remote_proxy_pass) + cl_skip(); + + 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.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); +} + +void test_online_clone__proxy_credentials_in_url(void) +{ + if (!_remote_proxy_url) + cl_skip(); + + g_options.fetch_opts.proxy_opts.type = GIT_PROXY_SPECIFIED; + g_options.fetch_opts.proxy_opts.url = _remote_proxy_url; + 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); +} |