Merge pull request #1825 from git-lfs/test/ssh-auth

Add test for ssh auth
This commit is contained in:
risk danger olson 2017-01-05 08:48:30 -07:00 committed by GitHub
commit a98842214a
5 changed files with 62 additions and 2 deletions

@ -109,7 +109,7 @@ func Environ(cfg *config.Configuration, manifest *tq.Manifest) []string {
}
for _, e := range osEnviron {
if !strings.Contains(e, "GIT_") {
if !strings.Contains(strings.SplitN(e, "=", 2)[0], "GIT_") {
continue
}
env = append(env, e)

34
test/cmd/ssh-echo.go Normal file

@ -0,0 +1,34 @@
// +build testtools
package main
import (
"encoding/json"
"fmt"
"os"
"strings"
)
type sshResponse struct {
Href string `json:"href"`
Header map[string]string `json:"header"`
}
func main() {
// expect args:
// ssh-echo -p PORT git@127.0.0.1 git-lfs-authenticate REPO OPERATION
if len(os.Args) != 5 {
fmt.Fprintf(os.Stderr, "got %d args: %v", len(os.Args), os.Args)
os.Exit(1)
}
// just "git-lfs-authenticate REPO OPERATION"
authLine := strings.Split(os.Args[4], " ")
if len(authLine) < 13 {
fmt.Fprintf(os.Stderr, "bad git-lfs-authenticate line: %s\nargs: %v", authLine, os.Args)
}
json.NewEncoder(os.Stdout).Encode(sshResponse{
Href: fmt.Sprintf("http://127.0.0.1:%s/%s.git/info/lfs", os.Args[2], authLine[1]),
})
}

@ -101,3 +101,24 @@ begin_test "batch transfers occur in reverse order by size"
)
end_test
begin_test "batch transfers with ssh endpoint"
(
set -e
reponame="batch-ssh"
setup_remote_repo "$reponame"
clone_repo "$reponame" "$reponame"
sshurl="${GITSERVER/http:\/\//ssh://git@}/$reponame"
git config lfs.url "$sshurl"
git lfs env
oid="$(calc_oid "test")"
git lfs track "*.dat"
printf "test" > test.dat
git add .gitattributes test.dat
git commit -m "initial commit"
git push origin master 2>&1
)
end_test

@ -686,7 +686,8 @@ begin_test "env with multiple ssh remotes"
expected='Endpoint=https://git-server.com/user/repo.git/info/lfs (auth=none)
SSH=git@git-server.com:user/repo.git
Endpoint (other)=https://other-git-server.com/user/repo.git/info/lfs (auth=none)
SSH=git@other-git-server.com:user/repo.git'
SSH=git@other-git-server.com:user/repo.git
GIT_SSH=ssh-echo'
contains_same_elements "$expected" "$(git lfs env | grep -e "Endpoint" -e "SSH=")"
)

@ -110,9 +110,13 @@ TESTHOME="$REMOTEDIR/home"
GIT_CONFIG_NOSYSTEM=1
GIT_TERMINAL_PROMPT=0
GIT_SSH=ssh-echo
APPVEYOR_REPO_COMMIT_MESSAGE="test: env test should look for GIT_SSH too"
export CREDSDIR
export GIT_CONFIG_NOSYSTEM
export GIT_SSH
export APPVEYOR_REPO_COMMIT_MESSAGE
mkdir -p "$TMPDIR"
mkdir -p "$TRASHDIR"