secrets-engine/tests/conftest.py

22 lines
820 B
Python
Raw Normal View History

"""Synthetic founder admission anchor for every test; never a verification bypass."""
import subprocess
import pytest
from tests.signature_support import FOUNDER, admission_anchor
@pytest.fixture(scope='session')
def founder_key(tmp_path_factory):
return admission_anchor(tmp_path_factory.mktemp('founder-admission'))
@pytest.fixture(autouse=True)
def founder_anchor(founder_key, monkeypatch):
import secrets_engine.founder_admission as admission
monkeypatch.setenv('SECRETS_ENGINE_ADMISSION_ANCHOR', str(founder_key['anchor']))
# Tests run as the anchor's owner; keep the mode-bit half of the rule.
real_rule = admission._writable_by_runtime
monkeypatch.setattr(admission, '_writable_by_runtime', lambda info: bool(info.st_mode & 0o022))
return {**founder_key, 'real_rule': real_rule}