docs: project docs, scripts, deployment configs, and evidence

This commit is contained in:
2026-04-02 11:22:17 +08:00
parent 4718980ab5
commit bbeeb63dfa
396 changed files with 165018 additions and 0 deletions

680
verbose_test.txt Normal file
View File

@@ -0,0 +1,680 @@
? github.com/user-management-system/cmd/server [no test files]
=== RUN TestAuthHandler_Register_MissingUsername
--- PASS: TestAuthHandler_Register_MissingUsername (0.00s)
=== RUN TestAuthHandler_Register_MissingPassword
--- PASS: TestAuthHandler_Register_MissingPassword (0.00s)
=== RUN TestAuthHandler_Register_InvalidJSON
--- PASS: TestAuthHandler_Register_InvalidJSON (0.00s)
=== RUN TestAuthHandler_Login_MissingFields
=== RUN TestAuthHandler_Login_MissingFields/空_account
=== RUN TestAuthHandler_Login_MissingFields/空_password
=== RUN TestAuthHandler_Login_MissingFields/全空
--- PASS: TestAuthHandler_Login_MissingFields (0.00s)
--- PASS: TestAuthHandler_Login_MissingFields/空_account (0.00s)
--- PASS: TestAuthHandler_Login_MissingFields/空_password (0.00s)
--- PASS: TestAuthHandler_Login_MissingFields/全空 (0.00s)
=== RUN TestAuthHandler_Login_InvalidJSON
--- PASS: TestAuthHandler_Login_InvalidJSON (0.00s)
=== RUN TestAuthHandler_RefreshToken_MissingToken
--- PASS: TestAuthHandler_RefreshToken_MissingToken (0.00s)
=== RUN TestAuthHandler_ResponseFormat
--- PASS: TestAuthHandler_ResponseFormat (0.00s)
=== RUN TestDeviceHandler_CreateDevice_InvalidJSON
--- PASS: TestDeviceHandler_CreateDevice_InvalidJSON (0.00s)
=== RUN TestDeviceHandler_UpdateDevice_InvalidID
--- PASS: TestDeviceHandler_UpdateDevice_InvalidID (0.00s)
=== RUN TestWebhookHandler_CreateWebhook_InvalidJSON
--- PASS: TestWebhookHandler_CreateWebhook_InvalidJSON (0.00s)
=== RUN TestWebhookHandler_DeleteWebhook_InvalidID
--- PASS: TestWebhookHandler_DeleteWebhook_InvalidID (0.00s)
=== RUN TestTOTPHandler_EnableTOTP_InvalidJSON
--- PASS: TestTOTPHandler_EnableTOTP_InvalidJSON (0.00s)
=== RUN TestLogHandler_GetMyLoginLogs_Unauthenticated
--- PASS: TestLogHandler_GetMyLoginLogs_Unauthenticated (0.00s)
=== RUN TestCaptchaHandler_VerifyCaptcha_InvalidJSON
--- PASS: TestCaptchaHandler_VerifyCaptcha_InvalidJSON (0.00s)
=== RUN TestPasswordResetHandler_ForgotPassword_InvalidJSON
--- PASS: TestPasswordResetHandler_ForgotPassword_InvalidJSON (0.00s)
=== RUN TestRoleHandler_CreateRole_InvalidJSON
--- PASS: TestRoleHandler_CreateRole_InvalidJSON (0.00s)
=== RUN TestRoleHandler_GetRole_InvalidID
--- PASS: TestRoleHandler_GetRole_InvalidID (0.00s)
=== RUN TestRoleHandler_UpdateRole_InvalidJSON
--- PASS: TestRoleHandler_UpdateRole_InvalidJSON (0.00s)
=== RUN TestPermissionHandler_CreatePermission_InvalidJSON
--- PASS: TestPermissionHandler_CreatePermission_InvalidJSON (0.00s)
=== RUN TestPermissionHandler_GetPermission_InvalidID
--- PASS: TestPermissionHandler_GetPermission_InvalidID (0.00s)
=== RUN TestUserHandler_GetUser_InvalidID
--- PASS: TestUserHandler_GetUser_InvalidID (0.00s)
=== RUN TestUserHandler_UpdateUser_InvalidJSON
--- PASS: TestUserHandler_UpdateUser_InvalidJSON (0.00s)
=== RUN TestUserHandler_ListUsers_Response
--- PASS: TestUserHandler_ListUsers_Response (0.00s)
=== RUN TestUserHandler_UpdatePassword_InvalidJSON
--- PASS: TestUserHandler_UpdatePassword_InvalidJSON (0.00s)
=== RUN TestUserHandler_DeleteUser_ResponseFormat
--- PASS: TestUserHandler_DeleteUser_ResponseFormat (0.00s)
PASS
ok github.com/user-management-system/internal/api/handler 1.760s
=== RUN TestIPFilter_BlockedIP_Returns403
--- PASS: TestIPFilter_BlockedIP_Returns403 (0.00s)
=== RUN TestIPFilter_NonBlockedIP_Returns200
--- PASS: TestIPFilter_NonBlockedIP_Returns200 (0.00s)
=== RUN TestIPFilter_EmptyBlacklist_AllPass
--- PASS: TestIPFilter_EmptyBlacklist_AllPass (0.00s)
=== RUN TestIPFilter_WhitelistOverridesBlacklist
--- PASS: TestIPFilter_WhitelistOverridesBlacklist (0.00s)
=== RUN TestIPFilter_CIDRBlacklist
--- PASS: TestIPFilter_CIDRBlacklist (0.00s)
=== RUN TestIPFilter_ExpiredRule_Passes
--- PASS: TestIPFilter_ExpiredRule_Passes (0.00s)
=== RUN TestIPFilter_ClientIPSetInContext
--- PASS: TestIPFilter_ClientIPSetInContext (0.00s)
=== RUN TestRealIP_XForwardedFor_PublicIP
--- PASS: TestRealIP_XForwardedFor_PublicIP (0.00s)
=== RUN TestRealIP_XForwardedFor_AllPrivate
--- PASS: TestRealIP_XForwardedFor_AllPrivate (0.00s)
=== RUN TestRealIP_XRealIP_Fallback
--- PASS: TestRealIP_XRealIP_Fallback (0.00s)
=== RUN TestRealIP_RemoteAddr_Fallback
--- PASS: TestRealIP_RemoteAddr_Fallback (0.00s)
=== RUN TestIPFilterMiddleware_GetFilter
--- PASS: TestIPFilterMiddleware_GetFilter (0.00s)
=== RUN TestIPFilter_ConcurrentRequests
--- PASS: TestIPFilter_ConcurrentRequests (0.00s)
PASS
ok github.com/user-management-system/internal/api/middleware 0.881s
? github.com/user-management-system/internal/api/router [no test files]
=== RUN TestTOTPManager_GenerateAndValidate
totp_test.go:26: 生成 Secret: KEU6VS5PMBZ2W24HYHUGK2SY6O3MVOXR
totp_test.go:27: 恢复码示例: LLO5M-VH7RH
totp_test.go:37: TOTP 验证通过code=715062
--- PASS: TestTOTPManager_GenerateAndValidate (0.01s)
=== RUN TestTOTPManager_InvalidCode
totp_test.go:52: 无效验证码正确拒绝
--- PASS: TestTOTPManager_InvalidCode (0.01s)
=== RUN TestTOTPManager_RecoveryCodeFormat
--- PASS: TestTOTPManager_RecoveryCodeFormat (0.01s)
=== RUN TestValidateRecoveryCode
totp_test.go:100: 恢复码验证全部通过
--- PASS: TestValidateRecoveryCode (0.00s)
PASS
ok github.com/user-management-system/internal/auth 3.237s
? github.com/user-management-system/internal/auth/providers [no test files]
=== RUN TestRedisCache_Disabled
--- PASS: TestRedisCache_Disabled (0.00s)
=== RUN TestL1Cache_SetGet
--- PASS: TestL1Cache_SetGet (0.00s)
=== RUN TestL1Cache_Expiration
--- PASS: TestL1Cache_Expiration (0.10s)
=== RUN TestL1Cache_Delete
--- PASS: TestL1Cache_Delete (0.00s)
=== RUN TestL1Cache_Clear
--- PASS: TestL1Cache_Clear (0.00s)
=== RUN TestL1Cache_Size
--- PASS: TestL1Cache_Size (0.00s)
=== RUN TestL1Cache_Cleanup
--- PASS: TestL1Cache_Cleanup (0.06s)
=== RUN TestCacheManager_SetGet
--- PASS: TestCacheManager_SetGet (0.00s)
=== RUN TestCacheManager_Delete
--- PASS: TestCacheManager_Delete (0.00s)
=== RUN TestCacheManager_Exists
--- PASS: TestCacheManager_Exists (0.00s)
=== RUN TestCacheManager_Clear
--- PASS: TestCacheManager_Clear (0.00s)
=== RUN TestCacheManager_Concurrent
--- PASS: TestCacheManager_Concurrent (0.00s)
=== RUN TestCacheManager_WithDisabledL2
--- PASS: TestCacheManager_WithDisabledL2 (0.00s)
PASS
ok github.com/user-management-system/internal/cache 3.056s
=== RUN Test100kConcurrentLogins
concurrent_test.go:228: 开始并发测试: 大并发登录, 并发数: 1000
concurrent_test.go:235: 总请求=4372702, 成功=4372702, 失败=0, P99=65.6073ms, TPS=437160.65, 错误率=0.00%
--- PASS: Test100kConcurrentLogins (10.08s)
=== RUN Test200kConcurrentTokenValidations
concurrent_test.go:258: 总请求=7654944, P99=7.8338ms, TPS=764709.66
--- PASS: Test200kConcurrentTokenValidations (10.14s)
=== RUN TestConcurrentTokenValidation
concurrent_test.go:272: 总请求=1930728, 成功=1930728, TPS=643402.69
--- PASS: TestConcurrentTokenValidation (3.03s)
=== RUN TestConcurrentReadWrite
concurrent_test.go:306: 并发读写测试完成: 读goroutines=100, 写goroutines=20, 最终值=2000
--- PASS: TestConcurrentReadWrite (0.00s)
=== RUN TestConcurrentRegistration
concurrent_test.go:311: 跳过并发数据库测试SQLite不可用: Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work. This is a stub
--- SKIP: TestConcurrentRegistration (0.00s)
PASS
ok github.com/user-management-system/internal/concurrent 23.549s
? github.com/user-management-system/internal/config [no test files]
=== RUN TestIndexUsage
=== RUN TestIndexUsage/主键查询应使用主键索引
database_index_test.go:188: 使用索引: idx_users_username (期望: PRIMARY)
=== RUN TestIndexUsage/用户名查询应使用username索引
=== RUN TestIndexUsage/邮箱查询应使用email索引
database_index_test.go:188: 使用索引: idx_users_username (期望: idx_users_email)
=== RUN TestIndexUsage/时间范围查询应使用created_at索引
database_index_test.go:188: 使用索引: idx_users_username (期望: idx_users_created_at)
--- PASS: TestIndexUsage (0.00s)
--- PASS: TestIndexUsage/主键查询应使用主键索引 (0.00s)
--- PASS: TestIndexUsage/用户名查询应使用username索引 (0.00s)
--- PASS: TestIndexUsage/邮箱查询应使用email索引 (0.00s)
--- PASS: TestIndexUsage/时间范围查询应使用created_at索引 (0.00s)
=== RUN TestIndexSelectivity
=== RUN TestIndexSelectivity/ID列应具有高选择性
database_index_test.go:226: 列 'id' 的选择性: 100.00% (1000000/1000000)
=== RUN TestIndexSelectivity/用户名列应具有高选择性
database_index_test.go:226: 列 'username' 的选择性: 99.90% (999000/1000000)
=== RUN TestIndexSelectivity/角色列可能具有较低选择性
database_index_test.go:226: 列 'role' 的选择性: 0.00% (5/1000000)
--- PASS: TestIndexSelectivity (0.00s)
--- PASS: TestIndexSelectivity/ID列应具有高选择性 (0.00s)
--- PASS: TestIndexSelectivity/用户名列应具有高选择性 (0.00s)
--- PASS: TestIndexSelectivity/角色列可能具有较低选择性 (0.00s)
=== RUN TestIndexCovering
=== RUN TestIndexCovering/覆盖索引查询
database_index_test.go:264: 查询使用覆盖索引,包含列: id, username, email
=== RUN TestIndexCovering/非覆盖索引查询
database_index_test.go:266: 查询未使用覆盖索引,需要回表查询
--- PASS: TestIndexCovering (0.00s)
--- PASS: TestIndexCovering/覆盖索引查询 (0.00s)
--- PASS: TestIndexCovering/非覆盖索引查询 (0.00s)
=== RUN TestIndexFragmentation
=== RUN TestIndexFragmentation/用户表主键索引碎片化
database_index_test.go:299: 表 'users' 的索引 'PRIMARY' 碎片化率: 2.50%
=== RUN TestIndexFragmentation/用户表username索引碎片化
database_index_test.go:299: 表 'users' 的索引 'idx_users_username' 碎片化率: 5.30%
--- PASS: TestIndexFragmentation (0.00s)
--- PASS: TestIndexFragmentation/用户表主键索引碎片化 (0.00s)
--- PASS: TestIndexFragmentation/用户表username索引碎片化 (0.00s)
=== RUN TestIndexSize
=== RUN TestIndexSize/用户表索引大小
database_index_test.go:332: 表 'users' 的索引 'idx_users_username' 大小: 50.00 MB, 占比 25.00%
--- PASS: TestIndexSize (0.00s)
--- PASS: TestIndexSize/用户表索引大小 (0.00s)
=== RUN TestIndexRebuildPerformance
=== RUN TestIndexRebuildPerformance/重建用户表主键索引
database_index_test.go:378: 重建索引 'PRIMARY' 用时: 5.0003753s (行数: 1000000)
=== RUN TestIndexRebuildPerformance/重建用户表username索引
database_index_test.go:378: 重建索引 'idx_users_username' 用时: 5.0009554s (行数: 1000000)
--- PASS: TestIndexRebuildPerformance (10.00s)
--- PASS: TestIndexRebuildPerformance/重建用户表主键索引 (5.00s)
--- PASS: TestIndexRebuildPerformance/重建用户表username索引 (5.00s)
=== RUN TestQueryPlanStability
=== RUN TestQueryPlanStability/用户ID查询
=== RUN TestQueryPlanStability/用户名查询
=== RUN TestQueryPlanStability/邮箱查询
--- PASS: TestQueryPlanStability (0.00s)
--- PASS: TestQueryPlanStability/用户ID查询 (0.00s)
--- PASS: TestQueryPlanStability/用户名查询 (0.00s)
--- PASS: TestQueryPlanStability/邮箱查询 (0.00s)
=== RUN TestFullTableScanDetection
=== RUN TestFullTableScanDetection/ID查询不应全表扫描
database_index_test.go:465: 查询正确使用索引
=== RUN TestFullTableScanDetection/LIKE前缀查询不应全表扫描
database_index_test.go:465: 查询正确使用索引
=== RUN TestFullTableScanDetection/LIKE中间查询可能全表扫描
=== RUN TestFullTableScanDetection/函数包装列会全表扫描
--- PASS: TestFullTableScanDetection (0.00s)
--- PASS: TestFullTableScanDetection/ID查询不应全表扫描 (0.00s)
--- PASS: TestFullTableScanDetection/LIKE前缀查询不应全表扫描 (0.00s)
--- PASS: TestFullTableScanDetection/LIKE中间查询可能全表扫描 (0.00s)
--- PASS: TestFullTableScanDetection/函数包装列会全表扫描 (0.00s)
=== RUN TestIndexEfficiency
=== RUN TestIndexEfficiency/精确查询应扫描少量行
database_index_test.go:500: 查询扫描/返回比: 1.00 (1/1)
=== RUN TestIndexEfficiency/范围查询应扫描适量行
database_index_test.go:500: 查询扫描/返回比: 1.00 (10000/10000)
--- PASS: TestIndexEfficiency (0.00s)
--- PASS: TestIndexEfficiency/精确查询应扫描少量行 (0.00s)
--- PASS: TestIndexEfficiency/范围查询应扫描适量行 (0.00s)
=== RUN TestCompositeIndexOrder
=== RUN TestCompositeIndexOrder/复合索引(用户名,邮箱)_-_完全匹配
=== RUN TestCompositeIndexOrder/复合索引(用户名,邮箱)_-_前缀匹配
=== RUN TestCompositeIndexOrder/复合索引(用户名,邮箱)_-_跳过列
database_index_test.go:551: 查询未使用复合索引 'idx_users_username_email' (列: [username email])
--- PASS: TestCompositeIndexOrder (0.00s)
--- PASS: TestCompositeIndexOrder/复合索引(用户名,邮箱)_-_完全匹配 (0.00s)
--- PASS: TestCompositeIndexOrder/复合索引(用户名,邮箱)_-_前缀匹配 (0.00s)
--- PASS: TestCompositeIndexOrder/复合索引(用户名,邮箱)_-_跳过列 (0.00s)
=== RUN TestIndexLocking
=== RUN TestIndexLocking/在线创建索引锁定时间
database_index_test.go:583: CREATE INDEX idx_test ON users(username) 锁定时间: 100ms
=== RUN TestIndexLocking/在线删除索引锁定时间
database_index_test.go:583: DROP INDEX idx_test ON users 锁定时间: 50ms
--- PASS: TestIndexLocking (0.00s)
--- PASS: TestIndexLocking/在线创建索引锁定时间 (0.00s)
--- PASS: TestIndexLocking/在线删除索引锁定时间 (0.00s)
=== RUN TestIndexMaintenance
=== RUN TestIndexMaintenance/ANALYZE_TABLE
database_index_test.go:640: ANALYZE TABLE 执行成功
=== RUN TestIndexMaintenance/OPTIMIZE_TABLE
database_index_test.go:645: OPTIMIZE TABLE 执行成功
=== RUN TestIndexMaintenance/CHECK_TABLE
database_index_test.go:650: CHECK TABLE 执行成功
--- PASS: TestIndexMaintenance (0.00s)
--- PASS: TestIndexMaintenance/ANALYZE_TABLE (0.00s)
--- PASS: TestIndexMaintenance/OPTIMIZE_TABLE (0.00s)
--- PASS: TestIndexMaintenance/CHECK_TABLE (0.00s)
PASS
ok github.com/user-management-system/internal/database 13.584s
=== RUN TestUserStatusConstantsExtra
--- PASS: TestUserStatusConstantsExtra (0.00s)
=== RUN TestUserModel
--- PASS: TestUserModel (0.00s)
=== RUN TestUserTableName
--- PASS: TestUserTableName (0.00s)
=== RUN TestUserStatusConstants
--- PASS: TestUserStatusConstants (0.00s)
=== RUN TestGenderConstants
--- PASS: TestGenderConstants (0.00s)
=== RUN TestUserActiveCheck
--- PASS: TestUserActiveCheck (0.00s)
PASS
ok github.com/user-management-system/internal/domain 2.263s
=== RUN TestE2ERegisterAndLogin
[API] 2026-03-16 15:28:21 POST /api/v1/auth/register | status: 200 | latency: 81.9874ms | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
e2e_test.go:162: 注册成功: map[avatar: email:e2euser1@example.com id:1 nickname: phone: status:1 username:e2e_user1]
[API] 2026-03-16 15:28:21 POST /api/v1/auth/login | status: 200 | latency: 67.892ms | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
e2e_test.go:185: 登录成功access_token 长度=283
[API] 2026-03-16 15:28:21 GET /api/v1/auth/userinfo | status: 200 | latency: 1.0356ms | ip: 127.0.0.1 | user_id: 1 | ua: Go-http-client/1.1
e2e_test.go:198: 用户信息获取成功: map[avatar: email:e2euser1@example.com id:1 nickname: phone: status:1 username:e2e_user1]
[API] 2026-03-16 15:28:21 POST /api/v1/auth/logout | status: 200 | latency: 434.1µs | ip: 127.0.0.1 | user_id: 1 | ua: Go-http-client/1.1
e2e_test.go:205: 登出成功
--- PASS: TestE2ERegisterAndLogin (0.16s)
=== RUN TestE2ELoginFailures
[API] 2026-03-16 15:28:21 POST /api/v1/auth/register | status: 200 | latency: 70.0723ms | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[API] 2026-03-16 15:28:21 POST /api/v1/auth/login | status: 401 | latency: 66.1336ms | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
e2e_test.go:234: 错误密码返回 HTTP 401符合预期
[API] 2026-03-16 15:28:21 POST /api/v1/auth/login | status: 401 | latency: 0s | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
--- PASS: TestE2ELoginFailures (0.15s)
=== RUN TestE2EUnauthorizedAccess
[API] 2026-03-16 15:28:21 GET /api/v1/auth/userinfo | status: 401 | latency: 0s | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
e2e_test.go:263: 未认证访问正确返回 401
[API] 2026-03-16 15:28:21 GET /api/v1/auth/userinfo | status: 401 | latency: 0s | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
e2e_test.go:270: 无效 token 正确返回 401
--- PASS: TestE2EUnauthorizedAccess (0.01s)
=== RUN TestE2EPasswordReset
[API] 2026-03-16 15:28:21 POST /api/v1/auth/register | status: 200 | latency: 67.982ms | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[API] 2026-03-16 15:28:21 POST /api/v1/auth/forgot-password | status: 200 | latency: 1.0478ms | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[密码重置邮件-开发模式] To: resetuser@example.com
Subject: 密码重置请求
ResetURL: http://localhost/reset-password?token=1c80318e5ecb044ec896e37f0e21a27bb075e89d12a7e062b08914121a142629
e2e_test.go:293: 密码重置请求正确返回 200
--- PASS: TestE2EPasswordReset (0.08s)
=== RUN TestE2ECaptcha
[API] 2026-03-16 15:28:21 GET /api/v1/auth/captcha | status: 200 | latency: 3.0943ms | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
e2e_test.go:322: 验证码生成成功captcha_id=1773646101458624000-3275f282db33bb745c3384a254b09d87
[API] 2026-03-16 15:28:21 GET /api/v1/auth/captcha/image | status: 200 | latency: 2.0854ms | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[Query] /api/v1/auth/captcha/image?captcha_id=1773646101458624000-3275f282db33bb745c3384a254b09d87
e2e_test.go:329: 验证码图片获取成功
--- PASS: TestE2ECaptcha (0.01s)
=== RUN TestE2EConcurrentLogin
[API] 2026-03-16 15:28:21 POST /api/v1/auth/register | status: 200 | latency: 69.3837ms | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[API] 2026-03-16 15:28:21 POST /api/v1/auth/login | status: 429 | latency: 0s | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[API] 2026-03-16 15:28:21 POST /api/v1/auth/login | status: 429 | latency: 0s | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[API] 2026-03-16 15:28:21 POST /api/v1/auth/login | status: 429 | latency: 0s | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[API] 2026-03-16 15:28:21 POST /api/v1/auth/login | status: 429 | latency: 0s | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[API] 2026-03-16 15:28:21 POST /api/v1/auth/login | status: 429 | latency: 0s | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[API] 2026-03-16 15:28:21 POST /api/v1/auth/login | status: 429 | latency: 0s | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[API] 2026-03-16 15:28:21 POST /api/v1/auth/login | status: 429 | latency: 0s | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[API] 2026-03-16 15:28:21 POST /api/v1/auth/login | status: 429 | latency: 2.2605ms | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[API] 2026-03-16 15:28:21 POST /api/v1/auth/login | status: 429 | latency: 0s | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[API] 2026-03-16 15:28:21 POST /api/v1/auth/login | status: 429 | latency: 0s | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[API] 2026-03-16 15:28:21 POST /api/v1/auth/login | status: 429 | latency: 132.8µs | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[API] 2026-03-16 15:28:21 POST /api/v1/auth/login | status: 429 | latency: 0s | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[API] 2026-03-16 15:28:21 POST /api/v1/auth/login | status: 429 | latency: 0s | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[API] 2026-03-16 15:28:21 POST /api/v1/auth/login | status: 429 | latency: 0s | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[API] 2026-03-16 15:28:21 POST /api/v1/auth/login | status: 429 | latency: 0s | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[API] 2026-03-16 15:28:21 POST /api/v1/auth/login | status: 429 | latency: 0s | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[API] 2026-03-16 15:28:21 POST /api/v1/auth/login | status: 429 | latency: 0s | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[API] 2026-03-16 15:28:21 POST /api/v1/auth/login | status: 429 | latency: 0s | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[API] 2026-03-16 15:28:21 POST /api/v1/auth/login | status: 200 | latency: 71.2774ms | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
[API] 2026-03-16 15:28:21 POST /api/v1/auth/login | status: 200 | latency: 72.4312ms | ip: 127.0.0.1 | user_id: <nil> | ua: Go-http-client/1.1
e2e_test.go:384: 并发登录结果: 成功=2 失败=18 总耗时=74.3998ms 平均=13.020135ms
--- PASS: TestE2EConcurrentLogin (0.15s)
PASS
ok github.com/user-management-system/internal/e2e 1.050s
=== RUN TestDatabaseIntegration
=== RUN TestDatabaseIntegration/CreateUser
=== RUN TestDatabaseIntegration/FindUser
=== RUN TestDatabaseIntegration/UpdateUser
=== RUN TestDatabaseIntegration/DeleteUser
--- PASS: TestDatabaseIntegration (0.02s)
--- PASS: TestDatabaseIntegration/CreateUser (0.01s)
--- PASS: TestDatabaseIntegration/FindUser (0.00s)
--- PASS: TestDatabaseIntegration/UpdateUser (0.00s)
--- PASS: TestDatabaseIntegration/DeleteUser (0.00s)
=== RUN TestTransactionIntegration
=== RUN TestTransactionIntegration/TransactionRollback
=== RUN TestTransactionIntegration/TransactionCommit
--- PASS: TestTransactionIntegration (0.00s)
--- PASS: TestTransactionIntegration/TransactionRollback (0.00s)
--- PASS: TestTransactionIntegration/TransactionCommit (0.00s)
=== RUN TestAPIIntegration
=== RUN TestAPIIntegration/RegisterEndpoint
=== RUN TestAPIIntegration/LoginEndpoint
=== RUN TestAPIIntegration/GetUserEndpoint
--- PASS: TestAPIIntegration (0.00s)
--- PASS: TestAPIIntegration/RegisterEndpoint (0.00s)
--- PASS: TestAPIIntegration/LoginEndpoint (0.00s)
--- PASS: TestAPIIntegration/GetUserEndpoint (0.00s)
PASS
ok github.com/user-management-system/internal/integration 1.844s
=== RUN TestMiddlewarePackageExists
middleware_test.go:13: middleware package ok
--- PASS: TestMiddlewarePackageExists (0.00s)
PASS
ok github.com/user-management-system/internal/middleware 2.041s
? github.com/user-management-system/internal/models [no test files]
=== RUN TestNewMetrics
--- PASS: TestNewMetrics (0.00s)
=== RUN TestMetricsGetCollectors
--- PASS: TestMetricsGetCollectors (0.00s)
=== RUN TestIncHTTPRequest
--- PASS: TestIncHTTPRequest (0.00s)
=== RUN TestObserveHTTPRequestDuration
--- PASS: TestObserveHTTPRequestDuration (0.00s)
=== RUN TestIncDBQuery
--- PASS: TestIncDBQuery (0.00s)
=== RUN TestObserveDBQueryDuration
--- PASS: TestObserveDBQueryDuration (0.00s)
=== RUN TestIncUserRegistration
--- PASS: TestIncUserRegistration (0.00s)
=== RUN TestIncUserLogin
--- PASS: TestIncUserLogin (0.00s)
=== RUN TestSetActiveUsers
--- PASS: TestSetActiveUsers (0.00s)
=== RUN TestSetMemoryUsage
--- PASS: TestSetMemoryUsage (0.00s)
=== RUN TestSetGoroutines
--- PASS: TestSetGoroutines (0.00s)
PASS
ok github.com/user-management-system/internal/monitoring 0.350s
=== RUN TestP99LatencyThreshold
=== RUN TestP99LatencyThreshold/JWT生成P99
=== RUN TestP99LatencyThreshold/模拟用户查询P99
--- PASS: TestP99LatencyThreshold (0.29s)
--- PASS: TestP99LatencyThreshold/JWT生成P99 (0.00s)
--- PASS: TestP99LatencyThreshold/模拟用户查询P99 (0.29s)
=== RUN TestCacheHitRate
=== RUN TestCacheHitRate/用户查询缓存命中率
=== RUN TestCacheHitRate/Token验证缓存命中率
--- PASS: TestCacheHitRate (0.00s)
--- PASS: TestCacheHitRate/用户查询缓存命中率 (0.00s)
--- PASS: TestCacheHitRate/Token验证缓存命中率 (0.00s)
=== RUN TestThroughput
=== RUN TestThroughput/登录吞吐量
performance_test.go:311: 实际吞吐量: 3506.26 TPS
=== RUN TestThroughput/用户查询吞吐量
performance_test.go:311: 实际吞吐量: 17567.53 TPS
--- PASS: TestThroughput (4.00s)
--- PASS: TestThroughput/登录吞吐量 (2.00s)
--- PASS: TestThroughput/用户查询吞吐量 (2.00s)
=== RUN TestMemoryUsage
performance_test.go:333: 内存变化: 0.02 MB
--- PASS: TestMemoryUsage (0.26s)
=== RUN TestGCPressure
performance_test.go:350: 平均GC停顿: 6.02 ms
--- PASS: TestGCPressure (0.11s)
=== RUN TestConnectionPool
performance_test.go:375: 连接池复用分布: max=100, min=100
--- PASS: TestConnectionPool (0.00s)
=== RUN TestResourceLeak
performance_test.go:392: Goroutine数量变化: 0
--- PASS: TestResourceLeak (0.20s)
PASS
ok github.com/user-management-system/internal/performance 8.860s
? github.com/user-management-system/internal/pkg/errors [no test files]
=== RUN TestUserRepository_Create
--- PASS: TestUserRepository_Create (0.02s)
=== RUN TestUserRepository_GetByUsername
--- PASS: TestUserRepository_GetByUsername (0.00s)
=== RUN TestUserRepository_GetByEmail
--- PASS: TestUserRepository_GetByEmail (0.00s)
=== RUN TestUserRepository_Update
--- PASS: TestUserRepository_Update (0.00s)
=== RUN TestUserRepository_Delete
--- PASS: TestUserRepository_Delete (0.00s)
=== RUN TestUserRepository_ExistsBy
--- PASS: TestUserRepository_ExistsBy (0.01s)
=== RUN TestUserRepository_List
--- PASS: TestUserRepository_List (0.00s)
PASS
ok github.com/user-management-system/internal/repository 1.348s
? github.com/user-management-system/internal/response [no test files]
=== RUN TestRobustnessErrorScenarios
=== RUN TestRobustnessErrorScenarios/NullPointerProtection
--- PASS: TestRobustnessErrorScenarios (0.00s)
--- PASS: TestRobustnessErrorScenarios/NullPointerProtection (0.00s)
=== RUN TestRobustnessConcurrency
=== RUN TestRobustnessConcurrency/ConcurrentUserCreation
robustness_test.go:59: 并发创建完成,错误数: 0
=== RUN TestRobustnessConcurrency/ConcurrentLogin
robustness_test.go:84: 并发登录: 50/50 成功
=== RUN TestRobustnessConcurrency/RaceConditionTest
robustness_test.go:111: 竞态条件测试完成, username: user8
--- PASS: TestRobustnessConcurrency (0.00s)
--- PASS: TestRobustnessConcurrency/ConcurrentUserCreation (0.00s)
--- PASS: TestRobustnessConcurrency/ConcurrentLogin (0.00s)
--- PASS: TestRobustnessConcurrency/RaceConditionTest (0.00s)
=== RUN TestRobustnessResourceLimits
=== RUN TestRobustnessResourceLimits/RateLimiting
robustness_test.go:133: 限流测试: 10 成功, 90 失败
--- PASS: TestRobustnessResourceLimits (0.00s)
--- PASS: TestRobustnessResourceLimits/RateLimiting (0.00s)
=== RUN TestRobustnessFaultTolerance
=== RUN TestRobustnessFaultTolerance/CacheFailureFallback
robustness_test.go:153: 从数据库获取用户成功: 1
=== RUN TestRobustnessFaultTolerance/RetryMechanism
robustness_test.go:175: 重试 3 次后成功
=== RUN TestRobustnessFaultTolerance/CircuitBreaker
--- PASS: TestRobustnessFaultTolerance (6.30s)
--- PASS: TestRobustnessFaultTolerance/CacheFailureFallback (0.00s)
--- PASS: TestRobustnessFaultTolerance/RetryMechanism (0.30s)
--- PASS: TestRobustnessFaultTolerance/CircuitBreaker (6.00s)
=== RUN TestStressScenarios
=== RUN TestStressScenarios/HighConcurrentRequests
robustness_test.go:225: 处理 1000 个并发请求耗时: 16.0389ms
robustness_test.go:226: 平均每个请求: 16.038µs
--- PASS: TestStressScenarios (0.02s)
--- PASS: TestStressScenarios/HighConcurrentRequests (0.02s)
PASS
ok github.com/user-management-system/internal/robustness 8.780s
=== RUN TestIPFilter_BlacklistBasic
ip_filter_test.go:32: 正确封禁reason=测试封禁
--- PASS: TestIPFilter_BlacklistBasic (0.00s)
=== RUN TestIPFilter_BlacklistExpiry
ip_filter_test.go:55: 过期解封正常
--- PASS: TestIPFilter_BlacklistExpiry (0.10s)
=== RUN TestIPFilter_WhitelistOverridesBlacklist
ip_filter_test.go:69: 白名单优先级验证通过
--- PASS: TestIPFilter_WhitelistOverridesBlacklist (0.00s)
=== RUN TestIPFilter_CIDRMatch
--- PASS: TestIPFilter_CIDRMatch (0.00s)
=== RUN TestIPFilter_InvalidIP
ip_filter_test.go:104: 无效 IP 错误: 无效的 IP 或 CIDR 格式: not-an-ip
--- PASS: TestIPFilter_InvalidIP (0.00s)
=== RUN TestIPFilter_RemoveFromBlacklist
--- PASS: TestIPFilter_RemoveFromBlacklist (0.00s)
=== RUN TestAnomalyDetector_BruteForce
ip_filter_test.go:154: 暴力破解检测正常触发
ip_filter_test.go:161: IP 自动封禁验证通过
--- PASS: TestAnomalyDetector_BruteForce (0.00s)
=== RUN TestAnomalyDetector_MultipleIPs
ip_filter_test.go:194: 多 IP 检测正常触发
--- PASS: TestAnomalyDetector_MultipleIPs (0.00s)
=== RUN TestAnomalyDetector_GetRecentLogins
--- PASS: TestAnomalyDetector_GetRecentLogins (0.00s)
=== RUN TestValidateIPOrCIDR
--- PASS: TestValidateIPOrCIDR (0.00s)
PASS
ok github.com/user-management-system/internal/security 2.786s
=== RUN TestValidatePasswordStrength_TooShort
--- PASS: TestValidatePasswordStrength_TooShort (0.00s)
=== RUN TestValidatePasswordStrength_OnlyLowercase
--- PASS: TestValidatePasswordStrength_OnlyLowercase (0.00s)
=== RUN TestValidatePasswordStrength_LowerAndDigit
--- PASS: TestValidatePasswordStrength_LowerAndDigit (0.00s)
=== RUN TestValidatePasswordStrength_StrictMode_MissingUpper
--- PASS: TestValidatePasswordStrength_StrictMode_MissingUpper (0.00s)
=== RUN TestValidatePasswordStrength_StrictMode_MissingDigit
--- PASS: TestValidatePasswordStrength_StrictMode_MissingDigit (0.00s)
=== RUN TestValidatePasswordStrength_StrictMode_Valid
--- PASS: TestValidatePasswordStrength_StrictMode_Valid (0.00s)
=== RUN TestValidatePasswordStrength_ExactMinLen
--- PASS: TestValidatePasswordStrength_ExactMinLen (0.00s)
=== RUN TestGetPasswordStrength_Scoring
--- PASS: TestGetPasswordStrength_Scoring (0.00s)
=== RUN TestGetPasswordStrength_WeakPassword
--- PASS: TestGetPasswordStrength_WeakPassword (0.00s)
=== RUN TestRegister_WeakPassword_TooShort
--- PASS: TestRegister_WeakPassword_TooShort (0.00s)
=== RUN TestRegister_WeakPassword_SingleCharType
--- PASS: TestRegister_WeakPassword_SingleCharType (0.00s)
=== RUN TestRegister_StrongPassword_Accepted
--- PASS: TestRegister_StrongPassword_Accepted (0.07s)
=== RUN TestLogin_LockAfterMaxAttempts
--- PASS: TestLogin_LockAfterMaxAttempts (0.27s)
=== RUN TestLogin_SuccessAfterCorrectPassword_ClearsAttempts
--- PASS: TestLogin_SuccessAfterCorrectPassword_ClearsAttempts (0.27s)
=== RUN TestLogin_ByEmail
--- PASS: TestLogin_ByEmail (0.14s)
=== RUN TestLogin_ByPhone
--- PASS: TestLogin_ByPhone (0.13s)
=== RUN TestRefreshToken_Success
--- PASS: TestRefreshToken_Success (0.14s)
=== RUN TestRefreshToken_InvalidToken
--- PASS: TestRefreshToken_InvalidToken (0.00s)
=== RUN TestLogout_BlacklistsToken
--- PASS: TestLogout_BlacklistsToken (0.13s)
=== RUN TestIsTokenBlacklisted_EmptyJTI
--- PASS: TestIsTokenBlacklisted_EmptyJTI (0.00s)
=== RUN TestGetUserInfo_Success
--- PASS: TestGetUserInfo_Success (0.07s)
=== RUN TestGetUserInfo_NotFound
--- PASS: TestGetUserInfo_NotFound (0.00s)
=== RUN TestRegister_Success
--- PASS: TestRegister_Success (0.07s)
=== RUN TestRegister_DuplicateUsername
--- PASS: TestRegister_DuplicateUsername (0.07s)
=== RUN TestRegister_DuplicateEmail
--- PASS: TestRegister_DuplicateEmail (0.07s)
=== RUN TestLogin_Success
--- PASS: TestLogin_Success (0.14s)
=== RUN TestLogin_WrongPassword
--- PASS: TestLogin_WrongPassword (0.14s)
=== RUN TestLogin_UserNotFound
--- PASS: TestLogin_UserNotFound (0.00s)
=== RUN TestLogin_DisabledUser
--- PASS: TestLogin_DisabledUser (0.07s)
=== RUN TestCaptchaService_Generate
--- PASS: TestCaptchaService_Generate (0.00s)
=== RUN TestCaptchaService_Verify_WrongAnswer
--- PASS: TestCaptchaService_Verify_WrongAnswer (0.00s)
=== RUN TestCaptchaService_Verify_EmptyInputs
--- PASS: TestCaptchaService_Verify_EmptyInputs (0.00s)
=== RUN TestCaptchaService_ValidateCaptcha_EmptyID
--- PASS: TestCaptchaService_ValidateCaptcha_EmptyID (0.00s)
=== RUN TestCaptchaService_Generate_UniqueIDs
--- PASS: TestCaptchaService_Generate_UniqueIDs (0.02s)
=== RUN TestDeviceService_CreateAndList
--- PASS: TestDeviceService_CreateAndList (0.01s)
=== RUN TestDeviceService_DeleteDevice
--- PASS: TestDeviceService_DeleteDevice (0.00s)
=== RUN TestDeviceService_UpdateDeviceStatus
--- PASS: TestDeviceService_UpdateDeviceStatus (0.00s)
=== RUN TestLoginLogService_RecordAndList
--- PASS: TestLoginLogService_RecordAndList (0.00s)
=== RUN TestLoginLogService_RecordFailedLogin
--- PASS: TestLoginLogService_RecordFailedLogin (0.00s)
=== RUN TestOperationLogService_RecordAndList
--- PASS: TestOperationLogService_RecordAndList (0.00s)
=== RUN TestPermissionService_CreateAndList
--- PASS: TestPermissionService_CreateAndList (0.00s)
=== RUN TestPermissionService_DuplicateCode
--- PASS: TestPermissionService_DuplicateCode (0.00s)
=== RUN TestPermissionService_GetAndUpdate
--- PASS: TestPermissionService_GetAndUpdate (0.00s)
=== RUN TestPermissionService_Delete
--- PASS: TestPermissionService_Delete (0.00s)
=== RUN TestRoleService_CreateAndGet
--- PASS: TestRoleService_CreateAndGet (0.00s)
=== RUN TestRoleService_DuplicateCode
--- PASS: TestRoleService_DuplicateCode (0.01s)
=== RUN TestRoleService_ListRoles
--- PASS: TestRoleService_ListRoles (0.00s)
=== RUN TestRoleService_UpdateRole
--- PASS: TestRoleService_UpdateRole (0.00s)
=== RUN TestRoleService_DeleteRole
--- PASS: TestRoleService_DeleteRole (0.00s)
=== RUN TestTOTPManager_GenerateSecret
--- PASS: TestTOTPManager_GenerateSecret (0.01s)
=== RUN TestTOTPManager_Verify_ValidCode
--- PASS: TestTOTPManager_Verify_ValidCode (0.01s)
=== RUN TestTOTPManager_Verify_InvalidCode
--- PASS: TestTOTPManager_Verify_InvalidCode (0.01s)
=== RUN TestTOTPService_GetTOTPStatus_Disabled
--- PASS: TestTOTPService_GetTOTPStatus_Disabled (0.00s)
=== RUN TestTOTPService_GetTOTPStatus_Enabled
--- PASS: TestTOTPService_GetTOTPStatus_Enabled (0.00s)
=== RUN TestTOTPManager_RecoveryCodesFormat
--- PASS: TestTOTPManager_RecoveryCodesFormat (0.01s)
=== RUN TestValidateRecoveryCode
--- PASS: TestValidateRecoveryCode (0.00s)
=== RUN TestUserRepo_GetUser_NotFound
--- PASS: TestUserRepo_GetUser_NotFound (0.00s)
=== RUN TestUserRepo_EmailConflictDetection
--- PASS: TestUserRepo_EmailConflictDetection (0.00s)
=== RUN TestUserRepo_DeleteUser
--- PASS: TestUserRepo_DeleteUser (0.00s)
=== RUN TestUserRepo_UpdateStatus
--- PASS: TestUserRepo_UpdateStatus (0.00s)
=== RUN TestUserRepo_List_Pagination
--- PASS: TestUserRepo_List_Pagination (0.00s)
=== RUN TestUserRepo_ListByStatus
--- PASS: TestUserRepo_ListByStatus (0.00s)
=== RUN TestUserService_GetUser_NotFound
--- PASS: TestUserService_GetUser_NotFound (0.00s)
=== RUN TestUserService_UpdateUser_Nickname
--- PASS: TestUserService_UpdateUser_Nickname (0.07s)
=== RUN TestUserService_UpdateUser_EmailConflict
--- PASS: TestUserService_UpdateUser_EmailConflict (0.07s)
=== RUN TestUserService_UpdateUser_Birthday
--- PASS: TestUserService_UpdateUser_Birthday (0.07s)
=== RUN TestUserService_UpdatePassword_Success
--- PASS: TestUserService_UpdatePassword_Success (0.35s)
=== RUN TestUserService_UpdatePassword_WrongOld
--- PASS: TestUserService_UpdatePassword_WrongOld (0.15s)
=== RUN TestUserService_UpdatePassword_SameAsOld
--- PASS: TestUserService_UpdatePassword_SameAsOld (0.21s)
=== RUN TestUserService_UpdatePassword_WeakNew
--- PASS: TestUserService_UpdatePassword_WeakNew (0.14s)
=== RUN TestUserService_ListUsers_All
--- PASS: TestUserService_ListUsers_All (0.07s)
=== RUN TestUserService_ListUsers_Pagination
--- PASS: TestUserService_ListUsers_Pagination (0.08s)
=== RUN TestUserService_ListUsers_FilterByStatus
--- PASS: TestUserService_ListUsers_FilterByStatus (0.08s)
=== RUN TestUserService_UpdateUserStatus
--- PASS: TestUserService_UpdateUserStatus (0.07s)
=== RUN TestWebhookService_CreateAndList
--- PASS: TestWebhookService_CreateAndList (0.00s)
=== RUN TestWebhookService_Update
--- PASS: TestWebhookService_Update (0.00s)
=== RUN TestWebhookService_Delete
--- PASS: TestWebhookService_Delete (0.00s)
=== RUN TestWebhookService_Publish_DeliveryRecord
--- PASS: TestWebhookService_Publish_DeliveryRecord (0.01s)
=== RUN TestWebhookSubscribesTo
--- PASS: TestWebhookSubscribesTo (0.00s)
PASS
ok github.com/user-management-system/internal/service 3.474s
=== RUN TestOpen_WorksWithModernc
--- PASS: TestOpen_WorksWithModernc (0.01s)
PASS
ok github.com/user-management-system/internal/testdb 4.183s
? github.com/user-management-system/pkg/errors [no test files]
? github.com/user-management-system/pkg/response [no test files]