The Status() handler was only checking if the CrowdSec process was running, not if LAPI was actually responding. This caused the CrowdSecConfig page to always show "LAPI is initializing" even when LAPI was fully operational. Changes: - Backend: Add lapi_ready field to /admin/crowdsec/status response - Frontend: Add CrowdSecStatus TypeScript interface - Frontend: Update conditional logic to check lapi_ready not running - Frontend: Separate warnings for "initializing" vs "not running" - Tests: Add unit tests for Status handler LAPI check Fixes regression from crowdsec_lapi_error_diagnostic.md fixes.
3.8 KiB
3.8 KiB
QA Report: CrowdSec LAPI Status Fix
Date: December 14, 2025 Agent: QA_Security Issue: CrowdSec LAPI status field was incorrectly handled, causing UI to not display proper status
Changes Tested
- Backend:
backend/internal/api/handlers/crowdsec_handler.go- Status() now returnslapi_readyfield - Frontend:
frontend/src/api/crowdsec.ts- Added CrowdSecStatus interface - Frontend:
frontend/src/pages/CrowdSecConfig.tsx- Updated conditionals to uselapi_ready - Test mocks: Updated to support new
lapi_readyfield
Test Results Summary
| Check | Status | Details |
|---|---|---|
| Backend Build | ✅ PASSED | go build ./... completed successfully |
| Backend Tests | ✅ PASSED | All 20 packages pass |
| Backend Lint (go vet) | ✅ PASSED | No issues found |
| Frontend Type Check | ✅ PASSED | TypeScript compilation successful |
| Frontend Lint | ✅ PASSED | 0 errors, 6 warnings (acceptable) |
| Frontend Tests | ✅ PASSED | 799 passed, 2 skipped |
| Pre-commit | ✅ PASSED | All hooks pass |
Detailed Results
Backend Build
✅ go build ./... - SUCCESS
Backend Tests
ok github.com/Wikid82/charon/backend/cmd/api
ok github.com/Wikid82/charon/backend/cmd/seed
ok github.com/Wikid82/charon/backend/internal/api/handlers
ok github.com/Wikid82/charon/backend/internal/api/middleware
ok github.com/Wikid82/charon/backend/internal/api/routes
ok github.com/Wikid82/charon/backend/internal/api/tests
ok github.com/Wikid82/charon/backend/internal/caddy
ok github.com/Wikid82/charon/backend/internal/cerberus
ok github.com/Wikid82/charon/backend/internal/config
ok github.com/Wikid82/charon/backend/internal/crowdsec
ok github.com/Wikid82/charon/backend/internal/database
ok github.com/Wikid82/charon/backend/internal/logger
ok github.com/Wikid82/charon/backend/internal/metrics
ok github.com/Wikid82/charon/backend/internal/models
ok github.com/Wikid82/charon/backend/internal/server
ok github.com/Wikid82/charon/backend/internal/services
ok github.com/Wikid82/charon/backend/internal/util
ok github.com/Wikid82/charon/backend/internal/version
Coverage: 85.2% (minimum required 85%)
Backend Lint
✅ go vet ./... - No issues
Frontend Type Check
✅ tsc --noEmit - SUCCESS
Frontend Lint
6 warnings (0 errors):
- 1x unused variable in e2e test
- 2x missing useEffect dependencies (existing, unrelated)
- 3x @typescript-eslint/no-explicit-any in test files
Note: All warnings are acceptable and unrelated to the LAPI fix
Frontend Tests
Test Files 87 passed (87)
Tests 799 passed | 2 skipped (801)
Duration 63.65s
Key test suites verified:
- src/api/__tests__/crowdsec.test.ts (9 tests) ✅
- src/pages/__tests__/CrowdSecConfig.test.tsx (3 tests) ✅
- src/pages/__tests__/Security.spec.tsx (6 tests) ✅
- src/pages/__tests__/Security.test.tsx (18 tests) ✅
- src/pages/__tests__/Security.dashboard.test.tsx (18 tests) ✅
Pre-commit Hooks
✅ Go Vet - Passed
✅ Check .version matches latest Git tag - Passed
✅ Prevent large files that are not tracked by LFS - Passed
✅ Prevent committing CodeQL DB artifacts - Passed
✅ Prevent committing data/backups files - Passed
✅ Frontend TypeScript Check - Passed
✅ Frontend Lint (Fix) - Passed
Conclusion
All quality gates have passed. The CrowdSec LAPI status fix has been comprehensively tested and is ready for merge.
Summary of Changes Verified
- Backend correctly returns
lapi_readyboolean field in CrowdSec status response - Frontend
CrowdSecStatusinterface properly types the response - UI conditionals correctly use
lapi_readyfor status display logic - All existing tests pass with updated mocks
- No regressions detected in related security features
Report generated by QA_Security agent