fastapi-gsap/.venv/lib/python3.12/site-packages/greenlet/tests/fail_cpp_exception.py
Tyler J King e744336385 fix: capability enforcement, credential safety, atomic delegations, input validation
C-6: ConnectorRuntime enforces capability_mask per operation.
     READ-only ACs cannot invoke MUTATE operations (wipe, lock, retire).
C-7: AC validated against database (exists, active, not expired)
     before connector invocation.
C-9: Delegated AC capability bounded by delegator's capability.
C-10: Command counter uses atomic SQL increment with limit check.
M-23: expire_stale() uses same atomic SQL pattern.

H-1: Sensitive credential fields hidden from repr/logs via repr=False.
H-2: Stub backend requires ALLOW_STUB_CREDENTIALS=true to activate.
H-3: Kerberos backend raises CredentialResolutionError instead of
     returning stub ticket.
H-4: Chronicle INTENT emitted before execution, RESULT after.
H-5: device_id validated as UUID before Graph API URL interpolation.
H-8: ConnectorRuntime enforces governance for all connector invocations.

Signed-off-by: Tyler King <tking@guildhouse.dev>
2026-04-14 08:13:27 -04:00

33 lines
985 B
Python

# -*- coding: utf-8 -*-
"""
Helper for testing a C++ exception throw aborts the process.
Takes one argument, the name of the function in :mod:`_test_extension_cpp` to call.
"""
import sys
import greenlet
from greenlet.tests import _test_extension_cpp
print('fail_cpp_exception is running')
def run_unhandled_exception_in_greenlet_aborts():
def _():
_test_extension_cpp.test_exception_switch_and_do_in_g2(
_test_extension_cpp.test_exception_throw_nonstd
)
g1 = greenlet.greenlet(_)
g1.switch()
func_name = sys.argv[1]
try:
func = getattr(_test_extension_cpp, func_name)
except AttributeError:
if func_name == run_unhandled_exception_in_greenlet_aborts.__name__:
func = run_unhandled_exception_in_greenlet_aborts
elif func_name == 'run_as_greenlet_target':
g = greenlet.greenlet(_test_extension_cpp.test_exception_throw_std)
func = g.switch
else:
raise
print('raising', func, flush=True)
func()