diff options
| author | Vicent Martà <vicent@github.com> | 2013-11-18 11:49:51 -0800 |
|---|---|---|
| committer | Vicent Martà <vicent@github.com> | 2013-11-18 11:49:51 -0800 |
| commit | 8ea7472e087bfc43b3acd257f7264342b433cccb (patch) | |
| tree | 761cc446f2141ebedd82b88a6bdf31d893effdd2 /tests | |
| parent | 872094441c165446a7bb989c0f215e1a4018218e (diff) | |
| parent | 84efffc33ab352d68cf981da0d6c8d358244cabc (diff) | |
| download | libgit2-8ea7472e087bfc43b3acd257f7264342b433cccb.tar.gz | |
Merge pull request #1960 from ethomson/ntlm
NTLM/Negotiate support in WinHTTP
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/online/clone.c | 33 | ||||
| -rw-r--r-- | tests/online/push.c | 16 |
2 files changed, 48 insertions, 1 deletions
diff --git a/tests/online/clone.c b/tests/online/clone.c index aa3d6b26a..d036a5a47 100644 --- a/tests/online/clone.c +++ b/tests/online/clone.c @@ -183,6 +183,39 @@ void test_online_clone__custom_remote_callbacks(void) cl_assert(callcount > 0); } +static int cred_failure_cb( + git_cred **cred, + const char *url, + const char *username_from_url, + unsigned int allowed_types, + void *data) +{ + return -1; +} + +void test_online_clone__cred_callback_failure_is_euser(void) +{ + const char *remote_url = cl_getenv("GITTEST_REMOTE_URL"); + const char *remote_user = cl_getenv("GITTEST_REMOTE_USER"); + const char *remote_default = cl_getenv("GITTEST_REMOTE_DEFAULT"); + int error; + + if (!remote_url) { + printf("GITTEST_REMOTE_URL unset; skipping clone test\n"); + return; + } + + if (!remote_user && !remote_default) { + printf("GITTEST_REMOTE_USER and GITTEST_REMOTE_DEFAULT unset; skipping clone test\n"); + return; + } + + g_options.remote_callbacks.credentials = cred_failure_cb; + + cl_git_fail(error = git_clone(&g_repo, remote_url, "./foo", &g_options)); + cl_assert_equal_i(error, GIT_EUSER); +} + void test_online_clone__credentials(void) { /* Remote URL environment variable must be set. User and password are optional. */ diff --git a/tests/online/push.c b/tests/online/push.c index aeb1ab47d..be505c3a1 100644 --- a/tests/online/push.c +++ b/tests/online/push.c @@ -9,14 +9,17 @@ static git_repository *_repo; +static char *_remote_url; + static char *_remote_ssh_key; static char *_remote_ssh_pubkey; static char *_remote_ssh_passphrase; -static char *_remote_url; static char *_remote_user; static char *_remote_pass; +static char *_remote_default; + static int cred_acquire_cb(git_cred **, const char *, const char *, unsigned int, void *); static git_remote *_remote; @@ -47,11 +50,21 @@ static int cred_acquire_cb( GIT_UNUSED(user_from_url); GIT_UNUSED(payload); + if (GIT_CREDTYPE_DEFAULT & allowed_types) { + if (!_remote_default) { + printf("GITTEST_REMOTE_DEFAULT must be set to use NTLM/Negotiate credentials\n"); + return -1; + } + + return git_cred_default_new(cred); + } + if (GIT_CREDTYPE_SSH_KEY & allowed_types) { if (!_remote_user || !_remote_ssh_pubkey || !_remote_ssh_key || !_remote_ssh_passphrase) { printf("GITTEST_REMOTE_USER, GITTEST_REMOTE_SSH_PUBKEY, GITTEST_REMOTE_SSH_KEY and GITTEST_REMOTE_SSH_PASSPHRASE must be set\n"); return -1; } + return git_cred_ssh_key_new(cred, _remote_user, _remote_ssh_pubkey, _remote_ssh_key, _remote_ssh_passphrase); } @@ -298,6 +311,7 @@ void test_online_push__initialize(void) _remote_ssh_key = cl_getenv("GITTEST_REMOTE_SSH_KEY"); _remote_ssh_pubkey = cl_getenv("GITTEST_REMOTE_SSH_PUBKEY"); _remote_ssh_passphrase = cl_getenv("GITTEST_REMOTE_SSH_PASSPHRASE"); + _remote_default = cl_getenv("GITTEST_REMOTE_DEFAULT"); _remote = NULL; if (_remote_url) { |
