mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-10-27 20:41:01 +00:00
[GITEA] test POST /{username}/{reponame}/{type:issues|pulls}/move_pin
Refs: https://forgejo.org/2023-11-release-v1-20-5-1/#api-and-web-endpoint-vulnerable-to-manually-crafted-identifiers (cherry picked from commit 52f50792606a22cbf1e144e1bd480984abf6f53f) (cherry picked from commit65b942fa1e) (cherry picked from commite140c5c983) (cherry picked from commit4d108fa1cf) (cherry picked from commit9430badc5c) (cherry picked from commit1e67f4665d) (cherry picked from commit992e0d3218) (cherry picked from commit0e25ca17f3) (cherry picked from commit3c7d9769fa) Conflicts: tests/integration/issue_test.go https://codeberg.org/forgejo/forgejo/pulls/2119 (cherry picked from commitf6bdf76a1d) (cherry picked from commita5e527f872) (cherry picked from commitbe3f9a28a1) (cherry picked from commit836a95eab8)
This commit is contained in:
parent
efbe483057
commit
3f71a0ef02
1 changed files with 42 additions and 0 deletions
|
|
@ -579,6 +579,48 @@ func TestGetIssueInfo(t *testing.T) {
|
||||||
assert.EqualValues(t, issue.ID, apiIssue.ID)
|
assert.EqualValues(t, issue.ID, apiIssue.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIssuePinMove(t *testing.T) {
|
||||||
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
session := loginUser(t, "user2")
|
||||||
|
issueURL, issue := testIssueWithBean(t, "user2", 1, "Title", "Content")
|
||||||
|
assert.EqualValues(t, 0, issue.PinOrder)
|
||||||
|
|
||||||
|
req := NewRequestWithValues(t, "POST", fmt.Sprintf("%s/pin", issueURL), map[string]string{
|
||||||
|
"_csrf": GetCSRF(t, session, issueURL),
|
||||||
|
})
|
||||||
|
session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
issue = unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: issue.ID})
|
||||||
|
|
||||||
|
position := 1
|
||||||
|
assert.EqualValues(t, position, issue.PinOrder)
|
||||||
|
|
||||||
|
newPosition := 2
|
||||||
|
|
||||||
|
// Using the ID of an issue that does not belong to the repository must fail
|
||||||
|
{
|
||||||
|
session5 := loginUser(t, "user5")
|
||||||
|
movePinURL := "/user5/repo4/issues/move_pin?_csrf=" + GetCSRF(t, session5, issueURL)
|
||||||
|
req = NewRequestWithJSON(t, "POST", movePinURL, map[string]any{
|
||||||
|
"id": issue.ID,
|
||||||
|
"position": newPosition,
|
||||||
|
})
|
||||||
|
session5.MakeRequest(t, req, http.StatusNotFound)
|
||||||
|
|
||||||
|
issue = unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: issue.ID})
|
||||||
|
assert.EqualValues(t, position, issue.PinOrder)
|
||||||
|
}
|
||||||
|
|
||||||
|
movePinURL := issueURL[:strings.LastIndexByte(issueURL, '/')] + "/move_pin?_csrf=" + GetCSRF(t, session, issueURL)
|
||||||
|
req = NewRequestWithJSON(t, "POST", movePinURL, map[string]any{
|
||||||
|
"id": issue.ID,
|
||||||
|
"position": newPosition,
|
||||||
|
})
|
||||||
|
session.MakeRequest(t, req, http.StatusNoContent)
|
||||||
|
|
||||||
|
issue = unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: issue.ID})
|
||||||
|
assert.EqualValues(t, newPosition, issue.PinOrder)
|
||||||
|
}
|
||||||
|
|
||||||
func TestUpdateIssueDeadline(t *testing.T) {
|
func TestUpdateIssueDeadline(t *testing.T) {
|
||||||
defer tests.PrepareTestEnv(t)()
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue