Add tests showing that credentials in lfs.url or remote url are used
This commit is contained in:
parent
3671987c9b
commit
5d076c57b1
@ -277,6 +277,15 @@ func lfsBatchHandler(w http.ResponseWriter, r *http.Request, repo string) {
|
||||
}
|
||||
}
|
||||
|
||||
if repo == "requirecreds" {
|
||||
user, pass, err := extractAuth(r.Header.Get("Authorization"))
|
||||
if err != nil || (user != "requirecreds" || pass != "pass") {
|
||||
w.Write([]byte("SUP"))
|
||||
w.WriteHeader(403)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
type batchReq struct {
|
||||
Operation string `json:"operation"`
|
||||
Objects []lfsObject `json:"objects"`
|
||||
@ -605,7 +614,7 @@ func skipIfBadAuth(w http.ResponseWriter, r *http.Request) bool {
|
||||
if pass == "pass" {
|
||||
return false
|
||||
}
|
||||
case "netrcuser":
|
||||
case "netrcuser", "requirecreds":
|
||||
return false
|
||||
case "path":
|
||||
if strings.HasPrefix(r.URL.Path, "/"+pass) {
|
||||
|
@ -209,3 +209,48 @@ begin_test "credentials from netrc with bad password"
|
||||
[ "0" = "$(grep -c "(1 of 1 files)" push.log)" ]
|
||||
)
|
||||
end_test
|
||||
|
||||
begin_test "credentials from lfs.url"
|
||||
(
|
||||
set -e
|
||||
|
||||
reponame="requirecreds"
|
||||
setup_remote_repo "$reponame"
|
||||
|
||||
clone_repo "$reponame" requirecreds-lfsurl
|
||||
gitserverhost=$(echo "$GITSERVER" | cut -d'/' -f3)
|
||||
git config lfs.url http://requirecreds:pass@$gitserverhost/$reponame.git/info/lfs
|
||||
git lfs env
|
||||
|
||||
git lfs track "*.dat"
|
||||
echo "push a" > a.dat
|
||||
git add .gitattributes a.dat
|
||||
git commit -m "add a.dat"
|
||||
|
||||
git lfs push origin master 2>&1 | tee push.log
|
||||
grep "(1 of 1 files)" push.log
|
||||
)
|
||||
end_test
|
||||
|
||||
begin_test "credentials from remote.origin.url"
|
||||
(
|
||||
set -e
|
||||
|
||||
reponame="requirecreds"
|
||||
setup_remote_repo "$reponame"
|
||||
|
||||
clone_repo "$reponame" requirecreds-remoteurl
|
||||
gitserverhost=$(echo "$GITSERVER" | cut -d'/' -f3)
|
||||
git config remote.origin.url http://requirecreds:pass@$gitserverhost/$reponame.git
|
||||
git lfs env
|
||||
|
||||
git lfs track "*.dat"
|
||||
echo "push b" > b.dat
|
||||
git add .gitattributes b.dat
|
||||
git commit -m "add b.dat"
|
||||
|
||||
git lfs push origin master 2>&1 | tee push.log
|
||||
grep "(1 of 1 files)" push.log
|
||||
exit 1
|
||||
)
|
||||
end_test
|
||||
|
Loading…
Reference in New Issue
Block a user