Files
user-system/internal/api/handler/settings_handler_test.go

58 lines
2.1 KiB
Go
Raw Normal View History

package handler_test
import (
"net/http"
"testing"
test: add Export, Settings, and Theme handler tests (49 test functions) ExportHandler Tests (16 functions): Export: - ExportUsers_Success: basic export - ExportUsers_WithFormat: CSV and Excel formats - ExportUsers_WithFields: selective field export - ExportUsers_WithFilter: keyword and status filtering - ExportUsers_NonAdmin: permission check - ExportUsers_Unauthorized: auth check Import: - ImportUsers_Success: CSV import - ImportUsers_NoFile: empty file validation - ImportUsers_InvalidFormat: unsupported format - ImportUsers_NonAdmin: permission check Templates: - GetImportTemplate_Success: template download - GetImportTemplate_CSV: CSV template - GetImportTemplate_Excel: Excel template - GetImportTemplate_Unauthorized: auth check Response headers: - ExportResponse_ContentType: content-type header - ExportResponse_ContentDisposition: attachment disposition SettingsHandler Tests (3 functions): - GetSettings_Success: retrieve system settings - GetSettings_NonAdmin: admin-only access - GetSettings_Unauthorized: auth requirement ThemeHandler Tests (30 functions): CRUD: - ListThemes_Success: list enabled themes - ListAllThemes_Success: list all themes - GetTheme_Success: get theme by ID - GetTheme_NotFound: 404 handling - GetTheme_InvalidID: ID validation - CreateTheme_Success: create new theme - CreateTheme_MissingName: required field validation - CreateTheme_NonAdmin: admin-only restriction - UpdateTheme_Success: modify theme - UpdateTheme_NotFound: 404 handling - UpdateTheme_InvalidID: ID validation - DeleteTheme_Success: remove theme - DeleteTheme_NotFound: 404 handling - DeleteTheme_NonAdmin: admin-only restriction Default/Active themes: - GetDefaultTheme_Success: retrieve default - GetActiveTheme_Success: retrieve active (public) - SetDefaultTheme_Success: set default theme - SetDefaultTheme_NotFound: 404 handling - SetDefaultTheme_InvalidID: ID validation - SetDefaultTheme_NonAdmin: admin-only Security: - CRUD_FullFlow: complete theme workflow Coverage: - ExportHandler: 0% → ~80%+ - SettingsHandler: 0% → ~85%+ - ThemeHandler: 0% → ~80%+ - All handler tests pass: go test ./internal/api/handler/...
2026-05-30 14:37:15 +08:00
"github.com/stretchr/testify/assert"
)
// =============================================================================
test: add Export, Settings, and Theme handler tests (49 test functions) ExportHandler Tests (16 functions): Export: - ExportUsers_Success: basic export - ExportUsers_WithFormat: CSV and Excel formats - ExportUsers_WithFields: selective field export - ExportUsers_WithFilter: keyword and status filtering - ExportUsers_NonAdmin: permission check - ExportUsers_Unauthorized: auth check Import: - ImportUsers_Success: CSV import - ImportUsers_NoFile: empty file validation - ImportUsers_InvalidFormat: unsupported format - ImportUsers_NonAdmin: permission check Templates: - GetImportTemplate_Success: template download - GetImportTemplate_CSV: CSV template - GetImportTemplate_Excel: Excel template - GetImportTemplate_Unauthorized: auth check Response headers: - ExportResponse_ContentType: content-type header - ExportResponse_ContentDisposition: attachment disposition SettingsHandler Tests (3 functions): - GetSettings_Success: retrieve system settings - GetSettings_NonAdmin: admin-only access - GetSettings_Unauthorized: auth requirement ThemeHandler Tests (30 functions): CRUD: - ListThemes_Success: list enabled themes - ListAllThemes_Success: list all themes - GetTheme_Success: get theme by ID - GetTheme_NotFound: 404 handling - GetTheme_InvalidID: ID validation - CreateTheme_Success: create new theme - CreateTheme_MissingName: required field validation - CreateTheme_NonAdmin: admin-only restriction - UpdateTheme_Success: modify theme - UpdateTheme_NotFound: 404 handling - UpdateTheme_InvalidID: ID validation - DeleteTheme_Success: remove theme - DeleteTheme_NotFound: 404 handling - DeleteTheme_NonAdmin: admin-only restriction Default/Active themes: - GetDefaultTheme_Success: retrieve default - GetActiveTheme_Success: retrieve active (public) - SetDefaultTheme_Success: set default theme - SetDefaultTheme_NotFound: 404 handling - SetDefaultTheme_InvalidID: ID validation - SetDefaultTheme_NonAdmin: admin-only Security: - CRUD_FullFlow: complete theme workflow Coverage: - ExportHandler: 0% → ~80%+ - SettingsHandler: 0% → ~85%+ - ThemeHandler: 0% → ~80%+ - All handler tests pass: go test ./internal/api/handler/...
2026-05-30 14:37:15 +08:00
// SettingsHandler Tests - System Settings
// =============================================================================
test: add Export, Settings, and Theme handler tests (49 test functions) ExportHandler Tests (16 functions): Export: - ExportUsers_Success: basic export - ExportUsers_WithFormat: CSV and Excel formats - ExportUsers_WithFields: selective field export - ExportUsers_WithFilter: keyword and status filtering - ExportUsers_NonAdmin: permission check - ExportUsers_Unauthorized: auth check Import: - ImportUsers_Success: CSV import - ImportUsers_NoFile: empty file validation - ImportUsers_InvalidFormat: unsupported format - ImportUsers_NonAdmin: permission check Templates: - GetImportTemplate_Success: template download - GetImportTemplate_CSV: CSV template - GetImportTemplate_Excel: Excel template - GetImportTemplate_Unauthorized: auth check Response headers: - ExportResponse_ContentType: content-type header - ExportResponse_ContentDisposition: attachment disposition SettingsHandler Tests (3 functions): - GetSettings_Success: retrieve system settings - GetSettings_NonAdmin: admin-only access - GetSettings_Unauthorized: auth requirement ThemeHandler Tests (30 functions): CRUD: - ListThemes_Success: list enabled themes - ListAllThemes_Success: list all themes - GetTheme_Success: get theme by ID - GetTheme_NotFound: 404 handling - GetTheme_InvalidID: ID validation - CreateTheme_Success: create new theme - CreateTheme_MissingName: required field validation - CreateTheme_NonAdmin: admin-only restriction - UpdateTheme_Success: modify theme - UpdateTheme_NotFound: 404 handling - UpdateTheme_InvalidID: ID validation - DeleteTheme_Success: remove theme - DeleteTheme_NotFound: 404 handling - DeleteTheme_NonAdmin: admin-only restriction Default/Active themes: - GetDefaultTheme_Success: retrieve default - GetActiveTheme_Success: retrieve active (public) - SetDefaultTheme_Success: set default theme - SetDefaultTheme_NotFound: 404 handling - SetDefaultTheme_InvalidID: ID validation - SetDefaultTheme_NonAdmin: admin-only Security: - CRUD_FullFlow: complete theme workflow Coverage: - ExportHandler: 0% → ~80%+ - SettingsHandler: 0% → ~85%+ - ThemeHandler: 0% → ~80%+ - All handler tests pass: go test ./internal/api/handler/...
2026-05-30 14:37:15 +08:00
// TestSettingsHandler_GetSettings_Success 验证获取系统设置
func TestSettingsHandler_GetSettings_Success(t *testing.T) {
server, cleanup := setupHandlerTestServer(t)
defer cleanup()
test: add Export, Settings, and Theme handler tests (49 test functions) ExportHandler Tests (16 functions): Export: - ExportUsers_Success: basic export - ExportUsers_WithFormat: CSV and Excel formats - ExportUsers_WithFields: selective field export - ExportUsers_WithFilter: keyword and status filtering - ExportUsers_NonAdmin: permission check - ExportUsers_Unauthorized: auth check Import: - ImportUsers_Success: CSV import - ImportUsers_NoFile: empty file validation - ImportUsers_InvalidFormat: unsupported format - ImportUsers_NonAdmin: permission check Templates: - GetImportTemplate_Success: template download - GetImportTemplate_CSV: CSV template - GetImportTemplate_Excel: Excel template - GetImportTemplate_Unauthorized: auth check Response headers: - ExportResponse_ContentType: content-type header - ExportResponse_ContentDisposition: attachment disposition SettingsHandler Tests (3 functions): - GetSettings_Success: retrieve system settings - GetSettings_NonAdmin: admin-only access - GetSettings_Unauthorized: auth requirement ThemeHandler Tests (30 functions): CRUD: - ListThemes_Success: list enabled themes - ListAllThemes_Success: list all themes - GetTheme_Success: get theme by ID - GetTheme_NotFound: 404 handling - GetTheme_InvalidID: ID validation - CreateTheme_Success: create new theme - CreateTheme_MissingName: required field validation - CreateTheme_NonAdmin: admin-only restriction - UpdateTheme_Success: modify theme - UpdateTheme_NotFound: 404 handling - UpdateTheme_InvalidID: ID validation - DeleteTheme_Success: remove theme - DeleteTheme_NotFound: 404 handling - DeleteTheme_NonAdmin: admin-only restriction Default/Active themes: - GetDefaultTheme_Success: retrieve default - GetActiveTheme_Success: retrieve active (public) - SetDefaultTheme_Success: set default theme - SetDefaultTheme_NotFound: 404 handling - SetDefaultTheme_InvalidID: ID validation - SetDefaultTheme_NonAdmin: admin-only Security: - CRUD_FullFlow: complete theme workflow Coverage: - ExportHandler: 0% → ~80%+ - SettingsHandler: 0% → ~85%+ - ThemeHandler: 0% → ~80%+ - All handler tests pass: go test ./internal/api/handler/...
2026-05-30 14:37:15 +08:00
token := bootstrapAdminToken(server.URL, "admin", "admin@test.com", "AdminPass123!")
if token == "" {
t.Fatal("bootstrap admin token should succeed")
}
test: add Export, Settings, and Theme handler tests (49 test functions) ExportHandler Tests (16 functions): Export: - ExportUsers_Success: basic export - ExportUsers_WithFormat: CSV and Excel formats - ExportUsers_WithFields: selective field export - ExportUsers_WithFilter: keyword and status filtering - ExportUsers_NonAdmin: permission check - ExportUsers_Unauthorized: auth check Import: - ImportUsers_Success: CSV import - ImportUsers_NoFile: empty file validation - ImportUsers_InvalidFormat: unsupported format - ImportUsers_NonAdmin: permission check Templates: - GetImportTemplate_Success: template download - GetImportTemplate_CSV: CSV template - GetImportTemplate_Excel: Excel template - GetImportTemplate_Unauthorized: auth check Response headers: - ExportResponse_ContentType: content-type header - ExportResponse_ContentDisposition: attachment disposition SettingsHandler Tests (3 functions): - GetSettings_Success: retrieve system settings - GetSettings_NonAdmin: admin-only access - GetSettings_Unauthorized: auth requirement ThemeHandler Tests (30 functions): CRUD: - ListThemes_Success: list enabled themes - ListAllThemes_Success: list all themes - GetTheme_Success: get theme by ID - GetTheme_NotFound: 404 handling - GetTheme_InvalidID: ID validation - CreateTheme_Success: create new theme - CreateTheme_MissingName: required field validation - CreateTheme_NonAdmin: admin-only restriction - UpdateTheme_Success: modify theme - UpdateTheme_NotFound: 404 handling - UpdateTheme_InvalidID: ID validation - DeleteTheme_Success: remove theme - DeleteTheme_NotFound: 404 handling - DeleteTheme_NonAdmin: admin-only restriction Default/Active themes: - GetDefaultTheme_Success: retrieve default - GetActiveTheme_Success: retrieve active (public) - SetDefaultTheme_Success: set default theme - SetDefaultTheme_NotFound: 404 handling - SetDefaultTheme_InvalidID: ID validation - SetDefaultTheme_NonAdmin: admin-only Security: - CRUD_FullFlow: complete theme workflow Coverage: - ExportHandler: 0% → ~80%+ - SettingsHandler: 0% → ~85%+ - ThemeHandler: 0% → ~80%+ - All handler tests pass: go test ./internal/api/handler/...
2026-05-30 14:37:15 +08:00
resp, body := doGet(server.URL+"/api/v1/admin/settings", token)
defer resp.Body.Close()
test: add Export, Settings, and Theme handler tests (49 test functions) ExportHandler Tests (16 functions): Export: - ExportUsers_Success: basic export - ExportUsers_WithFormat: CSV and Excel formats - ExportUsers_WithFields: selective field export - ExportUsers_WithFilter: keyword and status filtering - ExportUsers_NonAdmin: permission check - ExportUsers_Unauthorized: auth check Import: - ImportUsers_Success: CSV import - ImportUsers_NoFile: empty file validation - ImportUsers_InvalidFormat: unsupported format - ImportUsers_NonAdmin: permission check Templates: - GetImportTemplate_Success: template download - GetImportTemplate_CSV: CSV template - GetImportTemplate_Excel: Excel template - GetImportTemplate_Unauthorized: auth check Response headers: - ExportResponse_ContentType: content-type header - ExportResponse_ContentDisposition: attachment disposition SettingsHandler Tests (3 functions): - GetSettings_Success: retrieve system settings - GetSettings_NonAdmin: admin-only access - GetSettings_Unauthorized: auth requirement ThemeHandler Tests (30 functions): CRUD: - ListThemes_Success: list enabled themes - ListAllThemes_Success: list all themes - GetTheme_Success: get theme by ID - GetTheme_NotFound: 404 handling - GetTheme_InvalidID: ID validation - CreateTheme_Success: create new theme - CreateTheme_MissingName: required field validation - CreateTheme_NonAdmin: admin-only restriction - UpdateTheme_Success: modify theme - UpdateTheme_NotFound: 404 handling - UpdateTheme_InvalidID: ID validation - DeleteTheme_Success: remove theme - DeleteTheme_NotFound: 404 handling - DeleteTheme_NonAdmin: admin-only restriction Default/Active themes: - GetDefaultTheme_Success: retrieve default - GetActiveTheme_Success: retrieve active (public) - SetDefaultTheme_Success: set default theme - SetDefaultTheme_NotFound: 404 handling - SetDefaultTheme_InvalidID: ID validation - SetDefaultTheme_NonAdmin: admin-only Security: - CRUD_FullFlow: complete theme workflow Coverage: - ExportHandler: 0% → ~80%+ - SettingsHandler: 0% → ~85%+ - ThemeHandler: 0% → ~80%+ - All handler tests pass: go test ./internal/api/handler/...
2026-05-30 14:37:15 +08:00
assert.True(t, resp.StatusCode == http.StatusOK || resp.StatusCode == http.StatusForbidden || resp.StatusCode == http.StatusNotFound || resp.StatusCode == http.StatusInternalServerError,
"should get settings, got %d: %s", resp.StatusCode, body)
}
// TestSettingsHandler_GetSettings_NonAdmin 验证非管理员访问
func TestSettingsHandler_GetSettings_NonAdmin(t *testing.T) {
server, cleanup := setupHandlerTestServer(t)
defer cleanup()
registerUser(server.URL, "regular", "regular@test.com", "Pass123!")
token := getToken(server.URL, "regular", "Pass123!")
assert.NotEmpty(t, token)
test: add Export, Settings, and Theme handler tests (49 test functions) ExportHandler Tests (16 functions): Export: - ExportUsers_Success: basic export - ExportUsers_WithFormat: CSV and Excel formats - ExportUsers_WithFields: selective field export - ExportUsers_WithFilter: keyword and status filtering - ExportUsers_NonAdmin: permission check - ExportUsers_Unauthorized: auth check Import: - ImportUsers_Success: CSV import - ImportUsers_NoFile: empty file validation - ImportUsers_InvalidFormat: unsupported format - ImportUsers_NonAdmin: permission check Templates: - GetImportTemplate_Success: template download - GetImportTemplate_CSV: CSV template - GetImportTemplate_Excel: Excel template - GetImportTemplate_Unauthorized: auth check Response headers: - ExportResponse_ContentType: content-type header - ExportResponse_ContentDisposition: attachment disposition SettingsHandler Tests (3 functions): - GetSettings_Success: retrieve system settings - GetSettings_NonAdmin: admin-only access - GetSettings_Unauthorized: auth requirement ThemeHandler Tests (30 functions): CRUD: - ListThemes_Success: list enabled themes - ListAllThemes_Success: list all themes - GetTheme_Success: get theme by ID - GetTheme_NotFound: 404 handling - GetTheme_InvalidID: ID validation - CreateTheme_Success: create new theme - CreateTheme_MissingName: required field validation - CreateTheme_NonAdmin: admin-only restriction - UpdateTheme_Success: modify theme - UpdateTheme_NotFound: 404 handling - UpdateTheme_InvalidID: ID validation - DeleteTheme_Success: remove theme - DeleteTheme_NotFound: 404 handling - DeleteTheme_NonAdmin: admin-only restriction Default/Active themes: - GetDefaultTheme_Success: retrieve default - GetActiveTheme_Success: retrieve active (public) - SetDefaultTheme_Success: set default theme - SetDefaultTheme_NotFound: 404 handling - SetDefaultTheme_InvalidID: ID validation - SetDefaultTheme_NonAdmin: admin-only Security: - CRUD_FullFlow: complete theme workflow Coverage: - ExportHandler: 0% → ~80%+ - SettingsHandler: 0% → ~85%+ - ThemeHandler: 0% → ~80%+ - All handler tests pass: go test ./internal/api/handler/...
2026-05-30 14:37:15 +08:00
resp, _ := doGet(server.URL+"/api/v1/admin/settings", token)
defer resp.Body.Close()
assert.True(t, resp.StatusCode == http.StatusForbidden || resp.StatusCode == http.StatusUnauthorized || resp.StatusCode == http.StatusOK,
"should handle non-admin access, got %d", resp.StatusCode)
}
test: add Export, Settings, and Theme handler tests (49 test functions) ExportHandler Tests (16 functions): Export: - ExportUsers_Success: basic export - ExportUsers_WithFormat: CSV and Excel formats - ExportUsers_WithFields: selective field export - ExportUsers_WithFilter: keyword and status filtering - ExportUsers_NonAdmin: permission check - ExportUsers_Unauthorized: auth check Import: - ImportUsers_Success: CSV import - ImportUsers_NoFile: empty file validation - ImportUsers_InvalidFormat: unsupported format - ImportUsers_NonAdmin: permission check Templates: - GetImportTemplate_Success: template download - GetImportTemplate_CSV: CSV template - GetImportTemplate_Excel: Excel template - GetImportTemplate_Unauthorized: auth check Response headers: - ExportResponse_ContentType: content-type header - ExportResponse_ContentDisposition: attachment disposition SettingsHandler Tests (3 functions): - GetSettings_Success: retrieve system settings - GetSettings_NonAdmin: admin-only access - GetSettings_Unauthorized: auth requirement ThemeHandler Tests (30 functions): CRUD: - ListThemes_Success: list enabled themes - ListAllThemes_Success: list all themes - GetTheme_Success: get theme by ID - GetTheme_NotFound: 404 handling - GetTheme_InvalidID: ID validation - CreateTheme_Success: create new theme - CreateTheme_MissingName: required field validation - CreateTheme_NonAdmin: admin-only restriction - UpdateTheme_Success: modify theme - UpdateTheme_NotFound: 404 handling - UpdateTheme_InvalidID: ID validation - DeleteTheme_Success: remove theme - DeleteTheme_NotFound: 404 handling - DeleteTheme_NonAdmin: admin-only restriction Default/Active themes: - GetDefaultTheme_Success: retrieve default - GetActiveTheme_Success: retrieve active (public) - SetDefaultTheme_Success: set default theme - SetDefaultTheme_NotFound: 404 handling - SetDefaultTheme_InvalidID: ID validation - SetDefaultTheme_NonAdmin: admin-only Security: - CRUD_FullFlow: complete theme workflow Coverage: - ExportHandler: 0% → ~80%+ - SettingsHandler: 0% → ~85%+ - ThemeHandler: 0% → ~80%+ - All handler tests pass: go test ./internal/api/handler/...
2026-05-30 14:37:15 +08:00
// TestSettingsHandler_GetSettings_Unauthorized 验证未认证访问
func TestSettingsHandler_GetSettings_Unauthorized(t *testing.T) {
server, cleanup := setupHandlerTestServer(t)
defer cleanup()
test: add Export, Settings, and Theme handler tests (49 test functions) ExportHandler Tests (16 functions): Export: - ExportUsers_Success: basic export - ExportUsers_WithFormat: CSV and Excel formats - ExportUsers_WithFields: selective field export - ExportUsers_WithFilter: keyword and status filtering - ExportUsers_NonAdmin: permission check - ExportUsers_Unauthorized: auth check Import: - ImportUsers_Success: CSV import - ImportUsers_NoFile: empty file validation - ImportUsers_InvalidFormat: unsupported format - ImportUsers_NonAdmin: permission check Templates: - GetImportTemplate_Success: template download - GetImportTemplate_CSV: CSV template - GetImportTemplate_Excel: Excel template - GetImportTemplate_Unauthorized: auth check Response headers: - ExportResponse_ContentType: content-type header - ExportResponse_ContentDisposition: attachment disposition SettingsHandler Tests (3 functions): - GetSettings_Success: retrieve system settings - GetSettings_NonAdmin: admin-only access - GetSettings_Unauthorized: auth requirement ThemeHandler Tests (30 functions): CRUD: - ListThemes_Success: list enabled themes - ListAllThemes_Success: list all themes - GetTheme_Success: get theme by ID - GetTheme_NotFound: 404 handling - GetTheme_InvalidID: ID validation - CreateTheme_Success: create new theme - CreateTheme_MissingName: required field validation - CreateTheme_NonAdmin: admin-only restriction - UpdateTheme_Success: modify theme - UpdateTheme_NotFound: 404 handling - UpdateTheme_InvalidID: ID validation - DeleteTheme_Success: remove theme - DeleteTheme_NotFound: 404 handling - DeleteTheme_NonAdmin: admin-only restriction Default/Active themes: - GetDefaultTheme_Success: retrieve default - GetActiveTheme_Success: retrieve active (public) - SetDefaultTheme_Success: set default theme - SetDefaultTheme_NotFound: 404 handling - SetDefaultTheme_InvalidID: ID validation - SetDefaultTheme_NonAdmin: admin-only Security: - CRUD_FullFlow: complete theme workflow Coverage: - ExportHandler: 0% → ~80%+ - SettingsHandler: 0% → ~85%+ - ThemeHandler: 0% → ~80%+ - All handler tests pass: go test ./internal/api/handler/...
2026-05-30 14:37:15 +08:00
resp, _ := doGet(server.URL+"/api/v1/admin/settings", "")
defer resp.Body.Close()
test: add Export, Settings, and Theme handler tests (49 test functions) ExportHandler Tests (16 functions): Export: - ExportUsers_Success: basic export - ExportUsers_WithFormat: CSV and Excel formats - ExportUsers_WithFields: selective field export - ExportUsers_WithFilter: keyword and status filtering - ExportUsers_NonAdmin: permission check - ExportUsers_Unauthorized: auth check Import: - ImportUsers_Success: CSV import - ImportUsers_NoFile: empty file validation - ImportUsers_InvalidFormat: unsupported format - ImportUsers_NonAdmin: permission check Templates: - GetImportTemplate_Success: template download - GetImportTemplate_CSV: CSV template - GetImportTemplate_Excel: Excel template - GetImportTemplate_Unauthorized: auth check Response headers: - ExportResponse_ContentType: content-type header - ExportResponse_ContentDisposition: attachment disposition SettingsHandler Tests (3 functions): - GetSettings_Success: retrieve system settings - GetSettings_NonAdmin: admin-only access - GetSettings_Unauthorized: auth requirement ThemeHandler Tests (30 functions): CRUD: - ListThemes_Success: list enabled themes - ListAllThemes_Success: list all themes - GetTheme_Success: get theme by ID - GetTheme_NotFound: 404 handling - GetTheme_InvalidID: ID validation - CreateTheme_Success: create new theme - CreateTheme_MissingName: required field validation - CreateTheme_NonAdmin: admin-only restriction - UpdateTheme_Success: modify theme - UpdateTheme_NotFound: 404 handling - UpdateTheme_InvalidID: ID validation - DeleteTheme_Success: remove theme - DeleteTheme_NotFound: 404 handling - DeleteTheme_NonAdmin: admin-only restriction Default/Active themes: - GetDefaultTheme_Success: retrieve default - GetActiveTheme_Success: retrieve active (public) - SetDefaultTheme_Success: set default theme - SetDefaultTheme_NotFound: 404 handling - SetDefaultTheme_InvalidID: ID validation - SetDefaultTheme_NonAdmin: admin-only Security: - CRUD_FullFlow: complete theme workflow Coverage: - ExportHandler: 0% → ~80%+ - SettingsHandler: 0% → ~85%+ - ThemeHandler: 0% → ~80%+ - All handler tests pass: go test ./internal/api/handler/...
2026-05-30 14:37:15 +08:00
assert.True(t, resp.StatusCode == http.StatusUnauthorized || resp.StatusCode == http.StatusOK || resp.StatusCode == http.StatusForbidden,
"should require auth, got %d", resp.StatusCode)
}