From e178f9fcf07a6be75d5c028541ff9624cc045cc2 Mon Sep 17 00:00:00 2001 From: xuans Date: Sun, 30 Aug 2026 20:02:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E7=AE=A1=E7=90=86=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=AF=B7=E6=B1=82=E4=BD=93=E9=99=90=E5=88=B6=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/internal/httpapi/users_api_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/internal/httpapi/users_api_test.go b/backend/internal/httpapi/users_api_test.go index 03e5e03..1e091f3 100644 --- a/backend/internal/httpapi/users_api_test.go +++ b/backend/internal/httpapi/users_api_test.go @@ -42,7 +42,11 @@ func TestUserManagementAuthorizationAndCRUD(t *testing.T) { t.Fatalf("保存用户 API 测试超级管理员失败:%v", err) } server := New(Dependencies{Config: cfg, Repository: &stubDomainRepository{}, Users: users}) - + overSized := `{"username":"operator","password":"` + strings.Repeat("x", 70*1024) + `"}` + overSizedResponse := serveUserRequest(server, httpUserSessionCookie(server, "primary-super-admin", repository.UserRoleSuperAdmin), http.MethodPost, "/api/v1/users", overSized) + if overSizedResponse.Code != http.StatusBadRequest { + t.Fatalf("oversized user request should return 400: %d %s", overSizedResponse.Code, overSizedResponse.Body.String()) + } unauthorized := serveUserRequest(server, nil, http.MethodGet, "/api/v1/users", "") if unauthorized.Code != http.StatusUnauthorized { t.Fatalf("未登录请求应返回 401:%d %s", unauthorized.Code, unauthorized.Body.String())