Skip to content

Commit

Permalink
locking: use a download token when searching locks
Browse files Browse the repository at this point in the history
The locking API documentation specifies that a user need only have pull
access to the repository when searching locks. However, we requested an
upload token, which requires push access. Instead, ask for a download
token, which requires only pull access, as documented.
  • Loading branch information
bk2204 committed Jul 17, 2019
1 parent 26db98b commit 3fa6e14
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion locking/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ type lockList struct {
}

func (c *lockClient) Search(remote string, searchReq *lockSearchRequest) (*lockList, *http.Response, error) {
e := c.Endpoints.Endpoint("upload", remote)
e := c.Endpoints.Endpoint("download", remote)
req, err := c.NewRequest("GET", e, "locks", nil)
if err != nil {
return nil, nil, err
Expand Down
27 changes: 27 additions & 0 deletions t/t-locks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,33 @@ begin_test "list a single lock"
)
end_test

begin_test "list a single lock (SSH)"
(
set -e

reponame="locks-list-ssh"
setup_remote_repo_with_file "$reponame" "f.dat"
clone_repo "$reponame" "$reponame"

sshurl="${GITSERVER/http:\/\//ssh://git@}/$reponame"
echo $sshurl
git config lfs.url "$sshurl"

git lfs lock --json "f.dat" | tee lock.log

id=$(assert_lock lock.log f.dat)
assert_server_lock "$reponame" "$id" "refs/heads/master"

GIT_TRACE=1 git lfs locks --path "f.dat" 2>trace.log | tee locks.log
cat trace.log
[ $(wc -l < locks.log) -eq 1 ]
grep "f.dat" locks.log
grep "Git LFS Tests" locks.log
grep "lfs-ssh-echo.*git-lfs-authenticate $reponame download" trace.log
)
end_test


begin_test "list a single lock (--json)"
(
set -e
Expand Down

0 comments on commit 3fa6e14

Please sign in to comment.