summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2014-08-01 13:06:37 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2014-08-15 11:12:42 -0400
commitadcdeb36b0892c61832eb9add0b5cd6e9610e064 (patch)
tree4cd35b95b268addf0772a827ed7679908c511bfc
parentf96e7e6c94e4c414b4ec7e3a7bb37482488b3a80 (diff)
downloadlibgit2-adcdeb36b0892c61832eb9add0b5cd6e9610e064.tar.gz
online::clone::credentials support default credentials
-rw-r--r--tests/online/clone.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/tests/online/clone.c b/tests/online/clone.c
index 88aacbd43..0cd0f3115 100644
--- a/tests/online/clone.c
+++ b/tests/online/clone.c
@@ -226,9 +226,28 @@ void test_online_clone__cred_callback_failure_return_code_is_tunnelled(void)
cl_git_fail_with(git_clone(&g_repo, remote_url, "./foo", &g_options), -1);
}
+int cred_default(
+ git_cred **cred,
+ const char *url,
+ const char *user_from_url,
+ unsigned int allowed_types,
+ void *payload)
+{
+ GIT_UNUSED(url);
+ GIT_UNUSED(user_from_url);
+ GIT_UNUSED(payload);
+
+ if (!(allowed_types & GIT_CREDTYPE_DEFAULT))
+ return 0;
+
+ return git_cred_default_new(cred);
+}
+
void test_online_clone__credentials(void)
{
- /* Remote URL environment variable must be set. User and password are optional. */
+ /* Remote URL environment variable must be set.
+ * User and password are optional.
+ */
const char *remote_url = cl_getenv("GITTEST_REMOTE_URL");
git_cred_userpass_payload user_pass = {
cl_getenv("GITTEST_REMOTE_USER"),
@@ -237,8 +256,12 @@ void test_online_clone__credentials(void)
if (!remote_url) return;
- g_options.remote_callbacks.credentials = git_cred_userpass;
- g_options.remote_callbacks.payload = &user_pass;
+ if (cl_getenv("GITTEST_REMOTE_DEFAULT")) {
+ g_options.remote_callbacks.credentials = cred_default;
+ } else {
+ g_options.remote_callbacks.credentials = git_cred_userpass;
+ g_options.remote_callbacks.payload = &user_pass;
+ }
cl_git_pass(git_clone(&g_repo, remote_url, "./foo", &g_options));
git_repository_free(g_repo); g_repo = NULL;