fr41-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')

import asyncio
class NoValidationIO:
    async def get(self,*args,**kwargs): raise AssertionError('validation GET forbidden')
    async def post(self,*args,**kwargs): raise AssertionError('validation POST forbidden')
service=Cell2.SchemaService(Cell2.CONFIG,NoValidationIO())
assert Cell2.CONFIG.enable_cell4_cache is True
for ontology in ['synthetic-unregistered-a','synthetic-unregistered-b']:
    result=asyncio.run(service.validate_with_ontology(Cell2.DataSchema(fields=[]),ontology))
    assert result == (True,[])
    print('FR41',ontology,'accepted without any validation IO:',result)
← All docsView source on GitHub →