Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite of the LFS server #15523

Merged
merged 37 commits into from
Jun 5, 2021
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4281413
Use constants.
KN4CK3R Apr 13, 2021
9b8936a
Use IsValid instead of isOidValid
KN4CK3R Apr 13, 2021
6a8a4a9
Restructured code. Moved static checks out of loop.
KN4CK3R Apr 13, 2021
5f68237
Made method private.
KN4CK3R Apr 14, 2021
7d0e8d8
Restructured batch api. Add support for individual errors.
KN4CK3R Apr 14, 2021
c51ac32
Let router decide if LFS is enabled.
KN4CK3R Apr 15, 2021
406127b
Renamed methods.
KN4CK3R Apr 15, 2021
e5bcd0d
Return correct status from verify handler.
KN4CK3R Apr 15, 2021
2b9daab
Unified media type check in router.
KN4CK3R Apr 15, 2021
dad7521
Changed error code according to spec.
KN4CK3R Apr 15, 2021
f3fe4de
Moved checks into router.
KN4CK3R Apr 15, 2021
89607a2
Removed invalid v1 api methods.
KN4CK3R Apr 15, 2021
afd6eba
Unified methods.
KN4CK3R Apr 16, 2021
aff8fc8
Display better error messages.
KN4CK3R Apr 16, 2021
24279e1
Added size parameter. Create meta object on upload.
KN4CK3R Apr 16, 2021
c45f43c
Use object error on invalid size.
KN4CK3R Apr 16, 2021
709fcfa
Skip upload if object exists.
KN4CK3R Apr 16, 2021
d11bd55
Moved methods.
KN4CK3R Apr 16, 2021
497283f
Suppress fields in response.
KN4CK3R Apr 16, 2021
e0db2b2
Changed error on accept.
KN4CK3R Apr 16, 2021
5a932da
Fixed tests.
KN4CK3R Apr 16, 2021
2b0a713
Added tests.
KN4CK3R Apr 16, 2021
25c3a01
Merge branch 'master' of https://github.com/go-gitea/gitea into fix-l…
KN4CK3R Apr 16, 2021
9bc1cf6
Use ErrorResponse object.
KN4CK3R Apr 18, 2021
f80fe0f
Merge branch 'master' of https://github.com/go-gitea/gitea into fix-l…
KN4CK3R Apr 18, 2021
3093f76
Test against message property.
KN4CK3R Apr 18, 2021
1c3ac29
Add support for the old invalid lfs client.
KN4CK3R Apr 27, 2021
1bcbff8
Fixed the check because MinIO wraps the error.
KN4CK3R Apr 27, 2021
9eaa2e4
Use individual repositories.
KN4CK3R Apr 27, 2021
a3d323b
Removed unnecessary postgresql workaround.
KN4CK3R Apr 27, 2021
bec50ee
Merge branch 'main' of https://github.com/go-gitea/gitea into fix-lfs…
KN4CK3R May 18, 2021
5472d54
Merge branch 'main' into fix-lfs-server
6543 May 19, 2021
1443a2c
Merge branch 'main' into fix-lfs-server
6543 Jun 5, 2021
b0e6b8e
Use StatusNotFound instead of StatusForbidden.
KN4CK3R Jun 5, 2021
9f29ed5
Fixed status codes in tests.
KN4CK3R Jun 5, 2021
f411fe8
Merge branch 'main' into fix-lfs-server
lafriks Jun 5, 2021
0ccad52
Merge branch 'main' into fix-lfs-server
6543 Jun 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions integrations/api_repo_lfs_locks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/lfs"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"

Expand All @@ -24,13 +25,13 @@ func TestAPILFSLocksNotStarted(t *testing.T) {
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)

req := NewRequestf(t, "GET", "/%s/%s.git/info/lfs/locks", user.Name, repo.Name)
MakeRequest(t, req, http.StatusNotFound)
KN4CK3R marked this conversation as resolved.
Show resolved Hide resolved
MakeRequest(t, req, http.StatusForbidden)
req = NewRequestf(t, "POST", "/%s/%s.git/info/lfs/locks", user.Name, repo.Name)
MakeRequest(t, req, http.StatusNotFound)
MakeRequest(t, req, http.StatusForbidden)
req = NewRequestf(t, "GET", "/%s/%s.git/info/lfs/locks/verify", user.Name, repo.Name)
MakeRequest(t, req, http.StatusNotFound)
MakeRequest(t, req, http.StatusForbidden)
req = NewRequestf(t, "GET", "/%s/%s.git/info/lfs/locks/10/unlock", user.Name, repo.Name)
MakeRequest(t, req, http.StatusNotFound)
MakeRequest(t, req, http.StatusForbidden)
}

