Spaces:
Sleeping
Sleeping
File size: 1,274 Bytes
8760eb7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | """
Quick test to verify audit logging is working
Run this after creating/updating/deleting a task
"""
import asyncio
from src.database import get_session_dep
from src.routers.audit import router as audit_router
from src.models.audit_log import AuditLog
from sqlmodel import Session, select
async def verify_audit_logging():
"""Verify that audit logs are being saved"""
# This would need proper database setup, but serves as a reference
# In production, use: curl -X GET http://localhost:8000/api/health
pass
# Manual curl commands to test:
# 1. Check backend health
'''
curl -X GET https://tahasaif3-taskflow-app.hf.space/api/health
Expected: {"status": "healthy"}
'''
# 2. Create a test task
'''
curl -X POST https://tahasaif3-taskflow-app.hf.space/api/{user_id}/tasks/ \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"title": "Test Task",
"description": "Testing audit logging",
"completed": false
}'
'''
# 3. Fetch audit logs
'''
curl -X GET "https://tahasaif3-taskflow-app.hf.space/api/audit/events/{user_id}?offset=0&limit=50" \
-H "Authorization: Bearer {token}"
'''
# 4. Check database directly (if you have SQL access)
'''
SELECT * FROM audit_log ORDER BY timestamp DESC LIMIT 10;
'''
|