first commit
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import os
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from app.store import AlertStore
|
||||
|
||||
|
||||
class StoreTests(unittest.TestCase):
|
||||
def test_insert_and_read(self):
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
path = os.path.join(td, "alerts.db")
|
||||
store = AlertStore(path)
|
||||
event = {
|
||||
"timestamp": "2026-08-13T10:00:00+00:00",
|
||||
"event_type": "alert",
|
||||
"src_ip": "192.168.100.10",
|
||||
"src_port": 12345,
|
||||
"dest_ip": "9.9.9.9",
|
||||
"dest_port": 443,
|
||||
"proto": "TCP",
|
||||
"alert": {
|
||||
"signature_id": 1000001,
|
||||
"signature": "LOCAL TZSP PIPELINE TEST",
|
||||
"category": "Test",
|
||||
"severity": 1,
|
||||
"action": "allowed",
|
||||
},
|
||||
}
|
||||
store.insert_alert(event, False, "9.9.9.9", "observation")
|
||||
rows = store.recent(10)
|
||||
self.assertEqual(len(rows), 1)
|
||||
self.assertEqual(rows[0]["signature_id"], 1000001)
|
||||
self.assertEqual(store.summary()["total_alerts"], 1)
|
||||
store.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user