29 lines
1.0 KiB
Python
29 lines
1.0 KiB
Python
import hashlib
|
|
import json
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
import generate_component_capability_report
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
class ComponentCapabilityReportTests(unittest.TestCase):
|
|
def test_report(self):
|
|
report = json.loads((ROOT / "coverage/component-capability.report.json").read_text(encoding="utf-8"))
|
|
self.assertEqual(report["schema"], "component-capability-report.v1")
|
|
self.assertEqual(report["status"], "verified")
|
|
self.assertGreaterEqual(report["manifest"]["components"], 145)
|
|
self.assertGreater(report["existing_report"]["blocked_host_dynamic_loaders"], 0)
|
|
|
|
def test_report_self_hash(self):
|
|
report = json.loads((ROOT / "coverage/component-capability.report.json").read_text(encoding="utf-8"))
|
|
unsigned = dict(report)
|
|
actual = unsigned.pop("report_sha256")
|
|
self.assertEqual(actual, hashlib.sha256(generate_component_capability_report.canonical(unsigned).encode("utf-8")).hexdigest())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|