-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_api.py
More file actions
38 lines (33 loc) · 1.2 KB
/
test_api.py
File metadata and controls
38 lines (33 loc) · 1.2 KB
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
import requests
import json
import time
BASE_URL = "https://phishingagent.onrender.com"
API_KEY = "test_secret"
def test_health():
try:
response = requests.get(f"{BASE_URL}/health")
print(f"Health Check: {response.status_code} - {response.json()}")
except Exception as e:
print(f"Health Check Failed: {e}")
def test_phishing_check_safe():
try:
headers = {"X-API-Key": API_KEY}
data = {"url": "https://google.com"}
response = requests.post(f"{BASE_URL}/check-phishing", json=data, headers=headers)
print(f"Safe Check: {response.status_code} - {response.json()}")
except Exception as e:
print(f"Safe Check Failed: {e}")
def test_phishing_check_unknown():
try:
headers = {"X-API-Key": API_KEY}
data = {"url": "https://example.com"}
response = requests.post(f"{BASE_URL}/check-phishing", json=data, headers=headers)
print(f"Unknown Check: {response.status_code} - {response.json()}")
except Exception as e:
print(f"Unknown Check Failed: {e}")
if __name__ == "__main__":
# Wait for server to start
time.sleep(5)
test_health()
test_phishing_check_safe()
test_phishing_check_unknown()