mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-20 00:19:00 +00:00
Several handlers and model helpers skipped checks that their siblings already perform. - Only match principal keys when looking up SSH certificate principals - Return no attachments for an unsaved issue instead of every issue-less one - Reject issue and comment attachments when adding release attachments - Share one permission check for editing, deleting and reacting to issue content and for comment attachments between the web UI and the API, refusing them on locked issues for users who can't write - Reject issue edits, deletion and label changes in archived repositories via the API - Apply cross-origin protection to the repository topics endpoint - Return 404 for the repositories tab of individual users and respect profile visibility for the heatmap Fixes: https://github.com/go-gitea/gitea/issues/39226 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: bircni <bircni@icloud.com>
63 lines
1.8 KiB
Go
63 lines
1.8 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package integration
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
"time"
|
|
|
|
"gitea.dev/modules/timeutil"
|
|
"gitea.dev/tests"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestHeatmapEndpoints(t *testing.T) {
|
|
defer tests.PrepareTestEnv(t)()
|
|
|
|
// Mock time so fixture actions fall within the heatmap's time window
|
|
timeutil.MockSet(time.Date(2021, 1, 1, 0, 0, 0, 0, time.UTC))
|
|
defer timeutil.MockUnset()
|
|
|
|
session := loginUser(t, "user2")
|
|
|
|
t.Run("UserProfile", func(t *testing.T) {
|
|
defer tests.PrintCurrentTest(t)()
|
|
req := NewRequest(t, "GET", "/user2/-/heatmap")
|
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
|
|
|
result := DecodeJSON(t, resp, map[string]any{})
|
|
assert.Contains(t, result, "heatmapData")
|
|
assert.Contains(t, result, "totalContributions")
|
|
assert.Positive(t, result["totalContributions"])
|
|
})
|
|
|
|
t.Run("PrivateUserProfileAnonymous", func(t *testing.T) {
|
|
defer tests.PrintCurrentTest(t)()
|
|
req := NewRequest(t, "GET", "/user31/-/heatmap")
|
|
MakeRequest(t, req, http.StatusNotFound)
|
|
})
|
|
|
|
t.Run("OrgDashboard", func(t *testing.T) {
|
|
defer tests.PrintCurrentTest(t)()
|
|
req := NewRequest(t, "GET", "/org/org3/dashboard/-/heatmap")
|
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
|
|
|
result := DecodeJSON(t, resp, map[string]any{})
|
|
assert.Contains(t, result, "heatmapData")
|
|
assert.Contains(t, result, "totalContributions")
|
|
})
|
|
|
|
t.Run("OrgTeamDashboard", func(t *testing.T) {
|
|
defer tests.PrintCurrentTest(t)()
|
|
req := NewRequest(t, "GET", "/org/org3/dashboard/-/heatmap/team1")
|
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
|
|
|
result := DecodeJSON(t, resp, map[string]any{})
|
|
assert.Contains(t, result, "heatmapData")
|
|
assert.Contains(t, result, "totalContributions")
|
|
})
|
|
}
|