Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 66a530e

Browse files
committed
Merge pull request libgit2#3648 from libgit2/cmn/auth-retry
test: make sure we retry the auth callback on all platforms
2 parents 778fb69 + ba9bb66 commit 66a530e

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,10 @@ IF (BUILD_CLAR)
682682
ELSE ()
683683
ADD_TEST(libgit2_clar libgit2_clar -v)
684684
ENDIF ()
685+
686+
# Add a test target which runs the cred callback tests, to be
687+
# called after setting the url and user
688+
ADD_TEST(libgit2_clar-cred_callback libgit2_clar -v -sonline::clone::cred_callback)
685689
ENDIF ()
686690

687691
IF (TAGS)

appveyor.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,8 @@ build_script:
3636
- cmd: |
3737
if "%GENERATOR%"=="MSYS Makefiles" (C:\MinGW\msys\1.0\bin\sh --login /c/projects/libgit2/script/appveyor-mingw.sh)
3838
test_script:
39-
- ps: ctest -V .
39+
- ps: |
40+
ctest -V -R libgit2_clar
41+
$env:GITTEST_REMOTE_URL="https://github.com/libgit2/non-existent"
42+
$env:GITTEST_REMOTE_USER="libgit2test"
43+
ctest -V -R libgit2_clar-cred_callback

script/cibuild.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ git daemon --listen=localhost --export-all --enable=receive-pack --base-path="$H
2525
export GITTEST_REMOTE_URL="git://localhost/test.git"
2626

2727
# Run the test suite
28-
ctest -V . || exit $?
28+
ctest -V -R libgit2_clar || exit $?
2929

3030
# Now that we've tested the raw git protocol, let's set up ssh to we
3131
# can do the push tests over it
@@ -56,3 +56,7 @@ if [ -e ./libgit2_clar ]; then
5656
./libgit2_clar -sonline::clone::cred_callback || exit $?
5757
fi
5858
fi
59+
60+
export GITTEST_REMOTE_URL="https://github.com/libgit2/non-existent"
61+
export GITTEST_REMOTE_USER="libgit2test"
62+
ctest -V -R libgit2_clar-cred_callback

src/transports/winhttp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -926,10 +926,11 @@ static int winhttp_stream_read(
926926
if (parse_unauthorized_response(s->request, &allowed_types, &t->auth_mechanism) < 0)
927927
return -1;
928928

929-
if (allowed_types &&
930-
(!t->cred || 0 == (t->cred->credtype & allowed_types))) {
929+
if (allowed_types) {
931930
int cred_error = 1;
932931

932+
git_cred_free(t->cred);
933+
t->cred = NULL;
933934
/* Start with the user-supplied credential callback, if present */
934935
if (t->owner->cred_acquire_cb) {
935936
cred_error = t->owner->cred_acquire_cb(&t->cred, t->owner->url,

0 commit comments

Comments
 (0)