|
@@ -10,7 +10,7 @@ import {ComputerMaintenance} from '../../src/runner/computers/maintenance'
|
|
|
it.skipIf(!process.env.YAOYAO_COMPUTER_IMAGE)('migrates a legacy home and keeps real browser and encrypted application authorization through rebuild and restore',async()=>{
|
|
it.skipIf(!process.env.YAOYAO_COMPUTER_IMAGE)('migrates a legacy home and keeps real browser and encrypted application authorization through rebuild and restore',async()=>{
|
|
|
const home=await mkdtemp(join(tmpdir(),'yaoyao-auth-live-'))
|
|
const home=await mkdtemp(join(tmpdir(),'yaoyao-auth-live-'))
|
|
|
const provider=new ContainerComputerProvider('docker',randomUUID(),home)
|
|
const provider=new ContainerComputerProvider('docker',randomUUID(),home)
|
|
|
- const spec:ComputerSpecification={id:randomUUID(),ownerKey:randomUUID(),imageId:process.env.YAOYAO_COMPUTER_IMAGE!}
|
|
|
|
|
|
|
+ const spec:ComputerSpecification={id:randomUUID(),ownerKey:randomUUID(),imageId:process.env.YAOYAO_COMPUTER_IMAGE!,network:process.env.YAOYAO_COMPUTER_NETWORK==='managed-proxy'?'managed-proxy':'none'}
|
|
|
const script=await readFile(new URL('../fixtures/computer_auth.mjs',import.meta.url),'utf8')
|
|
const script=await readFile(new URL('../fixtures/computer_auth.mjs',import.meta.url),'utf8')
|
|
|
const execute=(argv:string[],user:'cua'|'root'='cua')=>provider.execute(spec,argv,{authorize:()=>{},user,timeout:60000}).catch(error=>{throw new Error(`${argv[0]} ${argv.at(-1)}: ${error.stderr??error.message}`)})
|
|
const execute=(argv:string[],user:'cua'|'root'='cua')=>provider.execute(spec,argv,{authorize:()=>{},user,timeout:60000}).catch(error=>{throw new Error(`${argv[0]} ${argv.at(-1)}: ${error.stderr??error.message}`)})
|
|
|
const maintenance=new ComputerMaintenance({status:()=>[{environmentId:spec.id,status:'free'}]} as any,provider,home)
|
|
const maintenance=new ComputerMaintenance({status:()=>[{environmentId:spec.id,status:'free'}]} as any,provider,home)
|
|
@@ -18,11 +18,15 @@ it.skipIf(!process.env.YAOYAO_COMPUTER_IMAGE)('migrates a legacy home and keeps
|
|
|
try{
|
|
try{
|
|
|
// Exercise the real upgrade path from the old workspace-only container.
|
|
// Exercise the real upgrade path from the old workspace-only container.
|
|
|
const workspace=await (provider as any).workspace(provider.validateSpecification(spec))
|
|
const workspace=await (provider as any).workspace(provider.validateSpecification(spec))
|
|
|
|
|
+ if(spec.network==='managed-proxy')await (provider as any).ensureNetwork(provider.validateSpecification(spec),()=>{})
|
|
|
const created=await provider.run('docker',(provider as any).args(provider.validateSpecification(spec),workspace))
|
|
const created=await provider.run('docker',(provider as any).args(provider.validateSpecification(spec),workspace))
|
|
|
const legacyId=created.stdout.trim();await provider.run('docker',['start',legacyId])
|
|
const legacyId=created.stdout.trim();await provider.run('docker',['start',legacyId])
|
|
|
expect(JSON.parse((await execute(['node','--input-type=module','-e',script,'login'])).stdout)).toEqual({browser:true,encryptedApplicationToken:true})
|
|
expect(JSON.parse((await execute(['node','--input-type=module','-e',script,'login'])).stdout)).toEqual({browser:true,encryptedApplicationToken:true})
|
|
|
await execute(['sh','-c','mkdir -p /root/.config; printf root-fixture > /root/.config/authorization'],'root')
|
|
await execute(['sh','-c','mkdir -p /root/.config; printf root-fixture > /root/.config/authorization'],'root')
|
|
|
const identity=(await execute(['cat','/var/lib/dbus/machine-id'])).stdout
|
|
const identity=(await execute(['cat','/var/lib/dbus/machine-id'])).stdout
|
|
|
|
|
+ // The updater uses a fresh provider without a cached gateway identity.
|
|
|
|
|
+ const migration=new ContainerComputerProvider('docker',provider.runnerId,home)
|
|
|
|
|
+ expect(await migration.preserveUserData(spec)).toBe(true)
|
|
|
await provider.remove(spec)
|
|
await provider.remove(spec)
|
|
|
const migrated=await provider.ensure(spec,()=>{})
|
|
const migrated=await provider.ensure(spec,()=>{})
|
|
|
expect(migrated.containerId).not.toBe(legacyId)
|
|
expect(migrated.containerId).not.toBe(legacyId)
|