fix(credentials): save resident keys without replacing live credentials
This commit is contained in:
@@ -95,7 +95,8 @@ try {
|
||||
controller = new HostController({ appRoot: installedRoot, dataRoot, port, timeoutMs: 60000 });
|
||||
const connected = await controller.connect(); assert.equal(connected.identity.pid, original.pid);
|
||||
assert.equal(connected.identity.instanceId, original.instanceId);
|
||||
const after = await publicSnapshot(controller.url, dataRoot), retention = compareOriginalState(before, after);
|
||||
const after = await publicSnapshot(controller.url, dataRoot), retention = compareOriginalState(before, after,
|
||||
{ credentialDefaultsSchemaChange: previous.version === '1.25.13' && candidate.version === '1.25.14' });
|
||||
assert.equal(after.version, candidate.version); assert.equal(fs.realpathSync.native(after.runtimeRoot), fs.realpathSync.native(installedRoot));
|
||||
const pointer = read(path.join(installRoot, 'current.json'));
|
||||
assert.equal(pointer.revision, pointerBefore.revision + 1); assert.equal(pointer.previous.version, previous.version);
|
||||
@@ -107,6 +108,24 @@ try {
|
||||
const receiptBytes = fs.statSync(operationFile).size; assert.ok(receiptBytes > 4 * 1024 * 1024);
|
||||
save('state-updated.json', after); save('pointer-updated.json', pointer);
|
||||
passed(stage, { ...receipt, from: previous.version, to: after.version, pid: after.pid, instanceId: original.instanceId, retention, authenticated, receiptBytes });
|
||||
if (candidate.version === '1.25.14') {
|
||||
stage = 'save the retained old-process key internally and restore it in a new packaged process';
|
||||
const current = (await controller.api('/model-center')).connections.find(connection => connection.id === 'legacy-default');
|
||||
assert.equal(current.hasKey, true); assert.notEqual(current.savedCredential?.status, 'saved');
|
||||
const saved = await controller.api('/model-center/credentials', { method: 'POST', input: { id: current.id, revision: current.revision, action: 'save-current' } });
|
||||
assert.equal(saved.credential.status, 'saved');
|
||||
const retained = saved.center.connections.find(connection => connection.id === current.id);
|
||||
assert.equal(retained.revision, current.revision); assert.equal(retained.credentialRevision, current.credentialRevision);
|
||||
const savedState = await publicSnapshot(controller.url, dataRoot); save('state-saved.json', savedState);
|
||||
await controller.stop(); const fresh = await controller.start();
|
||||
assert.notEqual(fresh.identity.pid, original.pid); assert.notEqual(fresh.identity.instanceId, original.instanceId);
|
||||
const restored = await publicSnapshot(controller.url, dataRoot);
|
||||
const restartRetention = compareOriginalState(savedState, { ...restored, pid: savedState.pid });
|
||||
await controller.api('/config/models', { method: 'POST', input: {} }); assert.equal(authenticated, 3);
|
||||
save('state-restarted.json', restored);
|
||||
passed(stage, { pid: fresh.identity.pid, oldPid: original.pid, credentialRevision: retained.credentialRevision,
|
||||
restartRetention, authenticated, savedCiphertextUnchanged: true });
|
||||
}
|
||||
stage = 'owned program uninstall preserves data';
|
||||
await controller.stop(); controller = null;
|
||||
const baseline = snapshotPersistentData(dataRoot), uninstallLog = path.join(root, 'uninstall.log');
|
||||
|
||||
Reference in New Issue
Block a user