Smail/backend/controllers/login_verification_policy_test.go
smail f60d3b0880
Some checks are pending
Security Checks / security (push) Waiting to run
整理前后端与测试构建目录并完善配置和安全引导
统一 frontend、backend、test、test-log 和 out 目录,更新构建、部署及测试入口;纳入配置管理兼容与首次安全引导修复;排除本机配置、密钥和测试产物。
2026-09-05 19:19:52 +08:00

27 lines
927 B
Go

package controllers
import "testing"
func TestLoginVerificationPolicyEnabled(t *testing.T) {
tests := []struct {
name string
enabled bool
policy string
want bool
}{
{name: "disabled", enabled: false, policy: "always", want: false},
{name: "empty policy is disabled", enabled: true, policy: "", want: false},
{name: "off policy is disabled", enabled: true, policy: "off", want: false},
{name: "always policy is enabled", enabled: true, policy: "always", want: true},
{name: "new device policy is enabled", enabled: true, policy: "new_device", want: true},
{name: "policy is case insensitive", enabled: true, policy: "ALWAYS", want: true},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
if got := loginVerificationPolicyEnabled(test.enabled, test.policy); got != test.want {
t.Fatalf("login verification policy result = %v, want %v", got, test.want)
}
})
}
}