diff options
author | Ben Straub <bs@github.com> | 2013-01-09 00:58:20 +0400 |
---|---|---|
committer | Ben Straub <bs@github.com> | 2013-01-10 01:31:17 +0400 |
commit | ffb02b1630da85e063a816cc6dddcdc004a8ff72 (patch) | |
tree | f8660cf4d0c99b7185b1428edc777c6f573b9041 /tests-clar/online/clone.c | |
parent | 252b24049cf7018ba80c736fda636c53c465fbd2 (diff) |
Expose stock user/pass credential utility
Diffstat (limited to 'tests-clar/online/clone.c')
-rw-r--r-- | tests-clar/online/clone.c | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/tests-clar/online/clone.c b/tests-clar/online/clone.c index 082ed52b3..9c51d692c 100644 --- a/tests-clar/online/clone.c +++ b/tests-clar/online/clone.c @@ -121,7 +121,7 @@ static int update_tips(const char *refname, const git_oid *a, const git_oid *b, return 0; } -void test_clone_network__custom_remote_callbacks(void) +void test_online_clone__custom_remote_callbacks(void) { git_remote_callbacks remote_callbacks = GIT_REMOTE_CALLBACKS_INIT; int callcount = 0; @@ -134,39 +134,18 @@ void test_clone_network__custom_remote_callbacks(void) cl_assert(callcount > 0); } -struct cred_user_pass { - const char *user; - const char *pass; -}; - -static int cred_acquire( - git_cred **cred, - const char *url, - unsigned int allowed_types, - void *payload) -{ - struct cred_user_pass *user_pass = (struct cred_user_pass*)payload; - - GIT_UNUSED(url); - if ((GIT_CREDTYPE_USERPASS_PLAINTEXT & allowed_types) == 0 || - git_cred_userpass_plaintext_new(cred, user_pass->user, user_pass->pass) < 0) - return -1; - - return 0; -} - -void test_clone_network__credentials(void) +void test_online_clone__credentials(void) { /* Remote URL environment variable must be set. User and password are optional. */ const char *remote_url = cl_getenv("GITTEST_REMOTE_URL"); - struct cred_user_pass user_pass = { + git_cred_stock_userpass_plaintext_payload user_pass = { cl_getenv("GITTEST_REMOTE_USER"), cl_getenv("GITTEST_REMOTE_PASS") }; if (!remote_url) return; - g_options.cred_acquire_cb = cred_acquire; + g_options.cred_acquire_cb = git_cred_stock_userpass_plaintext; g_options.cred_acquire_payload = &user_pass; cl_git_pass(git_clone(&g_repo, remote_url, "./foo", &g_options)); |