适配气站工作人员与用户受保护头像
This commit is contained in:
@@ -30,6 +30,7 @@ func registerGasBusinessRoutes(group *gin.RouterGroup) {
|
||||
staff.GET("", gaslogic.ListStaff)
|
||||
staff.POST("", gaslogic.CreateStaff)
|
||||
staff.GET("/:identity", gaslogic.GetStaff)
|
||||
staff.GET("/:identity/avatar", gaslogic.GetStaffAvatar)
|
||||
staff.PUT("/:identity", gaslogic.UpdateStaff)
|
||||
staff.PUT("/:identity/password", gaslogic.ResetStaffPassword)
|
||||
staff.PATCH("/:identity/status", gaslogic.UpdateStaffStatus)
|
||||
@@ -47,6 +48,7 @@ func registerGasBusinessRoutes(group *gin.RouterGroup) {
|
||||
user.GET("", gaslogic.ListUser)
|
||||
user.POST("", gaslogic.CreateUser)
|
||||
user.GET("/:identity", gaslogic.GetUser)
|
||||
user.GET("/:identity/avatar", gaslogic.GetUserAvatar)
|
||||
user.PUT("/:identity", gaslogic.UpdateUser)
|
||||
user.PUT("/:identity/password", gaslogic.ResetUserPassword)
|
||||
user.PATCH("/:identity/status", gaslogic.UpdateUserStatus)
|
||||
|
||||
@@ -81,3 +81,22 @@ func TestGasReadonlyDetailRoutes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestGasAvatarRoutes 验证工作人员与用户头像只能通过气站鉴权路由读取。
|
||||
func TestGasAvatarRoutes(t *testing.T) {
|
||||
gin.SetMode(gin.TestMode)
|
||||
engine := gin.New()
|
||||
RegisterGas("heqi", engine)
|
||||
routes := map[string]bool{}
|
||||
for _, route := range engine.Routes() {
|
||||
routes[route.Method+" "+route.Path] = true
|
||||
}
|
||||
for _, path := range []string{
|
||||
"GET /heqi/gas/v1/staff_account/:identity/avatar",
|
||||
"GET /heqi/gas/v1/user_account/:identity/avatar",
|
||||
} {
|
||||
if !routes[path] {
|
||||
t.Fatalf("missing gas avatar route %s", path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user