fr42-probe.py
import os, socket, sys
from unittest.mock import patch
import google.auth
from google.auth.exceptions import DefaultCredentialsError
attempts = []
def denied(*args, **kwargs):
attempts.append('network')
raise AssertionError('Cell02 fixture attempted external access')
socket.socket.connect = denied
socket.create_connection = denied
socket.getaddrinfo = denied
# Match Docker's src PYTHONPATH plus Cell02 working-directory import context.
sys.path[:0] = [sys.argv[1]+'/src/cells/cell02', sys.argv[1]+'/src']
# Explicitly absent fixture configuration, never workstation credentials.
os.environ['GCP_PROJECT_ID'] = ''
os.environ['MIZOKI_SRPVDAL_ENABLED'] = 'false'
os.environ['SRPVDAL_ENABLED'] = 'false'
with patch.object(google.auth, 'default', side_effect=DefaultCredentialsError('offline fixture')):
import Cell2
from fastapi.testclient import TestClient
assert Cell2.SRPVDAL_AVAILABLE
with TestClient(Cell2.app) as client:
# This legacy health route is liveness only; do not certify its claims.
health = client.get('/health')
assert health.status_code == 200
assert health.json()['service'] == Cell2.CONFIG.service_name
print('FR38_HEALTH', health.json())
print('FR38_READY', client.get('/ready').json())
print('FR38_CONFIG', repr(Cell2.CONFIG.gcp_project_id), 'fixture absent; SDK initialization refused')
status = client.get('/srpvdal/status')
assert status.status_code == 200
assert status.json()['status'] == 'not_configured'
assert status.json()['cell3_connected'] is False
assert status.json()['cell3_status'] == 'unverified'
assert status.json()['supported_tasks'] == []
assert client.post('/srpvdal/execute', json={'task_type':'learn'}).status_code == 422
for task in ['extract', 'transform', 'analyze', 'learn', 'unknown']:
response = client.post('/srpvdal/execute', json={'task_type':task, 'input_data':{'text':'synthetic fixture'}, 'enable_learning':True})
assert response.status_code == 501, response.text
assert response.json()['detail']['status'] == 'not_configured'
assert 'result' not in response.json()
assert 'learned' not in response.json()
assert Cell2.app.state.identity_resolver is None
assert Cell2.app.state.journey_publisher is None
import asyncio
service = Cell2.DLPService(Cell2.CONFIG)
assert service.dlp_client is None
raw = 'Synthetic fixture: fixture@example.invalid'
masked, entities = asyncio.run(service.inspect_and_mask_text(raw))
assert masked == raw and entities == []
print('FR40: absent DLP client returns original synthetic text and empty findings')
assert not attempts, 'external attempt was swallowed'
print('actual Cell2 ASGI: liveness200; mounted SRPVDAL not_configured, invalid422, five task refusals501; no cloud calls')
from google.cloud import dlp_v2
service = Cell2.DLPService(Cell2.CONFIG)
for name, constructor, config in [('inspect',dlp_v2.InspectConfig,service._get_inspect_config()),('deidentify',dlp_v2.DeidentifyConfig,service._get_deidentify_config())]:
try: constructor(**config)
except (ValueError,AttributeError) as exc: print('FR42',name,type(exc).__name__,str(exc))
with patch.object(Cell2.CONFIG,'dlp_inspect_template','projects/fixture/locations/global/inspectTemplates/fixture'):
try: dlp_v2.InspectConfig(**service._get_inspect_config())
except ValueError as exc: print('FR42 inspect-template',str(exc))
with patch.object(Cell2.CONFIG,'dlp_deidentify_template','projects/fixture/locations/global/deidentifyTemplates/fixture'):
try: dlp_v2.DeidentifyConfig(**service._get_deidentify_config())
except ValueError as exc: print('FR42 deidentify-template',str(exc))
item=dlp_v2.DeidentifyContentResponse(item=dlp_v2.ContentItem(value='[MASKED]')).item
try: item.findings
except AttributeError as exc: print('FR42 response',str(exc))
print('FR42 expected min_likelihood field:', 'min_likelihood' in dlp_v2.InspectConfig._meta.fields)
print('FR42 request template fields:',[x for x in dlp_v2.DeidentifyContentRequest._meta.fields if 'template' in x])