18 lines
767 B
Python
18 lines
767 B
Python
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from fgai.baseline import BaselineStore
|
|
from fgai.logs import parse_log_line
|
|
|
|
|
|
class BaselineTests(unittest.TestCase):
|
|
def test_creates_profile_after_twelve_completed_windows(self):
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
store = BaselineStore(str(Path(directory) / "baseline.sqlite3"))
|
|
for index in range(13):
|
|
store.ingest([parse_log_line(f"srcip=10.0.0.1 dstport={1000 + index} hitcount=2 sentbyte=5")], observed_at=1_700_000_000 + index * 300)
|
|
profiles = store.profiles({"10.0.0.1"})
|
|
self.assertEqual(profiles["10.0.0.1"]["samples"], 12)
|
|
self.assertIn("1000", profiles["10.0.0.1"]["known_destination_ports"])
|