fix(auth): 公开登录门按来源限速并设全站发信上限,冷却表定期清理

This commit is contained in:
Lemon-miaow committed 2026-09-24 15:51:42 +08:00
1 parent 15f729ffea
commit c4e4953f3d
26 files changed
+1141 -64

No files matched your search

+14
View File
@@ -3,9 +3,12 @@ package api
import (
"context"
"net/http"
"slices"
"strings"
"testing"
"time"
"felis.lolicon.best/internal/metrics"
)
// The per-code attempt cap resets on every resend; these pin the account-level
@@ -181,3 +184,14 @@ func TestOTPLockNoticeNamesDoorAndTime(t *testing.T) {
}
}
}
// The lockout alert sees a purpose only if metrics pre-creates its series.
func TestOTPPurposesMatchMetricLabels(t *testing.T) {
got := []string{otpPurposeOnboard, otpPurposeLogin, otpPurposeOpLogin, otpPurposeMigrate}
want := slices.Clone(metrics.OTPPurposes)
slices.Sort(got)
slices.Sort(want)
if !slices.Equal(got, want) {
t.Fatalf("otp purposes %v, metrics.OTPPurposes %v", got, want)
}
}