fix: decouple CBB imports from optional export diagnostics

This commit is contained in:
阿白叔 committed 2026-11-13 15:29:00 +08:00
1 parent cbc5723849
commit 1572e2d8ca
12 files changed
+601 -65

No files matched your search

+7 -5
View File
@@ -173,16 +173,17 @@ def test_add_route_readiness_is_separate_from_conservative_capability_gate(tmp_p
import cbb_refresh_verify.native_management as native
proof = {'lm/win32/bin/CleanWGLib.exe': hashlib.sha256(b'verified').hexdigest()}
monkeypatch.setattr(native, '_BINARY_PROOF', proof)
monkeypatch.setattr(native, '_PRODUCTION_ADD_VALIDATED', False)
path = tmp_path/next(iter(proof)); path.parent.mkdir(parents=True); path.write_bytes(b'verified')
adapter = native.NativeManagementAdapter(mentor_home=tmp_path)
assert adapter.route_capabilities()['add'].supported
assert not adapter.capabilities()['add'].supported
assert 'icdb2ascii' in adapter.capabilities()['add'].reason
assert not adapter.capabilities()['update'].supported
@pytest.mark.parametrize('bad', [None, 'CleanWGLib.exe', 'LibraryManager.exe', 'LMCDLL70.dll',
'LMCDocAddin70.dll', 'icdb2ascii.exe', 'icdb2csv.exe', 'edifExporter.exe'])
def test_public_crud_requires_pinned_core_and_every_identity_exporter(tmp_path, monkeypatch, bad):
def test_public_crud_requires_pinned_core_but_not_identity_exporters(tmp_path, monkeypatch, bad):
import hashlib
import cbb_refresh_verify.native_management as native
import cbb_refresh_verify.native_engineering_identity as identity
@@ -198,8 +199,8 @@ def test_public_crud_requires_pinned_core_and_every_identity_exporter(tmp_path,
if bad:
next(tmp_path.rglob(bad)).write_bytes(b'changed binary')
caps = native.NativeManagementAdapter(mentor_home=tmp_path).capabilities()
assert caps['add'].supported is (bad is None)
assert caps['update'].supported is (bad is None)
assert caps['add'].supported is (bad is None or bad in exporters)
assert caps['update'].supported is (bad is None or bad in exporters)
if bad in exporters: assert caps['remove'].supported
@@ -399,9 +400,10 @@ def test_production_caps_require_all_validated_binary_hashes(tmp_path, monkeypat
path = tmp_path/next(iter(proof)); path.parent.mkdir(parents=True); path.write_bytes(b'verified')
adapter = native.NativeManagementAdapter(mentor_home=tmp_path)
assert adapter.capabilities()['remove'].supported
assert not adapter.capabilities()['add'].supported
assert adapter.capabilities()['add'].supported
path.write_bytes(b'different')
assert not adapter.capabilities()['remove'].supported
assert not adapter.capabilities()['add'].supported
def test_probe_readd_requires_creation_token_and_fixed_owned_library(tmp_path):