fix: address review 414 write consent and native ownership boundaries

This commit is contained in:
阿白叔 committed 2026-11-13 17:32:14 +08:00
1 parent 1572e2d8ca
commit fee4a67ff1
19 files changed
+1008 -64

No files matched your search

+11 -10
View File
@@ -183,9 +183,9 @@ def test_idle_guard_ignores_unrelated_project_and_prefix_sibling(recovery_files,
request, original, _ = recovery_files
unrelated = original.parent.with_name(original.parent.name+'Old')/'PCB/A.pcb'
monkeypatch.setattr(mentor_adapter, 'pcb_processes', lambda: [(123, '', str(unrelated))])
monkeypatch.setattr(mentor_adapter, '_process_details', lambda name:
[(123, 'ExpeditionPCB.exe', f'ExpeditionPCB.exe "{unrelated}" -ReusableCircuit', 0)]
if name == 'ExpeditionPCB.exe' else [])
monkeypatch.setattr('cbb_refresh_verify.owner_probe.query_owners', lambda names:[
dict(pid=123,name='ExpeditionPCB.exe',executable='ExpeditionPCB.exe',
command=f'ExpeditionPCB.exe "{unrelated}" -ReusableCircuit',parent=0)])
_idle_check(request.lmc_file, original, original.parent/'PCB/A.pcb')
@@ -195,23 +195,23 @@ def test_idle_guard_rejects_exact_target_process(recovery_files, monkeypatch):
request, original, _ = recovery_files
target = original.parent/'PCB/A.pcb'
monkeypatch.setattr(mentor_adapter, 'pcb_processes', lambda: [])
monkeypatch.setattr(mentor_adapter, '_process_details', lambda name:
[(123, 'ExpeditionPCB.exe', f'ExpeditionPCB.exe "{target}" -ReusableCircuit', 0)]
if name == 'ExpeditionPCB.exe' else [])
monkeypatch.setattr('cbb_refresh_verify.owner_probe.query_owners', lambda names:[
dict(pid=123,name='ExpeditionPCB.exe',executable='ExpeditionPCB.exe',
command=f'ExpeditionPCB.exe "{target}" -ReusableCircuit',parent=0)])
with pytest.raises(ValueError, match='TARGET_NATIVE_OWNER_ACTIVE'):
_idle_check(request.lmc_file, original, target)
@pytest.mark.parametrize('target_state', ['idle', 'open_file', 'address'])
def test_pathless_external_client_uses_target_resource_proof(recovery_files, monkeypatch, target_state):
def test_pathless_external_client_requires_resource_proof_and_confirmation(recovery_files, monkeypatch, target_state):
import pywintypes
import win32con
import win32file
from cbb_refresh_verify import mentor_adapter
from cbb_refresh_verify.backup_recovery import _idle_check
request, original, _ = recovery_files
monkeypatch.setattr(mentor_adapter, '_process_details', lambda name:
[(123, 'viewdraw.exe', 'viewdraw.exe', 0)] if name == 'viewdraw.exe' else [])
monkeypatch.setattr('cbb_refresh_verify.owner_probe.query_owners', lambda names:[
dict(pid=123,name='viewdraw.exe',executable='viewdraw.exe',command='viewdraw.exe',parent=0)])
address = original.parent/'database/cdbsvr/sAddress.adr'
handle = None
try:
@@ -228,7 +228,8 @@ def test_pathless_external_client_uses_target_resource_proof(recovery_files, mon
_idle_check(request.lmc_file, original, original.parent/'PCB/A.pcb')
assert address.read_bytes() == b'live or unconfirmed native address'
else:
_idle_check(request.lmc_file, original, original.parent/'PCB/A.pcb')
with pytest.raises(ValueError,match='TARGET_NATIVE_OWNER_UNCONFIRMED'):
_idle_check(request.lmc_file, original, original.parent/'PCB/A.pcb')
finally:
if handle is not None: handle.Close()