feat: 重建 Sense 认证权限与审计 (#64)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user