更新密码找回uniapp
This commit is contained in:
1 parent
7f9a66da0f
commit
3fdda89833
1304 files changed
+3503
-26132
No files matched your search
@@ -12,8 +12,6 @@ import (
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
)
|
||||
|
||||
// 这些用例只覆盖不依赖数据库的身份判定:端归属、令牌错误分类、状态码映射。
|
||||
|
||||
func mint(t *testing.T, userType string) string {
|
||||
t.Helper()
|
||||
tok, err := jwtutil.GenerateToken(4, "hero920103", 2, userType)
|
||||
@@ -42,8 +40,6 @@ func TestRequireAcceptsMatchingEnd(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRequireRejectsForeignEnd(t *testing.T) {
|
||||
// 认证中心换码路径曾签发 user_type=tenant,落到这里就是「令牌有效但端不匹配」。
|
||||
// 这类失败续期救不回来,必须是 403,不能触发前端静默续期重放。
|
||||
for _, userType := range []string{"tenant", "user", "employee", "platform", ""} {
|
||||
_, err := Require(requestWith("Bearer "+mint(t, userType)), EndBackend)
|
||||
if !errors.Is(err, ErrWrongEnd) {
|
||||
@@ -90,8 +86,6 @@ func TestRequireTokenErrorsAreUnauthorized(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClassifyExpired(t *testing.T) {
|
||||
// SignToken/GenerateToken 都把非正数 TTL 钳成默认值,造不出真实过期令牌,
|
||||
// 因此这里直接验证错误分类:被包装的过期错误也要认出来。
|
||||
wrapped := fmt.Errorf("parse token: %w", jwt.ErrTokenExpired)
|
||||
if got := classify(wrapped); !errors.Is(got, ErrExpired) {
|
||||
t.Fatalf("包装后的过期错误应归类为 ErrExpired,实际 %v", got)
|
||||
|
||||
Reference in new issue
Block a user