Skip to content

Commit 03c5877

Browse files
committed
online::clone: skip creds fallback test
At present, we have three online tests against bitbucket: one which specifies the credentials in the payload, one which specifies the correct credentials in the URL and a final one that specifies the incorrect credentials in the URL. Bitbucket has begun responding to the latter test with a 403, which causes us to fail. Break these three tests into separate tests so that we can skip the latter until this is resolved on Bitbucket's end or until we can change the test to a different provider.
1 parent 937e7e2 commit 03c5877

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

tests/online/clone.c

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,15 +357,45 @@ void test_online_clone__bitbucket_style(void)
357357
cl_git_pass(git_clone(&g_repo, BB_REPO_URL, "./foo", &g_options));
358358
git_repository_free(g_repo); g_repo = NULL;
359359
cl_fixture_cleanup("./foo");
360+
}
361+
362+
void test_online_clone__bitbucket_uses_creds_in_url(void)
363+
{
364+
git_cred_userpass_payload user_pass = {
365+
"libgit2", "wrong"
366+
};
367+
368+
g_options.fetch_opts.callbacks.credentials = git_cred_userpass;
369+
g_options.fetch_opts.callbacks.payload = &user_pass;
360370

361-
/* User and pass from URL */
362-
user_pass.password = "wrong";
371+
/*
372+
* Correct user and pass are in the URL; the (incorrect) creds in
373+
* the `git_cred_userpass_payload` should be ignored.
374+
*/
363375
cl_git_pass(git_clone(&g_repo, BB_REPO_URL_WITH_PASS, "./foo", &g_options));
364376
git_repository_free(g_repo); g_repo = NULL;
365377
cl_fixture_cleanup("./foo");
378+
}
379+
380+
void test_online_clone__bitbucket_falls_back_to_specified_creds(void)
381+
{
382+
git_cred_userpass_payload user_pass = {
383+
"libgit2", "libgit2"
384+
};
385+
386+
g_options.fetch_opts.callbacks.credentials = git_cred_userpass;
387+
g_options.fetch_opts.callbacks.payload = &user_pass;
388+
389+
/*
390+
* TODO: as of March 2018, bitbucket sporadically fails with
391+
* 403s instead of replying with a 401 - but only sometimes.
392+
*/
393+
cl_skip();
366394

367-
/* Wrong password in URL, fall back to user_pass */
368-
user_pass.password = "libgit2";
395+
/*
396+
* Incorrect user and pass are in the URL; the (correct) creds in
397+
* the `git_cred_userpass_payload` should be used as a fallback.
398+
*/
369399
cl_git_pass(git_clone(&g_repo, BB_REPO_URL_WITH_WRONG_PASS, "./foo", &g_options));
370400
git_repository_free(g_repo); g_repo = NULL;
371401
cl_fixture_cleanup("./foo");

0 commit comments

Comments
 (0)