mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-25 11:22:16 +00:00
Allow get release download files and lfs files with oauth2 token format (#26430)
Fix #26165 Fix #25257
This commit is contained in:
parent
6b65c41ebf
commit
6e87a44034
8 changed files with 66 additions and 6 deletions
|
@ -0,0 +1 @@
|
|||
1032bbf17fbc0d9c95bb5418dabe8f8c99278700
|
|
@ -239,3 +239,20 @@ func TestViewTagsList(t *testing.T) {
|
|||
|
||||
assert.EqualValues(t, []string{"v1.0", "delete-tag", "v1.1"}, tagNames)
|
||||
}
|
||||
|
||||
func TestDownloadReleaseAttachment(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
tests.PrepareAttachmentsStorage(t)
|
||||
|
||||
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2})
|
||||
|
||||
url := repo.Link() + "/releases/download/v1.1/README.md"
|
||||
|
||||
req := NewRequest(t, "GET", url)
|
||||
MakeRequest(t, req, http.StatusNotFound)
|
||||
|
||||
req = NewRequest(t, "GET", url)
|
||||
session := loginUser(t, "user2")
|
||||
session.MakeRequest(t, req, http.StatusOK)
|
||||
}
|
||||
|
|
|
@ -179,6 +179,20 @@ func InitTest(requireGitea bool) {
|
|||
routers.InitWebInstalled(graceful.GetManager().HammerContext())
|
||||
}
|
||||
|
||||
func PrepareAttachmentsStorage(t testing.TB) {
|
||||
// prepare attachments directory and files
|
||||
assert.NoError(t, storage.Clean(storage.Attachments))
|
||||
|
||||
s, err := storage.NewStorage(setting.LocalStorageType, &setting.Storage{
|
||||
Path: filepath.Join(filepath.Dir(setting.AppPath), "tests", "testdata", "data", "attachments"),
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.NoError(t, s.IterateObjects("", func(p string, obj storage.Object) error {
|
||||
_, err = storage.Copy(storage.Attachments, p, s, p)
|
||||
return err
|
||||
}))
|
||||
}
|
||||
|
||||
func PrepareTestEnv(t testing.TB, skip ...int) func() {
|
||||
t.Helper()
|
||||
ourSkip := 1
|
||||
|
|
1
tests/testdata/data/attachments/a/0/a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a22
vendored
Normal file
1
tests/testdata/data/attachments/a/0/a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a22
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
# This is a release README
|
Loading…
Add table
Add a link
Reference in a new issue