mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-05 05:22:58 -05:00
Verify the final signed portable digest and apply an installed font to selected text
This commit is contained in:
1 parent
a2fd3ed2b0
commit
46284078cf
2 files changed
+76
-2
No files matched your search
@@ -0,0 +1,74 @@
|
||||
import json,os,secrets,socket,subprocess as sp,sys,time
|
||||
from pathlib import Path
|
||||
root=Path(__file__).resolve().parent
|
||||
exe=Path(sys.argv[1]); name=sys.argv[2]; profile=root/('profile-'+name+'-'+secrets.token_hex(3)); profile.mkdir()
|
||||
with socket.socket() as sock:
|
||||
sock.bind(('127.0.0.1',0));port=sock.getsockname()[1]
|
||||
token=secrets.token_hex(32)
|
||||
startup=sp.STARTUPINFO();startup.dwFlags|=sp.STARTF_USESHOWWINDOW;startup.wShowWindow=4
|
||||
with open(root/(name+'-app.log'),'w') as log:
|
||||
proc=sp.Popen([str(exe),'--control',str(port),'--automation-read-root',str(root),'--automation-write-root',str(root)], env=dict(os.environ,VECTORCRAFT_CONFIG_DIR=str(profile),VECTORCRAFT_CONTROL_TOKEN=token),startupinfo=startup,stdout=log,stderr=sp.STDOUT)
|
||||
try:
|
||||
for i in range(180):
|
||||
try: s=socket.create_connection(('127.0.0.1',port),timeout=1);break
|
||||
except OSError:
|
||||
if proc.poll() is not None:raise RuntimeError('startup exited')
|
||||
time.sleep(.3)
|
||||
else:raise RuntimeError('startup timeout')
|
||||
s.settimeout(40); stream=s.makefile('rwb')
|
||||
def call(m,p=None):
|
||||
stream.write((json.dumps(dict(id=1,method=m,params=p or {}))+'\n').encode());stream.flush()
|
||||
result=json.loads(stream.readline())
|
||||
if not result.get('ok'):raise RuntimeError((m,result.get('error')))
|
||||
return result.get('result')
|
||||
def cmd(c,**p):return call('engine.execute',dict(command=c,params=p))
|
||||
def snapshot(stage):
|
||||
snap=call('ui.inspect');(root/(name+'-'+stage+'.json')).write_text(json.dumps(snap,ensure_ascii=True))
|
||||
return snap
|
||||
call('auth',{'token':token});cmd('file.new',width=400,height=300)
|
||||
text=cmd('text.create',x=60,y=120,text='Font validation',font='Arial')
|
||||
cmd('select.set',ids=[text['id']])
|
||||
time.sleep(1)
|
||||
snap=snapshot('closed')
|
||||
combo=call('ui.find',{'name':'Font Family'})
|
||||
x,y,w,h=combo['rect']
|
||||
call('ui.click',{'x':x+w-7,'y':y+h/2})
|
||||
time.sleep(.5)
|
||||
snapshot('open')
|
||||
rows=[]
|
||||
for attempt in range(35):
|
||||
try:
|
||||
rows = [call('ui.find',{'name':'Arial Black','index':0})]
|
||||
break
|
||||
except RuntimeError:
|
||||
time.sleep(.4)
|
||||
for index in [1,2]:
|
||||
try:rows.append(call('ui.find',{'name':'Arial Black','index':index}))
|
||||
except RuntimeError:pass
|
||||
print('Arial Black matches:',rows,flush=True)
|
||||
if not rows:
|
||||
controls=call('ui.inspect',{'limit':1000})
|
||||
(root/(name+'-all.json')).write_text(json.dumps(controls,ensure_ascii=True))
|
||||
raise RuntimeError('Arial Black font unavailable in open popup')
|
||||
row=next((v for v in rows if v.get('role') in ('ListBoxOption','ListItem','Row','Option')), rows[0])
|
||||
rx,ry,rw,rh=row['rect']
|
||||
pointer={'x':rx+rw/2,'y':ry+rh/2}
|
||||
call('ui.move',pointer)
|
||||
time.sleep(.4)
|
||||
before=cmd('document.info',category='fonts')['fonts']
|
||||
call('ui.click',pointer)
|
||||
time.sleep(.5)
|
||||
call('ui.move',{'x':20,'y':100})
|
||||
time.sleep(.3)
|
||||
result=cmd('document.info',category='fonts')['fonts']
|
||||
after=call('ui.find',{'name':'Font Family'})
|
||||
snapshot('selected')
|
||||
evidence=dict(executable=str(exe), initial=combo['value'], row=row, hover_fonts=before, after_fonts=result, combo=after)
|
||||
(root/(name+'-result.json')).write_text(json.dumps(evidence,indent=2))
|
||||
print(json.dumps(evidence),flush=True)
|
||||
if name.startswith('diagnostic'):
|
||||
assert not any('Arial Black' in f for f in result), ('expected to reproduce the old rollback',result)
|
||||
else:
|
||||
assert after['value']=='Arial Black' and any('Arial Black' in f for f in result), ('font did not persist',result)
|
||||
finally:
|
||||
if proc.poll() is None:proc.terminate()
|
||||
@@ -39,10 +39,10 @@ jobs:
|
||||
}
|
||||
if ($LASTEXITCODE -ne 0) { throw "Signed artifact download failed." }
|
||||
$asset = Get-ChildItem $download -Recurse -Filter '*windows-x64-portable.zip' | Select-Object -First 1
|
||||
Get-FileHash $asset.FullName
|
||||
if ((Get-FileHash $asset.FullName).Hash -ne "2b9249c9deec9a300b626adb2a9aede38d83da51439c92c0f3da28e6c1cacd52") { throw "Portable differs from signed manifest" }
|
||||
Expand-Archive $asset.FullName "$download/expanded"
|
||||
$exe = Get-ChildItem "$download/expanded" -Recurse -Filter vectorcraft.exe | Select-Object -First 1
|
||||
$signature = Get-AuthenticodeSignature $exe.FullName
|
||||
if ($signature.Status -ne 'Valid') { throw "Authenticode: $($signature.Status) $($signature.StatusMessage)" }
|
||||
$signature.SignerCertificate | Format-Table Subject, Thumbprint
|
||||
python .github/qa-windows-saves.py $exe.FullName
|
||||
python .github/qa-final-font.py $exe.FullName final
|
||||
Reference in new issue
Block a user