func TestAPILFSLocksNotLogin(t *testing.T) {
Expand All @@ -40,7 +41,7 @@ func TestAPILFSLocksNotLogin(t *testing.T) {
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)

req := NewRequestf(t, "GET", "/%s/%s.git/info/lfs/locks", user.Name, repo.Name)
req.Header.Set("Accept", "application/vnd.git-lfs+json")
req.Header.Set("Accept", lfs.MediaType)
resp := MakeRequest(t, req, http.StatusUnauthorized)
var lfsLockError api.LFSLockError
DecodeJSON(t, resp, &lfsLockError)
Expand Down Expand Up @@ -102,8 +103,8 @@ func TestAPILFSLocksLogged(t *testing.T) {
for _, test := range tests {
session := loginUser(t, test.user.Name)
req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/%s.git/info/lfs/locks", test.repo.FullName()), map[string]string{"path": test.path})
req.Header.Set("Accept", "application/vnd.git-lfs+json")
req.Header.Set("Content-Type", "application/vnd.git-lfs+json")
req.Header.Set("Accept", lfs.MediaType)
req.Header.Set("Content-Type", lfs.MediaType)
resp := session.MakeRequest(t, req, test.httpResult)
if len(test.addTime) > 0 {
var lfsLock api.LFSLockResponse
Expand All @@ -119,7 +120,7 @@ func TestAPILFSLocksLogged(t *testing.T) {
for _, test := range resultsTests {
session := loginUser(t, test.user.Name)
req := NewRequestf(t, "GET", "/%s.git/info/lfs/locks", test.repo.FullName())
req.Header.Set("Accept", "application/vnd.git-lfs+json")
req.Header.Set("Accept", lfs.MediaType)
resp := session.MakeRequest(t, req, http.StatusOK)
var lfsLocks api.LFSLockList
DecodeJSON(t, resp, &lfsLocks)
Expand All @@ -131,8 +132,8 @@ func TestAPILFSLocksLogged(t *testing.T) {
}

req = NewRequestWithJSON(t, "POST", fmt.Sprintf("/%s.git/info/lfs/locks/verify", test.repo.FullName()), map[string]string{})
req.Header.Set("Accept", "application/vnd.git-lfs+json")
req.Header.Set("Content-Type", "application/vnd.git-lfs+json")
req.Header.Set("Accept", lfs.MediaType)
req.Header.Set("Content-Type", lfs.MediaType)
resp = session.MakeRequest(t, req, http.StatusOK)
var lfsLocksVerify api.LFSLockListVerify
DecodeJSON(t, resp, &lfsLocksVerify)
Expand All @@ -155,8 +156,8 @@ func TestAPILFSLocksLogged(t *testing.T) {
for _, test := range deleteTests {
session := loginUser(t, test.user.Name)
req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/%s.git/info/lfs/locks/%s/unlock", test.repo.FullName(), test.lockID), map[string]string{})
req.Header.Set("Accept", "application/vnd.git-lfs+json")
req.Header.Set("Content-Type", "application/vnd.git-lfs+json")
req.Header.Set("Accept", lfs.MediaType)
req.Header.Set("Content-Type", lfs.MediaType)
resp := session.MakeRequest(t, req, http.StatusOK)
var lfsLockRep api.LFSLockResponse
DecodeJSON(t, resp, &lfsLockRep)
Expand All @@ -168,7 +169,7 @@ func TestAPILFSLocksLogged(t *testing.T) {
for _, test := range resultsTests {
session := loginUser(t, test.user.Name)
req := NewRequestf(t, "GET", "/%s.git/info/lfs/locks", test.repo.FullName())
req.Header.Set("Accept", "application/vnd.git-lfs+json")
req.Header.Set("Accept", lfs.MediaType)
resp := session.MakeRequest(t, req, http.StatusOK)
var lfsLocks api.LFSLockList
DecodeJSON(t, resp, &lfsLocks)
Expand Down
Loading