MCPcopy Create free account
hub / github.com/OWASP/Python-Honeypot / TestApi

Class TestApi

tests/test_api.py:10–696  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8
9
10class TestApi(unittest.TestCase):
11
12 def test_index(self):
13 """
14 Test if the API is running
15 """
16 response = requests.get(API_URL)
17 self.assertEqual(response.status_code, 200)
18
19 def test_count_all_events(self):
20 response = requests.get(API_URL + "/api/events/count/all")
21 self.assertGreaterEqual(response.json()["count"], 0)
22 self.assertEqual(response.status_code, 200)
23
24 def test_count_honeypot_events(self):
25 response = requests.get(API_URL + "/api/events/count/honeypot")
26 self.assertGreaterEqual(response.json()["count"], 0)
27 self.assertEqual(response.status_code, 200)
28
29 def test_count_network_events(self):
30 response = requests.get(API_URL + "/api/events/count/network")
31 self.assertGreaterEqual(response.json()["count"], 0)
32 self.assertEqual(response.status_code, 200)
33
34 def test_count_credential_events(self):
35 response = requests.get(API_URL + "/api/events/count/credential")
36 self.assertGreaterEqual(response.json()["count"], 0)
37 self.assertEqual(response.status_code, 200)
38
39 def test_count_file_events(self):
40 response = requests.get(API_URL + "/api/events/count/file")
41 self.assertGreaterEqual(response.json()["count"], 0)
42 self.assertEqual(response.status_code, 200)
43
44 def test_count_data_events(self):
45 response = requests.get(API_URL + "/api/events/count/data")
46 self.assertGreaterEqual(response.json()["count"], 0)
47 self.assertEqual(response.status_code, 200)
48
49 response = requests.get(API_URL + "/api/events/count/data?date=2020-08-14")
50 self.assertGreaterEqual(response.json()["count"], 0)
51 self.assertEqual(response.status_code, 200)
52
53 def test_top_ten_honeypot_events(self):
54 response_port = requests.get(API_URL + "/api/events/count/groupby/honeypot/ip_dest")
55 self.assertGreaterEqual(len(response_port.json()), 0)
56 self.assertEqual(response_port.status_code, 200)
57
58 response_port = requests.get(API_URL + "/api/events/count/groupby/honeypot/ip_dest?country=US")
59 self.assertGreaterEqual(len(response_port.json()), 0)
60 self.assertEqual(response_port.status_code, 200)
61
62 response_port = requests.get(API_URL + "/api/events/count/groupby/honeypot/ip_dest?date=2020-08-14")
63 self.assertGreaterEqual(len(response_port.json()), 0)
64 self.assertEqual(response_port.status_code, 200)
65
66 response_port = requests.get(API_URL + "/api/events/count/groupby/honeypot/ip_dest?country=US&date=2020-08-14")
67 self.assertGreaterEqual(len(response_port.json()), 0)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected