Similarityoung commented on code in PR #1062:
URL: https://github.com/apache/dubbo-go-pixiu/pull/1062#discussion_r4505581764


##########
admin/controller/auth/auth_test.go:
##########
@@ -31,12 +31,8 @@ import (
 )
 
 func TestParseTokenRejectsUnexpectedSigningMethod(t *testing.T) {
-       claims := CustomClaims{
-               Username: "admin",
-               StandardClaims: jwt.StandardClaims{
-                       ExpiresAt: time.Now().Add(time.Hour).Unix(),
-               },
-       }
+       claims := CustomClaims{Username: "admin"}

Review Comment:
   已确认并处理。合并后的 #1061(658354d2)新增 fixture 已采用 promoted `ExpiresAt` 写法;本分支 rebase 
后已移除该文件剩余 7 处显式 `jwt.StandardClaims`,目前 `rg "jwt.StandardClaims" 
admin/controller/auth/auth_test.go` 为 0。为避免后续新增用例回退,同时将全部 12 处 claims fixture 
收敛到 `newTestClaims`。



##########
admin/controller/auth/auth_test.go:
##########
@@ -31,12 +31,8 @@ import (
 )
 
 func TestParseTokenRejectsUnexpectedSigningMethod(t *testing.T) {
-       claims := CustomClaims{
-               Username: "admin",
-               StandardClaims: jwt.StandardClaims{
-                       ExpiresAt: time.Now().Add(time.Hour).Unix(),
-               },
-       }
+       claims := CustomClaims{Username: "admin"}
+       claims.ExpiresAt = time.Now().Add(time.Hour).Unix()

Review Comment:
   已采纳:新增 `newTestClaims(ttl)`,并将文件中全部 12 处 claims fixture(含 #1061 新增用例)统一到该 
helper,避免重复样板和过期/有效边界分散。



##########
admin/controller/auth/auth_test.go:
##########
@@ -31,12 +31,8 @@ import (
 )
 
 func TestParseTokenRejectsUnexpectedSigningMethod(t *testing.T) {
-       claims := CustomClaims{
-               Username: "admin",
-               StandardClaims: jwt.StandardClaims{
-                       ExpiresAt: time.Now().Add(time.Hour).Unix(),
-               },
-       }
+       claims := CustomClaims{Username: "admin"}

Review Comment:
   已在 `newTestClaims` 上方补充注释,说明这里直接赋值 promoted `ExpiresAt` 是为了避免 staticcheck 
SA1019,防止后续重构回退到 struct literal。



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to