import copy,importlib.util,sys,unittest from pathlib import Path ROOT=Path(__file__).parent sys.path.insert(0,str(ROOT/'reusable_support')) # In the released repository this test is beside the portable entrypoint. import evaluate_reusable_batch04_image as entry class RuntimeDescriptor(unittest.TestCase): def descriptor(self): return {'kind':'browser-infrastructure','image_ref':'example/runtime@sha256:'+'1'*64,'container_path':'/crossswe-evaluator/browser-infra','source_manifest_sha256':'2'*64,'files':[{'path':n,'bytes':1,'sha256':'2'*64} for n in ['manifest.json','source-manifest.json']]} def test_closed_descriptor(self):entry.validate_runtime_descriptor(self.descriptor()) def test_duplicate_or_escaping_paths_rejected(self): for path in ['../outside','/absolute','manifest.json']: d=self.descriptor();d['files'].append({'path':path,'bytes':1,'sha256':'2'*64}) with self.assertRaises(AssertionError):entry.validate_runtime_descriptor(d) def test_manifest_binding_rejected(self): d=self.descriptor();d['source_manifest_sha256']='3'*64 with self.assertRaises(AssertionError):entry.validate_runtime_descriptor(d) if __name__=='__main__':unittest.main()