feat(backend): jwt middleware, login with redis rate limit, /auth/me

This commit is contained in:
2026-09-04 23:58:26 +08:00
parent a2f202ada6
commit bc88cabc47
9 changed files with 341 additions and 8 deletions
+24
View File
@@ -0,0 +1,24 @@
package redispkg
import (
"context"
"testing"
"time"
)
func TestDisabledIsSafe(t *testing.T) {
r := New("")
ctx := context.Background()
if _, ok := r.Get(ctx, "x"); ok {
t.Fatal("disabled Get must miss")
}
r.Set(ctx, "x", "y", time.Second) // 不 panic
if n := r.IncrWindow(ctx, "k", time.Second); n != 1 {
t.Fatal("disabled IncrWindow must allow")
}
un, ok := r.Lock(ctx, "lk", time.Second)
if !ok {
t.Fatal("disabled Lock must always acquire")
}
un()
}