import assert from 'node:assert/strict'; import fs from 'node:fs'; import jaas from '../public/cheerpj/natives/jaas.js'; const call = jaas.Java_com_sun_security_auth_module_UnixSystem_getUnixInfo; assert.equal(typeof call, 'function'); const unixSystem = { identity: null }; let invocations = 0; const lib = { com: { widgetworkbench: { cheerpj: { JaasIdentityBridge: { populate: async (instance) => { assert.strictEqual(instance, unixSystem); instance.identity = 'cheerpj-client'; invocations++; return 'cheerpj-client'; }, }, }}}}; await call(lib, unixSystem); assert.equal(invocations, 1); assert.equal(unixSystem.identity, 'cheerpj-client'); await assert.rejects(call(null, unixSystem), /missing native context/); await assert.rejects(call({}, unixSystem), /Cannot read|not on the Workplace classpath/); await assert.rejects(call({com:{widgetworkbench:{cheerpj:{JaasIdentityBridge:{populate:async()=> 'root'}}}}},unixSystem), /unexpected identity/); const jar = new URL('../public/cheerpj/jaas-identity-bridge.jar', import.meta.url); assert.ok(fs.statSync(jar).size > 1000); console.log('CheerpJ JAAS native helper contracts: isolated implementation, no vendor modification, synthetic username only.');