1 parent
18b6dfbdf7
commit
dd04bdb49e
83 files changed
+4547
-583
No files matched your search
@@ -6,8 +6,23 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.pcux.cn/xuans/Smail/models"
|
||||
"git.pcux.cn/xuans/Smail/services/access"
|
||||
)
|
||||
|
||||
func TestLoginSecurityFieldsByRole(t *testing.T) {
|
||||
ordinary := loginSecurityFields(&models.User{ID: 1, Role: string(access.RoleUser)})
|
||||
if ordinary["recoveryCodesConfigured"] != false || ordinary["showRecoverySetupPrompt"] != true {
|
||||
t.Fatalf("ordinary user security fields = %#v", ordinary)
|
||||
}
|
||||
|
||||
superAdmin := loginSecurityFields(&models.User{ID: 2, Role: string(access.RoleSuperAdmin)})
|
||||
if superAdmin["recoveryCodesConfigured"] != false || superAdmin["showRecoverySetupPrompt"] != false {
|
||||
t.Fatalf("super administrator security fields = %#v", superAdmin)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoginLimiterBlocksAndExpires(t *testing.T) {
|
||||
limiter := newLoginLimiter()
|
||||
now := time.Date(2026, 8, 24, 12, 0, 0, 0, time.UTC)
|
||||
|
||||
Reference in new issue
Block a user