Add host correlation and assurance coverage
This commit is contained in:
parent
8194d13734
commit
b40ac4252c
36 changed files with 944 additions and 23 deletions
28
tests/test_assurance.py
Normal file
28
tests/test_assurance.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from enodia_sentinel import assurance
|
||||
from enodia_sentinel.config import Config
|
||||
|
||||
|
||||
class TestHashChain(unittest.TestCase):
|
||||
def test_artifact_records_chain_to_previous_hash(self):
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
cfg = Config()
|
||||
cfg.log_dir = Path(d)
|
||||
one = cfg.log_dir / "one.txt"
|
||||
two = cfg.log_dir / "two.txt"
|
||||
one.write_text("one")
|
||||
two.write_text("two")
|
||||
r1 = assurance.append_artifact(cfg, "test", one)
|
||||
r2 = assurance.append_artifact(cfg, "test", two)
|
||||
self.assertEqual(r2["prev_hash"], r1["chain_hash"])
|
||||
summary = assurance.summary(cfg)
|
||||
self.assertEqual(summary["count"], 2)
|
||||
self.assertEqual(summary["last_hash"], r2["chain_hash"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue