fix: 修复 SpamBlock 配置越权 (#352)

This commit is contained in:
NikoCat233 authored and GitHub committed 2026-07-22 15:57:22 +08:00
1 parent 87d3ce35d3
commit da55756917
2 files changed
+21

No files matched your search

@@ -0,0 +1,18 @@
package main
import (
"testing"
"github.com/Jinnrry/pmail/utils/context"
)
func TestSettingsHtmlRejectsNonAdminSave(t *testing.T) {
s := &SpamBlock{}
result := s.SettingsHtml(&context.Context{}, "SpamBlock/save", `{"url":"https://model.example.com/predict"}`)
if result != "No Access Privileges" {
t.Fatalf("non-admin save result = %q, want access denial", result)
}
if s.cfg.ApiURL != "" {
t.Fatal("non-admin save changed the configuration")
}
}