Integrate 0.9.3 SLP/IP, SQLite identities and complete token fix; build release 0.9.3-1
This commit is contained in:
39
tests/test_identity_wizard_browser.py
Normal file
39
tests/test_identity_wizard_browser.py
Normal file
@@ -0,0 +1,39 @@
|
||||
"""Real Chromium, simulated API only; no production server or passwords."""
|
||||
from pathlib import Path
|
||||
import os
|
||||
from playwright.sync_api import sync_playwright
|
||||
root=Path(__file__).resolve().parents[1]/'websetup'
|
||||
state=dict(defaultPassword=False,groups={k:[] for k in ['1','2','3','4','5','6','12','13','17','21','45','200']},text='',revision='a',csrf='b',validation={'errors':[]},devices=[],backups=[],path='/etc/nwserv.conf',services=True)
|
||||
state['groups']['2']=['MARS'];state['groups']['4']=['0x102 eth0 802.2 1']
|
||||
objects=[{'name':'SUPERVISOR','type':1,'id':1,'unix':'nobody'},{'name':'EVERYONE','type':2,'id':2}]
|
||||
config=dict(version=1,tree='MARS_TREE',organization='HOME',units=['USERS','GROUPS','SERVERS'],placements=[])
|
||||
rev='r1'; fail=False; created=0; errors=[]
|
||||
def fixture(source,path,body):
|
||||
global config,rev,created
|
||||
if path=='/api/state':return state
|
||||
if path=='/api/status':return {'mars-nwe-pcap.service':'ActiveState=active','mars-pcapd.service':'ActiveState=active'}
|
||||
if path=='/api/directory':
|
||||
if body:
|
||||
assert body['confirm'] and body['revision']==rev
|
||||
config=body['config'];rev='r2';return {'ok':True}
|
||||
if fail:return {'error':'Test: Server nicht erreichbar'}
|
||||
return dict(validation={'errors':[],'warnings':[]},missing=[],runningConfigMatches=True,nativeNds=False,liveAvailable=True,liveComplete=True,objects=objects,servers=['MARS'],networks=['0x102 eth0 802.2 1'],volumes=['SYS /tmp'],config=config,revision=rev,configured=True)
|
||||
if path=='/api/identities':
|
||||
if body:
|
||||
assert body['confirm'] and body['name']=='ALICE' and len(body['password'])==20
|
||||
created+=1;objects.append({'name':'ALICE','type':1,'unix':'marsv200000000','id':3,'disabled':False});return {'alias':'marsv200000000','uid':200000000}
|
||||
return dict(wrappedBindery=True,liveComplete=True,databaseAvailable=True,identities=[{'name':'ALICE','alias':'marsv200000000','uid':200000000,'status':'linked'}] if created else [],issues=[])
|
||||
if path=='/api/bindery' and body['op']=='objects':return {'objects':objects}
|
||||
raise AssertionError((path,body))
|
||||
with sync_playwright() as p:
|
||||
b=p.chromium.launch(executable_path=os.environ.get('CHROMIUM','/usr/bin/chromium'),args=['--no-sandbox']);page=b.new_page(viewport={'width':390,'height':844});page.set_default_timeout(5000);page.on('pageerror',lambda e:errors.append(str(e)));page.on('dialog',lambda d:d.accept());page.expose_binding('fixture',fixture)
|
||||
# Use the actual HTML/JS/CSS with a simulated fetch implementation.
|
||||
page.evaluate("()=>{window.fetch=async(path,opts)=>{const d=await window.fixture(path,opts?.body?JSON.parse(opts.body):null);return {ok:!d.error,status:d.error?503:200,json:()=>d}};}")
|
||||
html=(root/'index.html').read_text().replace('<link rel="stylesheet" href="/style.css">','<style>'+(root/'style.css').read_text()+'</style>').replace('<script src="/app.js" defer></script>','');page.set_content(html);page.add_script_tag(content=(root/'app.js').read_text());page.wait_for_function("document.getElementById('serverStatus').textContent==='active'")
|
||||
page.locator('#directoryOpen').click();page.wait_for_function("document.getElementById('directoryChecks').textContent.includes('Betriebsmodus')")
|
||||
assert 'Noch nicht verfügbar' in page.locator('#directoryChecks').inner_text()
|
||||
page.locator('#directoryNext').click();page.locator('#directoryTree').fill('INVALID NAME');page.locator('#directoryNext').click();assert 'zulässige' in page.locator('#directoryMessage').inner_text();page.locator('#directoryTree').fill('MARS_TREE');page.locator('#directoryNext').click();page.locator('#directoryAuto').click();page.locator('#directoryNext').click();assert 'Tree / Baum: leer lassen' in page.locator('#directoryClient').input_value();page.locator('#directorySave').click();page.wait_for_function("document.getElementById('directoryMessage').textContent.includes('gespeichert')");assert config['placements']
|
||||
# A failed reload must not permit a save of stale data.
|
||||
fail=True;page.locator('#directoryBack').click();page.locator('#directoryBack').click();page.locator('#directoryBack').click();page.locator('#directoryReload').click();page.wait_for_function("document.getElementById('directoryMessage').textContent.includes('Bitte erneut laden')");assert page.locator('#directoryNext').is_disabled();fail=False;page.locator('#directoryReload').click();page.wait_for_function("!document.getElementById('directoryNext').disabled");page.locator('#directoryBindery').click();page.wait_for_function("document.getElementById('bindSummary').textContent.includes('2 Objekte')")
|
||||
page.locator('#createUser').click();page.locator('[name=name]').fill('alice');page.get_by_role('button',name='Sicheres Kennwort erzeugen').click();pw=page.locator('[name=password]').input_value();assert len(pw)==20 and all(c in '0123456789ABCDEF' for c in pw);page.locator('#actionSubmit').click();page.wait_for_function("document.getElementById('bindSummary').textContent.includes('3 Objekte')");assert created==1;assert page.locator('[name=password]').input_value()==''
|
||||
assert not errors,errors;print('PASS Chromium mobile 390x844: wizard, mode disclosure, invalid input, auto assignment, save, failed reload, recovery, generated password, user creation, cleared password (mock API)');b.close()
|
||||
Reference in New Issue
Block a user