diff options
author | Patrick Steinhardt <ps@pks.im> | 2020-03-31 15:42:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-31 15:42:14 +0200 |
commit | 7a2b969d559b83798d93728f24d1729ffc97b717 (patch) | |
tree | c4c6c9c0710c47a1da978d625ff2cf066eeff4c4 /tests | |
parent | 1e5b139509073e9209c34466de10d51baa821df5 (diff) | |
parent | bb52d9fa598ce74f82c4294e0aa98b4bdbfdbc7e (diff) | |
download | libgit2-maint/v0.28.tar.gz |
Merge pull request #5473 from libgit2/ethomson/v0.28.5v0.28.5maint/v0.28
fetchhead: strip credentials from remote URL
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fetchhead/nonetwork.c | 20 | ||||
-rw-r--r-- | tests/online/fetchhead.c | 17 |
2 files changed, 36 insertions, 1 deletions
diff --git a/tests/fetchhead/nonetwork.c b/tests/fetchhead/nonetwork.c index 658943273..ccfb4f773 100644 --- a/tests/fetchhead/nonetwork.c +++ b/tests/fetchhead/nonetwork.c @@ -108,7 +108,7 @@ void test_fetchhead_nonetwork__write(void) typedef struct { git_vector *fetchhead_vector; size_t idx; -} fetchhead_ref_cb_data; +} fetchhead_ref_cb_data; static int fetchhead_ref_cb(const char *name, const char *url, const git_oid *oid, unsigned int is_merge, void *payload) @@ -493,3 +493,21 @@ void test_fetchhead_nonetwork__create_with_multiple_refspecs(void) git_remote_free(remote); git_buf_dispose(&path); } + +void test_fetchhead_nonetwork__credentials_are_stripped(void) +{ + git_fetchhead_ref *ref; + git_oid oid; + + cl_git_pass(git_oid_fromstr(&oid, "49322bb17d3acc9146f98c97d078513228bbf3c0")); + cl_git_pass(git_fetchhead_ref_create(&ref, &oid, 0, + "refs/tags/commit_tree", "http://foo:bar@github.com/libgit2/TestGitRepository")); + cl_assert_equal_s(ref->remote_url, "http://github.com/libgit2/TestGitRepository"); + git_fetchhead_ref_free(ref); + + cl_git_pass(git_oid_fromstr(&oid, "49322bb17d3acc9146f98c97d078513228bbf3c0")); + cl_git_pass(git_fetchhead_ref_create(&ref, &oid, 0, + "refs/tags/commit_tree", "https://foo:bar@github.com/libgit2/TestGitRepository")); + cl_assert_equal_s(ref->remote_url, "https://github.com/libgit2/TestGitRepository"); + git_fetchhead_ref_free(ref); +} diff --git a/tests/online/fetchhead.c b/tests/online/fetchhead.c index ae72dde57..5e3586654 100644 --- a/tests/online/fetchhead.c +++ b/tests/online/fetchhead.c @@ -154,3 +154,20 @@ void test_online_fetchhead__colon_only_dst_refspec_creates_no_branch(void) cl_assert_equal_i(refs, count_references()); } + +void test_online_fetchhead__creds_get_stripped(void) +{ + git_buf buf = GIT_BUF_INIT; + git_remote *remote; + + cl_git_pass(git_repository_init(&g_repo, "./foo", 0)); + cl_git_pass(git_remote_create_anonymous(&remote, g_repo, "https://libgit3:libgit3@bitbucket.org/libgit2/testgitrepository.git")); + cl_git_pass(git_remote_fetch(remote, NULL, NULL, NULL)); + + cl_git_pass(git_futils_readbuffer(&buf, "./foo/.git/FETCH_HEAD")); + cl_assert_equal_s(buf.ptr, + "49322bb17d3acc9146f98c97d078513228bbf3c0\t\thttps://bitbucket.org/libgit2/testgitrepository.git\n"); + + git_remote_free(remote); + git_buf_dispose(&buf); +} |