Files
past-go/past-go/internal/httpapi/record_access_test.go
T
Blizzard b854d2873e feat: require couple binding and refine miniapp settings
Gate record features and storage entry points with invitation guidance; enforce record access in the backend. Add homepage greetings, right-swipe profile dismissal, and move the smoking switch to settings. Simplify API base configuration and remove the unused legacy tab bar component.
2026-11-04 21:27:03 +08:00

33 lines
1.1 KiB
Go

package httpapi
import (
"github.com/gin-gonic/gin"
"net/http/httptest"
"testing"
)
func TestRecordBindingAccess(t *testing.T) {
for _, action := range []string{"diary_list", "diary_add", "diary_comment_add", "timeline_detail", "album_add", "photos", "photo_upload", "set_album_cover", "songs_list", "checkin_do", "smoking_card_visible", "pet_adopt", "period_daily_save"} {
t.Run(action, func(t *testing.T) {
for _, cid := range []string{"", "bound-couple"} {
out := httptest.NewRecorder()
g, _ := gin.CreateTestContext(out)
c := &Ctx{G: g, Action: action, coupleResolved: true, coupleID: cid}
err := c.requireRecordBinding()
if cid == "" {
if !IsResponded(err) || out.Code != 403 {
t.Fatalf("unbound allowed: %v %d", err, out.Code)
}
} else if err != nil {
t.Fatal(err)
}
}
})
}
for _, action := range []string{"upload", "upload_avatar", "update_profile", "couple_info", "invite_partner", "storage_info", "account_delete", "announcement", "admin_contents"} {
if recordAction(action) {
t.Fatalf("unrelated feature blocked: %s", action)
}
}
}