sentinel-scam-honeypo / tests /test_scam_scenarios.py
avinash-rai's picture
Deployment Ready: Fixed scam detection low confidence, added production audit report, optimized throttles
1838600
import requests
import json
import time
API_URL = "http://127.0.0.1:8004/api/guvi/analyze"
HEADERS = {"x-api-key": "GUVI_HACKATHON_V2", "Content-Type": "application/json"}
SCENARIOS = [
{
"type": "JOB SCAM ",
"message": "Dear Candidate, Your resume has been shortlisted for Part Time Job. Daily earn Rs 5000-10000. Contact HR on WhatsApp: +91-9876543210 immediately."
},
{
"type": "LOTTERY SCAM ",
"message": "Congratulations! You have won Rs 25 Lakhs in KBC Jio Lottery. To claim your prize, pay processing fee of Rs 15,000 to SBI Account 1234567890."
},
{
"type": "TECH SUPPORT SCAM ",
"message": "Alert: Your computer is infected with a virus. Microsoft Windows subscription expired. Call 1800-123-456 to renew service properly."
},
{
"type": "CRYPTO INVESTMENT ",
"message": "Invest in Bitcoin Mining today and get 3x returns in 24 hours. Guaranteed profit. Send USDT to wallet address 0x1234abcd..."
},
{
"type": "POLICE/GOVT THREAT ",
"message": "This is Mumbai Police Cyber Cell. A case is registered against your Aadhar. You will be arrested in 2 hours. Pay fine to avoid jail."
}
]
def run_tests():
print(f" Testing {len(SCENARIOS)} Different Scam Scenarios...\n")
print(f"{'TYPE':<20} | {'PERSONA':<20} | {'RESPONSE (REALISM CHECK)'}")
print("-" * 120)
for i, scen in enumerate(SCENARIOS):
payload = {
"sessionId": f"TEST-SCENARIO-{i}",
"message": {
"sender": "scammer",
"text": scen["message"],
"timestamp": "2026-01-30T10:00:00Z"
},
"conversationHistory": [],
"metadata": {"channel": "SMS", "language": "English"}
}
try:
# 1. Send Request
start = time.time()
response = requests.post(API_URL, json=payload, headers=HEADERS)
duration = time.time() - start
if response.status_code == 200:
data = response.json()
# Extract details
reply = data.get("reply", "No Reply")
# Notes often contain the persona name in brackets or description
notes = data.get("agentNotes", "")
# Try to infer persona from response style if not explicit
persona = "Unknown"
if "sir" in reply.lower() or "madam" in reply.lower(): persona = "Polite/Desperate"
if "beta" in reply.lower() or "babu" in reply.lower() or "uncle" in reply.lower(): persona = "Elderly (Sharma Uncle)"
if "police" in reply.lower() or "jail" in reply.lower() or "mat bulana" in reply.lower(): persona = "Scared Citizen"
if "busy" in reply.lower() or "drive" in reply.lower() or "baad mein" in reply.lower(): persona = "Stalling/Busy"
if "ready" in reply.lower() or "upi" in reply.lower() or "fee" in reply.lower(): persona = "Compliance/Hooked"
print(f"[{scen['type']}]")
print(f" Input: \"{scen['message'][:60]}...\"")
print(f" Persona Logic: {persona}")
print(f" AI Reply: \"{reply}\"")
print(f" Latency: {duration:.2f}s")
print("-" * 60)
else:
print(f" Error {scen['type']}: {response.status_code} - {response.text}")
except Exception as e:
print(f" Exception: {e}")
time.sleep(1) # Gap between tests
if __name__ == "__main__":
run_tests()