research/tests/conftest.py
Meanwhile Research c8a04e144b Initial public release: capability-licensing reference implementation + reproducible claim demos
Clean-room reference implementation (Ed25519 certificate chain, AES-256-GCM
envelope, three-rung revocation ladder, crypto-erasure) with runnable examples
and 36 tests that reproduce each demonstrated claim on stand-in payloads.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-19 16:31:58 +10:00

56 lines
1.6 KiB
Python

"""Shared test fixtures: a full authority chain and a sealed stand-in unit."""
import os
import sys
from pathlib import Path
from types import SimpleNamespace
import pytest
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
from capability_licensing import ( # noqa: E402
CertificateAuthority,
KeyAuthority,
RevocationList,
)
@pytest.fixture()
def chain():
"""A root, an organisational signer, and a capability leaf with its key."""
authority = CertificateAuthority()
root = authority.create_root("Test Root Authority")
organisation = authority.issue_organisation(root.serial, "Test Organisation")
capability, capability_key = authority.issue_capability(
organisation.serial,
"test-capability",
claims={"grant": "test use only"},
)
return SimpleNamespace(
authority=authority,
root=root,
organisation=organisation,
capability=capability,
capability_key=capability_key,
)
@pytest.fixture()
def sealed_setup(chain):
"""A key authority with one sealed stand-in unit licensed to the leaf."""
revocations = RevocationList()
keys = KeyAuthority(
trusted_roots=[chain.root],
intermediates=[chain.organisation],
revocation_list=revocations,
)
payload = b"STAND-IN CAPABILITY UNIT (not a real model)\n" + os.urandom(4096)
sealed = keys.seal_unit("unit-test-001", payload, chain.capability.serial)
return SimpleNamespace(
chain=chain,
revocations=revocations,
keys=keys,
payload=payload,
sealed=sealed,
)