test: isolate ordinary unit runs from ambient credentials and provider I/O
Assistant: codex Assistant-Model: gpt-6.1-sol Assistant-Session: 01a1468b-63fa-7710-85dc-8f2e16b3ebfa
This commit is contained in:
parent
922c26da0f
commit
b593c87983
14 changed files with 592 additions and 6 deletions
29
tests/unit_isolation_probe.py
Normal file
29
tests/unit_isolation_probe.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
"""Closed child regression probes; executed only under the unit runner guard."""
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
mode = sys.argv[1]
|
||||
if mode == 'state':
|
||||
print(json.dumps({'bao_token_present': 'BAO_TOKEN' in os.environ,
|
||||
'vault_token_present': 'VAULT_TOKEN' in os.environ,
|
||||
'home_in_temporary': Path(os.environ['TMPDIR']) in Path.home().parents}))
|
||||
else:
|
||||
try:
|
||||
if mode == 'socket':
|
||||
socket.socket().connect(('127.0.0.1', 8000))
|
||||
elif mode == 'provider':
|
||||
subprocess.run(['bao', 'token', 'lookup'], check=True)
|
||||
elif mode == 'home':
|
||||
Path('/home/synthetic-ambient-unit-fixture/.vault-token').read_text()
|
||||
elif mode == 'nested':
|
||||
subprocess.run([sys.executable, '-c', 'print("SYNTHETIC-SECRET")'], check=True)
|
||||
else:
|
||||
raise AssertionError('unknown probe')
|
||||
except PermissionError:
|
||||
print('denied')
|
||||
else:
|
||||
raise AssertionError('external operation was not refused')
|
||||
Loading…
Add table
Add a link
Reference in a new issue