From a1d0ba795a03a1b39ddb8de23591763779b8d3f9 Mon Sep 17 00:00:00 2001 From: risk danger olson Date: Fri, 8 Apr 2016 14:16:48 -0600 Subject: [PATCH] update credential tests with good and bad tests for pushes and fetches --- test/cmd/lfstest-gitserver.go | 6 ++-- test/test-credentials.sh | 55 +++++++++++++++++++++++++++++------ 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/test/cmd/lfstest-gitserver.go b/test/cmd/lfstest-gitserver.go index b002817f..4b99de2b 100644 --- a/test/cmd/lfstest-gitserver.go +++ b/test/cmd/lfstest-gitserver.go @@ -278,9 +278,11 @@ func lfsBatchHandler(w http.ResponseWriter, r *http.Request, repo string) { } if repo == "requirecreds" { - user, pass, err := extractAuth(r.Header.Get("Authorization")) + auth := r.Header.Get("Authorization") + user, pass, err := extractAuth(auth) if err != nil || (user != "requirecreds" || pass != "pass") { - w.Write([]byte("SUP")) + errmsg := fmt.Sprintf("Got: '%s' => '%s' : '%s'", auth, user, pass) + w.Write([]byte(`{"message":"` + errmsg + `"}`)) w.WriteHeader(403) return } diff --git a/test/test-credentials.sh b/test/test-credentials.sh index 24a20bb3..d8af74e2 100755 --- a/test/test-credentials.sh +++ b/test/test-credentials.sh @@ -216,19 +216,38 @@ begin_test "credentials from lfs.url" 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" + echo "bad push" + git lfs env + git lfs push origin master 2>&1 | tee push.log + grep "(0 of 1 files)" push.log + + echo "good push" + gitserverhost=$(echo "$GITSERVER" | cut -d'/' -f3) + git config lfs.url http://requirecreds:pass@$gitserverhost/$reponame.git/info/lfs + git lfs env git lfs push origin master 2>&1 | tee push.log grep "(1 of 1 files)" push.log + + echo "bad fetch" + rm -rf .git/lfs/objects + git config lfs.url http://$gitserverhost/$reponame.git/info/lfs + git lfs env + git lfs fetch --all 2>&1 | tee fetch.log + grep "(0 of 1 files)" fetch.log + + echo "good fetch" + rm -rf .git/lfs/objects + git config lfs.url http://requirecreds:pass@$gitserverhost/$reponame.git/info/lfs + git lfs env + git lfs fetch --all 2>&1 | tee fetch.log + grep "(1 of 1 files)" fetch.log ) end_test @@ -238,19 +257,37 @@ begin_test "credentials from remote.origin.url" 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" + echo "bad push" + git lfs env + git lfs push origin master 2>&1 | tee push.log + grep "(0 of 1 files)" push.log + + echo "good push" + gitserverhost=$(echo "$GITSERVER" | cut -d'/' -f3) + git config remote.origin.url http://requirecreds:pass@$gitserverhost/$reponame.git + git lfs env git lfs push origin master 2>&1 | tee push.log grep "(1 of 1 files)" push.log - exit 1 + + echo "bad fetch" + rm -rf .git/lfs/objects + git config remote.origin.url http://$gitserverhost/$reponame.git + git lfs env + git lfs fetch --all 2>&1 | tee fetch.log + grep "(0 of 1 files)" fetch.log + + echo "good fetch" + rm -rf .git/lfs/objects + git config remote.origin.url http://requirecreds:pass@$gitserverhost/$reponame.git + git lfs env + git lfs fetch --all 2>&1 | tee fetch.log + grep "(1 of 1 files)" fetch.log ) end_test