feat: 增加管理员 AI 模型配置 (#200)
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAIConfigTemplate_密钥不回显且表单语义完整(t *testing.T) {
|
||||
raw, err := os.ReadFile("templates/ai/list.html")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
source := string(raw)
|
||||
for _, want := range []string{
|
||||
`action="/settings/ai/save"`, `action="/settings/ai/secret"`,
|
||||
`action="/settings/ai/test"`, `action="/settings/ai/enable"`,
|
||||
`type="password"`, `autocomplete="new-password"`, "连接测试", "置信度%",
|
||||
} {
|
||||
if !strings.Contains(source, want) {
|
||||
t.Errorf("AI 配置模板缺少 %q", want)
|
||||
}
|
||||
}
|
||||
for _, forbidden := range []string{".APIKey", `value="{{.Secret`, `value="{{.API`} {
|
||||
if strings.Contains(source, forbidden) {
|
||||
t.Fatalf("AI 配置模板可能回显密钥字段 %q", forbidden)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user