Add fixed read-only diagnostics for the original partial Windows time profile
Rust development slice / linux (push) Failing after 6s

This commit is contained in:
2026-11-15 16:45:24 +01:00
parent e46f11d3f9
commit cd80745d44
3 changed files with 201 additions and 1 deletions
@@ -99,5 +99,42 @@ class PublicProfileContract(unittest.TestCase):
with self.assertRaises(GuardError):t.read(path,limit=1)
class OriginalPartialDiagnosticContract(unittest.TestCase):
def test_closed_reader_cannot_publish_or_repair(self):
source=t.partial_reader()
self.assertIn('time-profile-'+t.PARTIAL_ID,source)
self.assertIn('time-attestation.candidate.json',source)
self.assertIn('old_move_hresult_unknown=$true',source)
for forbidden in ('[IO.File]::Move','Set-Acl','WriteBytes','WriteNew','Start-Service','Stop-Service','CreateDirectory'):
self.assertNotIn(forbidden,source)
def test_diagnostic_executes_bound_reader_without_legacy_load_or_target_success(self):
import datetime as dt
from unittest.mock import Mock
manifest={'id':t.PARTIAL_ID,'generator_sha256':t.PARTIAL_GENERATOR_SHA,
'script_sha256':t.PARTIAL_SCRIPT_SHA,'request':{'config_sha256':t.PARTIAL_CONFIG_SHA}}
result={'id':t.PARTIAL_ID,'read_only':True,'retry_authorized':False,
'installation_verified':False,'clock_runtime_qualified':False}
access=Mock();access.powershell.return_value=result
expiry=(dt.datetime.now(dt.timezone.utc)+dt.timedelta(hours=1)).isoformat()
with tempfile.TemporaryDirectory() as root,patch.object(t,'ROOT',Path(root)), \
patch.object(t,'read',side_effect=[(b'original',manifest),(b'staged',None)]), \
patch.object(t,'load_case',side_effect=AssertionError('original case must not adopt new generator')), \
patch.object(t.raw_capture,'CaptureAccess',return_value=access), \
patch.object(t.prior.cb.contract,'protected_json',return_value={'expires_at':expiry}):
t.diagnose_partial()
call=access.powershell.call_args
executed=base64.b64decode(call.args[1]['source_base64'])
self.assertIn(t.sha(executed),call.args[0])
cases=list((Path(root)/'devstate/windows-time-profile-diagnostics').iterdir())
self.assertEqual(len(cases),1)
intent=json.loads((cases[0]/'intent.json').read_bytes())
receipt=json.loads((cases[0]/'receipt.json').read_bytes())
self.assertEqual(intent['reader_sha256'],t.sha(executed))
self.assertEqual(receipt['reader_sha256'],t.sha(executed))
self.assertTrue(receipt['old_move_hresult_unknown'])
self.assertEqual((cases[0]/'reader.ps1').read_bytes(),executed)
if __name__ == '__main__':
unittest.main()