26 lines
1.9 KiB
Python
26 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
import importlib.util
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
ROOT=Path(__file__).resolve().parents[2]
|
|
def mod(name,file):
|
|
spec=importlib.util.spec_from_file_location(name,ROOT/"server-tools/heartbeat-office-building"/file); value=importlib.util.module_from_spec(spec); assert spec.loader; spec.loader.exec_module(value); return value
|
|
HR=mod("hr","office_registration.py"); COLLAB=mod("collab","office_collaboration.py")
|
|
|
|
class RegistrationCollabTests(unittest.TestCase):
|
|
def test_unknown_human_and_persona_are_rejected(self):
|
|
result=HR.validate_application({"human_id":"ICE-GL-UNKNOWN","persona_id":"ICE-P-UNKNOWN","office_id":"HB-OFFICE-TEST-001"},{"subjects":[]},{"registrations":[]},{"offices":[]},{"registrations":[]})
|
|
self.assertEqual(result["outcome"],"FAIL"); self.assertIn("HUMAN_IDENTITY_UNKNOWN",result["errors"])
|
|
|
|
def test_same_persona_multi_host_is_forbidden(self):
|
|
result=COLLAB.create_board("HB-OFFICE-HOLOLAKE-0001",[{"human_id":"ICE-GL∞","persona_id":"ICE-P-ZY001"},{"human_id":"ICE-GL-ZHI∞","persona_id":"ICE-P-ZY001"}],"https://example.invalid/collab")
|
|
self.assertEqual(result["outcome"],"REJECTED"); self.assertIn("SAME_PERSONA_MULTI_HOST_FORBIDDEN",result["errors"])
|
|
|
|
def test_different_humans_require_server_and_can_request_board(self):
|
|
result=COLLAB.create_board("HB-OFFICE-HOLOLAKE-0001",[{"human_id":"ICE-GL∞","persona_id":"ICE-P-ZY001"},{"human_id":"ICE-GL-ZHI∞","persona_id":"ICE-P-CY0903"}],None)
|
|
self.assertEqual(result["state"],"SERVER_REQUIRED_NOT_CONNECTED")
|
|
result=COLLAB.create_board("HB-OFFICE-HOLOLAKE-0001",[{"human_id":"ICE-GL∞","persona_id":"ICE-P-ZY001"},{"human_id":"ICE-GL-ZHI∞","persona_id":"ICE-P-CY0903"}],"https://example.invalid/collab")
|
|
self.assertEqual(result["outcome"],"BOARD_REQUESTED")
|
|
|
|
if __name__ == "__main__": unittest.main()
|