#!/usr/bin/env python3
"""Read-only check after restarting this lab; does not create missing data."""
import os
from pycti import OpenCTIApiClient
api=OpenCTIApiClient(os.environ['OPENCTI_URL'],os.environ['OPENCTI_TOKEN'],log_level='ERROR')
reports=api.report.list(search='SecTools Lab — 釣魚事件建模練習',first=10)
report=next((r for r in reports if r.get('name')=='SecTools Lab — 釣魚事件建模練習'),None)
assert report, 'Report missing; this check never recreates data'
exported=api.stix2.get_stix_bundle_or_object_from_entity_id('Report',report['id'],mode='full')
objects=exported['objects']
assert any(o.get('type')=='domain-name' and o.get('value')=='login.example' for o in objects)
assert any(o.get('type')=='relationship' and o.get('relationship_type')=='uses' for o in objects)
print('PASS read-only persistence: report, domain and uses relationship survive restart')
print('PASS no create/update operation was used to satisfy this check')
