mirror of
https://github.com/git/git.git
synced 2026-01-11 21:33:13 +09:00
Merge branch 'ag/http-netrc-tests' into jch
Additional tests were introduced to see the interaction with netrc auth with auth failure on the http transport. Comments? * ag/http-netrc-tests: t5550: add netrc tests for http 401/403
This commit is contained in:
commit
182979e152
@ -319,13 +319,22 @@ setup_askpass_helper() {
|
||||
'
|
||||
}
|
||||
|
||||
set_askpass() {
|
||||
set_askpass () {
|
||||
>"$TRASH_DIRECTORY/askpass-query" &&
|
||||
echo "$1" >"$TRASH_DIRECTORY/askpass-user" &&
|
||||
echo "$2" >"$TRASH_DIRECTORY/askpass-pass"
|
||||
}
|
||||
|
||||
expect_askpass() {
|
||||
set_netrc () {
|
||||
# $HOME=$TRASH_DIRECTORY
|
||||
echo "machine $1 login $2 password $3" >"$TRASH_DIRECTORY/.netrc"
|
||||
}
|
||||
|
||||
clear_netrc () {
|
||||
rm -f "$TRASH_DIRECTORY/.netrc"
|
||||
}
|
||||
|
||||
expect_askpass () {
|
||||
dest=$HTTPD_DEST${3+/$3}
|
||||
|
||||
{
|
||||
|
||||
@ -238,6 +238,10 @@ SSLEngine On
|
||||
AuthName "git-auth"
|
||||
AuthUserFile passwd
|
||||
Require valid-user
|
||||
|
||||
# return 403 for authenticated user: forbidden-user@host
|
||||
RewriteCond "%{REMOTE_USER}" "^forbidden-user@host"
|
||||
RewriteRule ^ - [F]
|
||||
</Location>
|
||||
|
||||
<LocationMatch "^/auth-push/.*/git-receive-pack$">
|
||||
|
||||
@ -1 +1,2 @@
|
||||
user@host:$apr1$LGPmCZWj$9vxEwj5Z5GzQLBMxp3mCx1
|
||||
forbidden-user@host:$apr1$LGPmCZWj$9vxEwj5Z5GzQLBMxp3mCx1
|
||||
|
||||
@ -102,6 +102,31 @@ test_expect_success 'cloning password-protected repository can fail' '
|
||||
expect_askpass both wrong
|
||||
'
|
||||
|
||||
test_expect_success 'using credentials from netrc to clone successfully' '
|
||||
test_when_finished clear_netrc &&
|
||||
set_askpass wrong &&
|
||||
set_netrc 127.0.0.1 user@host pass@host &&
|
||||
git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-netrc &&
|
||||
expect_askpass none
|
||||
'
|
||||
|
||||
test_expect_success 'netrc unauthorized credentials (prompt after 401)' '
|
||||
test_when_finished clear_netrc &&
|
||||
set_askpass wrong &&
|
||||
set_netrc 127.0.0.1 user@host pass@wrong &&
|
||||
test_must_fail git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-netrc-401 &&
|
||||
expect_askpass both wrong
|
||||
'
|
||||
|
||||
test_expect_success 'netrc authorized but forbidden credentials (fail on 403)' '
|
||||
test_when_finished clear_netrc &&
|
||||
set_askpass wrong &&
|
||||
set_netrc 127.0.0.1 forbidden-user@host pass@host &&
|
||||
test_must_fail git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-netrc-403 2>err &&
|
||||
expect_askpass none &&
|
||||
grep "The requested URL returned error: 403" err
|
||||
'
|
||||
|
||||
test_expect_success 'http auth can use user/pass in URL' '
|
||||
set_askpass wrong &&
|
||||
git clone "$HTTPD_URL_USER_PASS/auth/dumb/repo.git" clone-auth-none &&
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user