Skip to content

Commit d377e25

Browse files
committed
Add release attachment test and fix test typo
1 parent 35b44c2 commit d377e25

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

tests/integration/api_issue_attachment_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func TestAPIEditIssueAttachmentWithUnallowedFile(t *testing.T) {
152152

153153
attachment := unittest.AssertExistsAndLoadBean(t, &repo_model.Attachment{ID: 1})
154154
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: attachment.RepoID})
155-
issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{RepoID: attachment.IssueID})
155+
issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: attachment.IssueID})
156156
repoOwner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
157157

158158
session := loginUser(t, repoOwner.Name)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright 2024 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package integration
5+
6+
import (
7+
"fmt"
8+
"net/http"
9+
"testing"
10+
11+
auth_model "code.gitea.io/gitea/models/auth"
12+
repo_model "code.gitea.io/gitea/models/repo"
13+
"code.gitea.io/gitea/models/unittest"
14+
user_model "code.gitea.io/gitea/models/user"
15+
"code.gitea.io/gitea/tests"
16+
)
17+
18+
func TestAPIEditReleaseAttachmentWithUnallowedFile(t *testing.T) {
19+
defer tests.PrepareTestEnv(t)()
20+
21+
attachment := unittest.AssertExistsAndLoadBean(t, &repo_model.Attachment{ID: 11})
22+
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: attachment.RepoID})
23+
release := unittest.AssertExistsAndLoadBean(t, &repo_model.Release{ID: attachment.ReleaseID})
24+
repoOwner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
25+
26+
session := loginUser(t, repoOwner.Name)
27+
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteIssue)
28+
29+
filename := "file.bad"
30+
urlStr := fmt.Sprintf("/api/v1/repos/%s/%s/releases/%d/assets/%d", repoOwner.Name, repo.Name, release.ID, attachment.ID)
31+
req := NewRequestWithValues(t, "PATCH", urlStr, map[string]string{
32+
"name": filename,
33+
}).AddTokenAuth(token)
34+
35+
session.MakeRequest(t, req, http.StatusUnprocessableEntity)
36+
}

0 commit comments

Comments
 (0)