Workplace Widget 5.10.23
This commit is contained in:
@@ -25,46 +25,115 @@ class DOMParser {
|
||||
return {documentElement:root,getElementsByTagName:tag=>tag==='parsererror'?[]:root.getElementsByTagName(tag)};
|
||||
}
|
||||
}
|
||||
const source=fs.readFileSync(new URL('../public/cheerpj-runner.js',import.meta.url),'utf8');
|
||||
const nativeSource=fs.readFileSync(new URL('../public/cheerpj/natives/jaas.js',import.meta.url),'utf8');
|
||||
assert.match(nativeSource,/Java_com_sun_security_auth_module_UnixSystem_getUnixInfo/);
|
||||
const source=fs.readFileSync(new URL('../public/cheerpj-runner.js',import.meta.url),'utf8')
|
||||
.replace(/^import jaasNativeHandlers from '\.\/cheerpj\/natives\/jaas\.js';\n/, 'const jaasNativeHandlers=mockJaasNativeHandlers;\n');
|
||||
let responseText='';
|
||||
const origin='https://demo.example.org:8181';
|
||||
async function launch(path,version=11,opts={},testOptions={}){
|
||||
const sent=[],called=[];
|
||||
const context={URL,DOMParser,
|
||||
location:{href:origin+'/backend/hmi/cheerpj-runner.html',origin,hostname:'demo.example.org'},
|
||||
// A trusted, same-origin WidgetWorkbench parent responds to a one-shot request.
|
||||
const parentProxy={postMessage:m=>{
|
||||
sent.push(m);
|
||||
if(m.type==='hmi-cheerpj-credential-request'){
|
||||
const reply=testOptions.handoff
|
||||
? {type:'hmi-cheerpj-credentials',requestId:m.requestId,...testOptions.handoff}
|
||||
: {type:'hmi-cheerpj-credentials-unavailable',requestId:m.requestId};
|
||||
queueMicrotask(()=>context._handler({source:parentProxy,origin,data:reply}));
|
||||
}
|
||||
}};
|
||||
const context={URL,DOMParser,mockJaasNativeHandlers:{Java_com_sun_security_auth_module_UnixSystem_getUnixInfo:async()=>{}},
|
||||
location:{href:origin+'/backend/hmi/cheerpj-runner.html'+(testOptions.diagMode?'?diagnose='+testOptions.diagMode:''),origin,hostname:'demo.example.org'},
|
||||
document:{body:{classList:{add:()=>{}}},getElementById:()=>({textContent:'',className:'',getBoundingClientRect:()=>({width:960,height:640})})},
|
||||
window:{parent:{postMessage:m=>sent.push(m)},addEventListener:(type,fn)=>{if(type==='message')context._handler=fn},
|
||||
window:{parent:parentProxy,addEventListener:(type,fn)=>{if(type==='message')context._handler=fn},
|
||||
cheerpjInit:async(opts)=>called.push(['init',opts]),cheerpjCreateDisplay:(w,h)=>{assert.equal(w,-1);assert.equal(h,-1);called.push('display')},
|
||||
cheerpjRunMain:async (...args)=>{called.push(['runMain',...args]);return 0},
|
||||
cheerpjRunJar:async (...args)=>{called.push(['runJar',...args]);return 0},
|
||||
cheerpjRunLibrary:async cp=>{
|
||||
called.push(['library',cp]);
|
||||
if(cp==='')return {java:{nio:{file:{
|
||||
return {java:{nio:{file:{
|
||||
Paths:{get:async path=>{called.push(['tempPath',path]);return {value:path}}},
|
||||
Files:{
|
||||
createDirectories:async (path,attributes)=>{
|
||||
called.push(['tempMkdir',path.value,attributes]);
|
||||
if(testOptions.failTemp)throw Error('Speicherplatz erschöpft');
|
||||
if(testOptions.failTemp || testOptions.blockNested && path.value==='/files/itac-workplace/tmp')throw Error(testOptions.failTemp?'Speicherplatz erschöpft':'Verzeichnis durch vorhandene Datei blockiert');
|
||||
return path;
|
||||
},
|
||||
isDirectory:async (path,options)=>{
|
||||
called.push(['tempIsDir',path.value,options]);
|
||||
return !testOptions.notDirectory;
|
||||
return testOptions.notDirectory ? false : true;
|
||||
},
|
||||
createTempFile:async (path,prefix,suffix,attributes)=>{
|
||||
called.push(['tempProbe',path.value,prefix,suffix,attributes]);
|
||||
if(testOptions.readOnly)throw Error('Schreiben nicht erlaubt');
|
||||
if(testOptions.failTemp || testOptions.readOnly || testOptions.probeBlockNested && path.value==='/files/itac-workplace/tmp' || testOptions.blockAllSubdirs && path.value!=='/files')throw Error(testOptions.failTemp?'Speicherplatz erschöpft':testOptions.readOnly?'Schreiben nicht erlaubt':'Schreibtest fehlgeschlagen');
|
||||
return {value:path.value+'/hmi-tmp-check-1.tmp'};
|
||||
},
|
||||
deleteIfExists:async path=>{called.push(['tempProbeRemove',path.value]);return true;}
|
||||
}
|
||||
}}}};
|
||||
return {com:{widgetworkbench:{cheerpj:{WorkplaceResizeBridge:{resize:async (w,h)=>{called.push(['resize',w,h]);return 1}}}}}};
|
||||
}},lang:{System:{setProperty:async (key,value)=>{called.push(['setProperty',key,value]);return '/files';}}}},
|
||||
com:{sun:{security:{auth:{module:{UnixSystem:class {
|
||||
constructor(){
|
||||
if(testOptions.jaasFail==='proxy'){
|
||||
// Java Throwable proxies do not necessarily expose JS toString or
|
||||
// Symbol.toPrimitive: String(proxy) would mask the original exception.
|
||||
const proxy=Object.create(null);
|
||||
proxy.getClass=async()=>({getName:async()=> 'java.lang.UnsatisfiedLinkError'});
|
||||
proxy.getMessage=async()=> 'no jaas in java.library.path: Missing import: JVM_LoadLibrary';
|
||||
proxy.getCause=async()=>null;
|
||||
throw proxy;
|
||||
}
|
||||
if(testOptions.jaasFail==='opaque')throw Object.create(null);
|
||||
if(testOptions.jaasFail)throw Error('no jaas in java.library.path: Missing import: JVM_LoadLibrary');
|
||||
}
|
||||
async getUsername(){
|
||||
if(testOptions.jaasUserProxy){
|
||||
const proxy=Object.create(null);
|
||||
proxy.equals=async value=>value==='cheerpj-client';
|
||||
return proxy;
|
||||
}
|
||||
return 'cheerpj-client';
|
||||
}
|
||||
}}}}},widgetworkbench:{cheerpj:{WorkplaceCredentialBridge:{
|
||||
offer:async(user,pass,client)=>{called.push(['credentialOffer',user==='tester',pass==='secret123',client]);return testOptions.offerRejected?0:1;}
|
||||
},WorkplaceResizeBridge:{
|
||||
startRuntimeMonitor:async (w,h,mode)=>{
|
||||
called.push(['windowMonitorStart',w,h,mode]);
|
||||
if(testOptions.monitorUnsupported)throw Error('Java code still running, check for a missing await');
|
||||
return 1;
|
||||
},
|
||||
// The following methods are Java-internal only and MUST NOT be called
|
||||
// from JS while the Workplace main method is running.
|
||||
resize:async()=>{throw Error('forbidden parallel JS resize call');},
|
||||
diagnoseWindows:async()=>{throw Error('forbidden parallel JS diagnostic call');},
|
||||
rescueOffscreenDialogs:async()=>{throw Error('forbidden parallel JS rescue call');}
|
||||
}}}}};
|
||||
},
|
||||
},
|
||||
parent:{postMessage:m=>sent.push(m)},
|
||||
fetch:async u=>({ok:true,status:200,url:u,text:async()=>responseText}),
|
||||
setInterval,clearInterval,Error,Promise,ResizeObserver:class { observe(){} disconnect(){} },
|
||||
parent:parentProxy,
|
||||
fetch:async (u,options={})=>{
|
||||
if(u==='/backend/hmi/cheerpj-libs/javax.json-1.1.4.jar'){
|
||||
called.push(['jsonpProbe',u,options.headers?.Range]);
|
||||
const status=testOptions.providerMissing?404:testOptions.providerNoRange?200:206;
|
||||
return {ok:status<400,status,url:origin+u};
|
||||
}
|
||||
if(u==='/backend/hmi/cheerpj/natives/jaas.js'){
|
||||
called.push(['jaasModuleProbe',u]);
|
||||
const status=testOptions.nativeMissing?404:200;
|
||||
return {ok:status<400,status,url:origin+u};
|
||||
}
|
||||
if(u==='/backend/hmi/cheerpj/workplace-credential-bridge.jar'){
|
||||
called.push(['credentialBridgeProbe',u,options.headers?.Range]);
|
||||
return {ok:true,status:testOptions.credentialBridgeMissing?404:206,url:origin+u};
|
||||
}
|
||||
if(u==='/backend/hmi/cheerpj/jaas-identity-bridge.jar'){
|
||||
called.push(['jaasBridgeProbe',u,options.headers?.Range]);
|
||||
const status=testOptions.bridgeMissing?404:testOptions.bridgeNoRange?200:206;
|
||||
return {ok:status<400,status,url:origin+u};
|
||||
}
|
||||
return {ok:true,status:200,url:u,text:async()=>responseText};
|
||||
},
|
||||
setInterval,clearInterval,setTimeout,clearTimeout,Error,Promise,ResizeObserver:class { observe(){} disconnect(){} },
|
||||
};
|
||||
vm.createContext(context);vm.runInContext('(function(){\n'+source+'\n})()',context);
|
||||
context._handler({source:context.window.parent,origin,data:{type:'hmi-cheerpj-launch',requestId:'test-1',jnlpUrl:path,javaVersion:version,...opts}});
|
||||
@@ -97,33 +166,117 @@ result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp'
|
||||
assert.equal(result.end?.state,'finished',JSON.stringify(result.end));
|
||||
assert.deepEqual(Array.from(result.called.find(c=>Array.isArray(c)&&c[0]==='init')[1].javaProperties),
|
||||
['itac.artes.clusternodes=https://demo.example.org:8181/mes',
|
||||
'java.io.tmpdir=/files/itac-workplace/tmp']);
|
||||
'java.io.tmpdir=/files',
|
||||
'java.library.path=/app/backend/hmi/cheerpj/natives']);
|
||||
const initIndex=result.called.findIndex(c=>Array.isArray(c)&&c[0]==='init');
|
||||
const mkdirIndex=result.called.findIndex(c=>Array.isArray(c)&&c[0]==='tempMkdir');
|
||||
const propIndex=result.called.findIndex(c=>Array.isArray(c)&&c[0]==='setProperty');
|
||||
const runIndex=result.called.findIndex(c=>Array.isArray(c)&&c[0]==='runMain');
|
||||
assert.ok(initIndex>=0&&mkdirIndex>initIndex&&runIndex>mkdirIndex,
|
||||
assert.ok(initIndex>=0&&mkdirIndex>initIndex&&propIndex>mkdirIndex&&runIndex>propIndex,
|
||||
'Java-Temp-Ordner muss vor dem Workplace-Start erzeugt werden.');
|
||||
assert.equal(result.called[mkdirIndex][1],'/files/itac-workplace/tmp');
|
||||
assert.ok(result.called.some(c=>Array.isArray(c)&&c[0]==='tempIsDir'&&c[1]==='/files/itac-workplace/tmp'));
|
||||
assert.ok(!result.called.some(c=>Array.isArray(c)&&c[0]==='tempIsDir'), 'Keine fehleranfällige Java-Boolean-Umwandlung verwenden.');
|
||||
assert.ok(result.called.some(c=>Array.isArray(c)&&c[0]==='setProperty'&&c[1]==='java.io.tmpdir'&&c[2]==='/files/itac-workplace/tmp'));
|
||||
assert.ok(result.called.some(c=>Array.isArray(c)&&c[0]==='tempProbe'&&c[1]==='/files/itac-workplace/tmp'));
|
||||
assert.ok(result.called.some(c=>Array.isArray(c)&&c[0]==='tempProbeRemove'));
|
||||
|
||||
assert.ok(result.called.some(c=>Array.isArray(c)&&c[0]==='library'&&c[1].endsWith('workplace-resize-bridge-v2.jar')));
|
||||
assert.ok(result.called.some(c=>Array.isArray(c)&&c[0]==='runMain'&&c[2].endsWith('workplace-resize-bridge-v2.jar')));
|
||||
assert.equal(result.called.filter(c=>Array.isArray(c)&&c[0]==='library').length,1,'CheerpJ Library Mode must run only once');
|
||||
assert.ok(result.called.find(c=>Array.isArray(c)&&c[0]==='library')[1].includes('/app/jar/app.jar')===false);
|
||||
assert.ok(result.called.some(c=>Array.isArray(c)&&c[0]==='library'&&c[1].endsWith('workplace-window-monitor-v4.jar')));
|
||||
assert.equal(typeof result.called.find(c=>Array.isArray(c)&&c[0]==='init')[1].natives.Java_com_sun_security_auth_module_UnixSystem_getUnixInfo,'function');
|
||||
assert.ok(result.called.some(c=>Array.isArray(c)&&c[0]==='runMain'&&c[2].endsWith('workplace-window-monitor-v4.jar')));
|
||||
const workplaceCall=result.called.find(c=>Array.isArray(c)&&c[0]==='runMain');
|
||||
assert.equal(workplaceCall[1],'com.itac.mes.suite.presentation.MesSuiteFrameWebstartLauncher');
|
||||
assert.equal(workplaceCall[3],'itac.appid=Workplace');
|
||||
assert.equal(workplaceCall[2].split(':').length,130);
|
||||
assert.equal(workplaceCall[2].split(':').length,133);
|
||||
assert.match(workplaceCall[2],/workplace-credential-bridge\.jar/);
|
||||
assert.match(workplaceCall[2],/\/app\/backend\/hmi\/cheerpj-libs\/javax\.json-1\.1\.4\.jar/);
|
||||
assert.match(workplaceCall[2],/\/app\/backend\/hmi\/cheerpj\/jaas-identity-bridge\.jar/);
|
||||
assert.ok(result.called.some(c=>c[0]==='jaasModuleProbe'));
|
||||
assert.ok(result.called.some(c=>c[0]==='jaasBridgeProbe'&&c[2]==='bytes=0-0'));
|
||||
assert.ok(result.called.some(c=>Array.isArray(c)&&c[0]==='jsonpProbe'&&c[2]==='bytes=0-0'));
|
||||
const probeIndex=result.called.findIndex(c=>Array.isArray(c)&&c[0]==='jsonpProbe');
|
||||
assert.ok(probeIndex>=0&&probeIndex<runIndex,'JSON-P Range-Probe muss vor main() erfolgen.');
|
||||
assert.match(result.sent.find(s=>s.state==='running')?.message||'',/RXTX/);
|
||||
// New WindowGeometry checks: readonly by default; opt-in repair only on request.
|
||||
result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',11,{workplace:true,windowMode:'diagnose'});
|
||||
assert.equal(result.end?.state,'finished',JSON.stringify(result.end));
|
||||
assert.ok(result.called.some(c=>Array.isArray(c)&&c[0]==='windowMonitorStart'&&c[1]===960&&c[2]===640&&c[3]==='diagnose'));
|
||||
assert.ok(!result.called.some(c=>Array.isArray(c)&&['resize','windowSnapshot','windowRescue'].includes(c[0])));
|
||||
assert.ok(result.called.findIndex(c=>Array.isArray(c)&&c[0]==='windowMonitorStart')<result.called.findIndex(c=>Array.isArray(c)&&c[0]==='runMain'),
|
||||
'Java-Monitor muss vor main() gestartet sein.');
|
||||
result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',11,{workplace:true,windowMode:'rescue'});
|
||||
assert.equal(result.end?.state,'finished',JSON.stringify(result.end));
|
||||
assert.ok(result.called.some(c=>Array.isArray(c)&&c[0]==='windowMonitorStart'&&c[3]==='rescue'));
|
||||
assert.ok(!result.called.some(c=>Array.isArray(c)&&['resize','windowSnapshot','windowRescue'].includes(c[0])));
|
||||
result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',11,{workplace:true,windowMode:'off'});
|
||||
assert.equal(result.end?.state,'finished',JSON.stringify(result.end));
|
||||
assert.ok(result.called.some(c=>Array.isArray(c)&&c[0]==='windowMonitorStart'&&c[3]==='off'));
|
||||
assert.ok(!result.called.some(c=>Array.isArray(c)&&['resize','windowSnapshot','windowRescue'].includes(c[0])));
|
||||
// If the optional Java monitor cannot be started, the vendor main must still run.
|
||||
result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',11,{workplace:true,windowMode:'diagnose'},{monitorUnsupported:true});
|
||||
assert.equal(result.end?.state,'finished',JSON.stringify(result.end));
|
||||
assert.ok(result.called.some(c=>Array.isArray(c)&&c[0]==='runMain'));
|
||||
assert.match(result.sent.find(s=>s.state==='running')?.message||'',/Fenstermonitor nicht verfügbar/);
|
||||
result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',11,{workplace:true},{diagMode:'jaas-only'});
|
||||
assert.equal(result.end?.state,'finished',JSON.stringify(result.end));
|
||||
assert.match(result.end.message,/JAAS UnixSystem erfolgreich initialisiert/);
|
||||
assert.ok(!result.called.some(c=>Array.isArray(c)&&c[0]==='runMain'));
|
||||
assert.equal(result.called.filter(c=>Array.isArray(c)&&c[0]==='library').length,1);
|
||||
result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',11,{workplace:true},{diagMode:'jaas-only',jaasFail:true});
|
||||
assert.equal(result.end?.state,'error');
|
||||
assert.match(result.end.message,/JAAS-Laufzeittest fehlgeschlagen/);
|
||||
assert.match(result.end.message,/JVM_LoadLibrary/);
|
||||
assert.ok(!result.called.some(c=>Array.isArray(c)&&c[0]==='runMain'));
|
||||
// Java/CheerpJ proxy exceptions must retain their original diagnostic text.
|
||||
result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',11,{workplace:true},{diagMode:'jaas-only',jaasFail:'proxy'});
|
||||
assert.equal(result.end?.state,'error',JSON.stringify(result.end));
|
||||
assert.match(result.end.message,/java\.lang\.UnsatisfiedLinkError/);
|
||||
assert.match(result.end.message,/JVM_LoadLibrary/);
|
||||
assert.match(result.end.message,/UnixSystem-Konstruktor/);
|
||||
assert.doesNotMatch(result.end.message,/Cannot convert object to primitive value/);
|
||||
result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',11,{workplace:true},{diagMode:'jaas-only',jaasFail:'opaque'});
|
||||
assert.equal(result.end?.state,'error',JSON.stringify(result.end));
|
||||
assert.match(result.end.message,/CheerpJ-Java-Exception/);
|
||||
assert.doesNotMatch(result.end.message,/Cannot convert object to primitive value/);
|
||||
result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',11,{workplace:true},{diagMode:'jaas-only',jaasUserProxy:true});
|
||||
assert.equal(result.end?.state,'finished',JSON.stringify(result.end));
|
||||
result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',11,{workplace:true},{nativeMissing:true});
|
||||
assert.equal(result.end?.state,'error');
|
||||
assert.match(result.end?.message||'',/JAAS-Kompatibilitätsmodul.*404/);
|
||||
assert.ok(!result.called.some(c=>c[0]==='runMain'));
|
||||
result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',11,{workplace:true},{bridgeMissing:true});
|
||||
assert.equal(result.end?.state,'error');
|
||||
assert.match(result.end?.message||'',/JAAS-Java-Hilfsklasse.*404/);
|
||||
assert.ok(!result.called.some(c=>c[0]==='runMain'));
|
||||
result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',11,{workplace:true},{bridgeNoRange:true});
|
||||
assert.equal(result.end?.state,'error');
|
||||
assert.match(result.end?.message||'',/JAAS-Java-Hilfsklasse.*200/);
|
||||
assert.ok(!result.called.some(c=>c[0]==='runMain'));
|
||||
result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',11,{workplace:true},{providerMissing:true});
|
||||
assert.equal(result.end?.state,'error');
|
||||
assert.match(result.end.message,/JSON-P-Provider.*404/);
|
||||
assert.ok(!result.called.some(c=>Array.isArray(c)&&c[0]==='runMain'));
|
||||
result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',11,{workplace:true},{providerNoRange:true});
|
||||
assert.equal(result.end?.state,'error');
|
||||
assert.match(result.end.message,/JSON-P-Provider.*200/);
|
||||
assert.ok(!result.called.some(c=>Array.isArray(c)&&c[0]==='runMain'));
|
||||
result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',11,{workplace:true},{failTemp:true});
|
||||
assert.equal(result.end?.state,'error');
|
||||
assert.match(result.end.message,/Temp-Verzeichnis.*Speicherplatz erschöpft/);
|
||||
assert.ok(!result.called.some(c=>Array.isArray(c)&&c[0]==='runMain'),
|
||||
'Workplace darf nicht ohne benutzbaren Temp-Ordner starten.');
|
||||
result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',11,{workplace:true},{notDirectory:true});
|
||||
assert.equal(result.end?.state,'error');
|
||||
assert.match(result.end.message,/kein Verzeichnis/);
|
||||
assert.ok(!result.called.some(c=>Array.isArray(c)&&c[0]==='runMain'));
|
||||
assert.equal(result.end?.state,'finished', 'isDirectory darf nicht mehr fälschlich den Start blockieren.');
|
||||
assert.ok(result.called.some(c=>Array.isArray(c)&&c[0]==='tempProbe'));
|
||||
result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',11,{workplace:true},{blockNested:true});
|
||||
assert.equal(result.end?.state,'finished',JSON.stringify(result.end));
|
||||
assert.ok(result.called.some(c=>Array.isArray(c)&&c[0]==='setProperty'&&c[2]==='/files/itac-workplace-tmp'));
|
||||
assert.match(result.sent.find(s=>s.state==='running')?.message||'',/Ausweichverzeichnis/);
|
||||
result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',11,{workplace:true},{blockAllSubdirs:true});
|
||||
assert.equal(result.end?.state,'finished',JSON.stringify(result.end));
|
||||
assert.ok(result.called.some(c=>Array.isArray(c)&&c[0]==='setProperty'&&c[2]==='/files'));
|
||||
assert.ok(!result.called.some(c=>Array.isArray(c)&&c[0]==='tempMkdir'&&c[1]==='/files'));
|
||||
result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',11,{workplace:true},{readOnly:true});
|
||||
assert.equal(result.end?.state,'error');
|
||||
assert.match(result.end.message,/Schreiben nicht erlaubt/);
|
||||
@@ -143,5 +296,38 @@ assert.throws(()=>resolveTrusted('https://mes.internal:8181/mes/x.jnlp'),/Origin
|
||||
const backend=fs.readFileSync(new URL('../../backend/src/main/java/com/workbenchclassic/hmi/HmiWorkplaceProxyResource.java',import.meta.url),'utf8');
|
||||
assert.match(backend,/HmiImsapiGateway\.targetOrigin\(request\)/);
|
||||
assert.doesNotMatch(backend,/private static final String BASE = "https:\/\/partner/);
|
||||
assert.ok(fs.statSync(new URL('../public/cheerpj/workplace-resize-bridge-v2.jar',import.meta.url)).size>1000);
|
||||
console.log('CheerpJ contracts: JNLP, HTTP same-origin, iTAC 129 JARs, writable virtual temp directory and startup ordering validated.');
|
||||
assert.ok(fs.statSync(new URL('../public/cheerpj/workplace-window-monitor-v4.jar',import.meta.url)).size>1000);
|
||||
assert.doesNotMatch(source,/async function attachWorkplaceResize\(/, 'Remove concurrent JS resize loop');
|
||||
assert.doesNotMatch(source,/async function attachWorkplaceWindowMonitor\(/, 'Remove concurrent JS diagnostic loop');
|
||||
console.log('CheerpJ contracts: JNLP, HTTP same-origin, iTAC 129 JARs, Java11 JVM-internal WindowGeometry monitor diagnose/rescue/off, temp directory and startup ordering validated.');
|
||||
|
||||
// V5.10.23: a trusted parent can offer credentials exactly once, before main().
|
||||
responseText=fs.readFileSync(new URL('../../backend/src/main/resources/hmi/Workplace.jnlp',import.meta.url),'utf8')
|
||||
.replace('codebase="https://partner.itacsoftware.com:8181/mes/webstart/clients"',
|
||||
'codebase="/backend/api/hmi/v1/cheerpj/workplace/jars"')
|
||||
.replace('<resources>', '<resources><property name="itac.artes.clusternodes" value="'+origin+'/mes"/>');
|
||||
const credentials={username:'tester',password:'secret123',client:'any'};
|
||||
result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',11,
|
||||
{workplace:true,browserCredentials:true},{handoff:credentials});
|
||||
assert.equal(result.end?.state,'finished',JSON.stringify(result.end));
|
||||
assert.equal(result.sent.filter(m=>m.type==='hmi-cheerpj-credential-request').length,1);
|
||||
assert.ok(result.called.some(c=>c[0]==='credentialBridgeProbe'&&c[2]==='bytes=0-0'));
|
||||
assert.ok(result.called.some(c=>c[0]==='credentialOffer'&&c[1]&&c[2]&&c[3]==='any'));
|
||||
assert.ok(result.called.findIndex(c=>c[0]==='credentialOffer')<result.called.findIndex(c=>c[0]==='runMain'));
|
||||
assert.ok(result.called.findIndex(c=>c[0]==='credentialOffer')<result.called.findIndex(c=>c[0]==='windowMonitorStart'));
|
||||
const directNatives=result.called.find(c=>Array.isArray(c)&&c[0]==='init')[1].natives;
|
||||
assert.equal(typeof directNatives.Java_com_widgetworkbench_cheerpj_WorkplaceCredentialBridge_nativeReport,'function');
|
||||
await directNatives.Java_com_widgetworkbench_cheerpj_WorkplaceCredentialBridge_nativeReport(null,null,1);
|
||||
assert.ok(result.sent.some(m=>m.type==='hmi-cheerpj-auth-result'&&m.code===1));
|
||||
result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',11,
|
||||
{workplace:true,browserCredentials:true});
|
||||
assert.equal(result.end?.state,'finished');
|
||||
assert.ok(!result.called.some(c=>c[0]==='credentialOffer'));
|
||||
result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',11,
|
||||
{workplace:true,browserCredentials:true},{handoff:credentials,credentialBridgeMissing:true});
|
||||
assert.equal(result.end?.state,'finished');
|
||||
assert.ok(!result.called.some(c=>c[0]==='credentialOffer'));
|
||||
result=await launch(origin+'/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp',11,
|
||||
{workplace:true,browserCredentials:true},{handoff:credentials,offerRejected:true});
|
||||
assert.equal(result.end?.state,'finished');
|
||||
console.info('V5.10.23 one-shot credential handoff, JNI auth result, unavailable bridge, offer failure: passed.');
|
||||
|
||||
Reference in New Issue
Block a user