From 25205737781ec0d73e57283f43e5d4fdf355a0dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Thu, 3 Mar 2016 10:08:00 +0100 Subject: [PATCH 1/3] test: make sure we retry the auth callback on all platforms We were missing this test on Windows, which meant we didn't notice that we never fixed the single authentication attempt it tries, nor its wrong return code. Enable this for the unix platforms as well over HTTP. We previously were doing it locally but disabled it on OS X due to issues with its sshd not accepting password authentication. --- appveyor.yml | 6 +++++- script/cibuild.sh | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 166fa56b1..7186aaf63 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -36,4 +36,8 @@ build_script: - cmd: | if "%GENERATOR%"=="MSYS Makefiles" (C:\MinGW\msys\1.0\bin\sh --login /c/projects/libgit2/script/appveyor-mingw.sh) test_script: -- ps: ctest -V . +- ps: | + ctest -V . + $env:GITTEST_REMOTE_URL="https://github.com/libgit2/non-existent" + $env:GITTEST_REMOTE_USER="libgit2test" + .\Debug\libgit2_clar -sonline::clone::cred_callback diff --git a/script/cibuild.sh b/script/cibuild.sh index de5df9ea8..029dcd413 100755 --- a/script/cibuild.sh +++ b/script/cibuild.sh @@ -56,3 +56,7 @@ if [ -e ./libgit2_clar ]; then ./libgit2_clar -sonline::clone::cred_callback || exit $? fi fi + +export GITTEST_REMOTE_URL="https://github.com/libgit2/non-existent" +export GITTEST_REMOTE_USER="libgit2test" +./libgit2_clar -sonline::clone::cred_callback || exit $? From a4cba9d45384eec145537438a8e2d765c3a0bf11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Thu, 3 Mar 2016 10:48:24 +0100 Subject: [PATCH 2/3] winhttp: retry authentication If the caller has provided bad authentication, give them another apportunity to get it right until they give up. This brings WinHTTP in line with the other transports. --- src/transports/winhttp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/transports/winhttp.c b/src/transports/winhttp.c index ded041686..32b838084 100644 --- a/src/transports/winhttp.c +++ b/src/transports/winhttp.c @@ -926,10 +926,11 @@ replay: if (parse_unauthorized_response(s->request, &allowed_types, &t->auth_mechanism) < 0) return -1; - if (allowed_types && - (!t->cred || 0 == (t->cred->credtype & allowed_types))) { + if (allowed_types) { int cred_error = 1; + git_cred_free(t->cred); + t->cred = NULL; /* Start with the user-supplied credential callback, if present */ if (t->owner->cred_acquire_cb) { cred_error = t->owner->cred_acquire_cb(&t->cred, t->owner->url, From ba9bb664f3ed3f230c474ddd8937bd072cc9947f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Thu, 3 Mar 2016 19:21:07 +0100 Subject: [PATCH 3/3] tests: create a ctest target for cred_callback --- CMakeLists.txt | 4 ++++ appveyor.yml | 4 ++-- script/cibuild.sh | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 931b06459..f4e56e6cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -682,6 +682,10 @@ IF (BUILD_CLAR) ELSE () ADD_TEST(libgit2_clar libgit2_clar -v) ENDIF () + + # Add a test target which runs the cred callback tests, to be + # called after setting the url and user + ADD_TEST(libgit2_clar-cred_callback libgit2_clar -v -sonline::clone::cred_callback) ENDIF () IF (TAGS) diff --git a/appveyor.yml b/appveyor.yml index 7186aaf63..3ed3c49a1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -37,7 +37,7 @@ build_script: if "%GENERATOR%"=="MSYS Makefiles" (C:\MinGW\msys\1.0\bin\sh --login /c/projects/libgit2/script/appveyor-mingw.sh) test_script: - ps: | - ctest -V . + ctest -V -R libgit2_clar $env:GITTEST_REMOTE_URL="https://github.com/libgit2/non-existent" $env:GITTEST_REMOTE_USER="libgit2test" - .\Debug\libgit2_clar -sonline::clone::cred_callback + ctest -V -R libgit2_clar-cred_callback diff --git a/script/cibuild.sh b/script/cibuild.sh index 029dcd413..00cde0ada 100755 --- a/script/cibuild.sh +++ b/script/cibuild.sh @@ -25,7 +25,7 @@ git daemon --listen=localhost --export-all --enable=receive-pack --base-path="$H export GITTEST_REMOTE_URL="git://localhost/test.git" # Run the test suite -ctest -V . || exit $? +ctest -V -R libgit2_clar || exit $? # Now that we've tested the raw git protocol, let's set up ssh to we # can do the push tests over it @@ -59,4 +59,4 @@ fi export GITTEST_REMOTE_URL="https://github.com/libgit2/non-existent" export GITTEST_REMOTE_USER="libgit2test" -./libgit2_clar -sonline::clone::cred_callback || exit $? +ctest -V -R libgit2_clar-cred_callback