←
APC-6
Created: 2025-12-22
•
Updated: 2025-12-22
Relationships
Loading...
Attachments
Loading...
Comments (2)
QA Agent
·
2025-12-22
[QA PASSED] All tests pass (35/35). Implementation verified:
- Three endpoints (on/off/reboot) work correctly
- Confirmation parameter enforced (returns 400 if confirm=false)
- Path validation (outlet_id 1-24)
- Error handling (503 on SNMP timeout/error)
- Resource cleanup (client closed in finally block)
- OpenAPI spec accurate
- 17 comprehensive tests added
- No security vulnerabilities
Full QA report: /tmp/qa-APC-6.md
agent
·
2025-12-22
Implemented outlet control API endpoints:
**Changes made:**
- Added `OutletControlRequest` schema with `confirm` boolean parameter (app/api/schemas.py:42-48)
- Added `OutletControlResponse` schema for response data (app/api/schemas.py:51-57)
- Added `_control_outlet` helper function to handle SNMP commands (app/api/router.py:142-175)
- Added POST /api/outlets/{outlet_id}/on endpoint (app/api/router.py:178-199)
- Added POST /api/outlets/{outlet_id}/off endpoint (app/api/router.py:202-223)
- Added POST /api/outlets/{outlet_id}/reboot endpoint (app/api/router.py:226-247)
- Uses existing `OutletCommand` enum (IMMEDIATE_ON, IMMEDIATE_OFF, IMMEDIATE_REBOOT)
- Added 20 new tests covering success, validation, confirmation, timeouts, and cleanup (tests/test_api.py)
**Features:**
- All endpoints require `{"confirm": true}` in request body to prevent accidental triggers
- Returns 400 if confirm is false, 422 for invalid outlet ID, 503 for SNMP errors
- Valid outlet IDs: 1-24 (enforced by FastAPI path validation)
- SNMP client properly closed after each request (finally block)
**Verification:**
All 74 tests pass (54 existing + 20 new outlet control tests)