File size: 1,284 Bytes
5e0532d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import asyncio
import os
import time
from app.services.audit import audit_service

async def verify_audit():
    print("Verifying Audit Service...")
    
    # 1. Log Interaction
    await audit_service.log_interaction(
        user_id="test_user_1",
        intent="test_intent",
        guardrails_triggered=[]
    )
    print("Logged interaction.")
    
    # 2. Log Violation
    await audit_service.log_violation(
        user_id="test_user_unsafe",
        violation_type="Prohibited Phrase",
        content="This is a test violation content."
    )
    print("Logged violation.")
    
    # 3. Check File
    time.sleep(1) # Ensure flush
    log_path = "logs/ora.log"
    if os.path.exists(log_path):
        print(f"Log file found at {log_path}")
        with open(log_path, "r") as f:
            content = f.read()
            print("--- Log Content ---")
            print(content)
            print("-------------------")
            
            if "test_user_1" in content and "test_user_unsafe" in content:
                print("SUCCESS: Both log entries found.")
            else:
                print("FAILURE: Log entries missing.")
    else:
        print(f"FAILURE: Log file not found at {log_path}")

if __name__ == "__main__":
    asyncio.run(verify_audit())