feat: 重建 Sense 认证权限与审计 (#64)

This commit is contained in:
QiuSW
2026-08-14 12:03:10 +08:00
parent c515f00319
commit 0411aa37c5
32 changed files with 509 additions and 123 deletions
@@ -0,0 +1,26 @@
package service
import (
"strings"
"testing"
)
func TestValidatePassword(t *testing.T) {
tests := []struct {
name string
value string
wantErr bool
}{
{name: "lowercase accepted", value: "chengma", wantErr: false},
{name: "six characters accepted", value: "abcdef", wantErr: false},
{name: "too short", value: "abcde", wantErr: true},
{name: "bcrypt byte limit", value: strings.Repeat("a", MaxPasswordBytes+1), wantErr: true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := ValidatePassword(tt.value); (got != nil) != tt.wantErr {
t.Fatalf("ValidatePassword() error = %v, wantErr %v", got, tt.wantErr)
}
})
}
}