This commit is contained in:
@@ -1298,6 +1298,44 @@ describe('native instance provisioning', () => {
|
||||
await advance();
|
||||
expect(nativeInstance(job.name)?.generation).toBe(2);
|
||||
});
|
||||
it('prepares separate moderation credentials for the replacement generation', async () => {
|
||||
const job = await queue();
|
||||
const { config } = await import('../../src/lib/server/config.js');
|
||||
(config as { publicUrl: string }).publicUrl = 'https://public-controller.example';
|
||||
const { heartbeat } = await import('../../src/lib/server/hosts/index.js');
|
||||
heartbeat(hostId, {
|
||||
...inventory(),
|
||||
capabilities: [...inventory().capabilities, 'moderation.configure']
|
||||
});
|
||||
await advance();
|
||||
const created = await acknowledge(job.deploymentId);
|
||||
const oldToken = (created.payload.moderation as { token: string }).token;
|
||||
const { queueNativeRebuild } = await import('../../src/lib/server/provisioning/native.js');
|
||||
const rebuild = queueNativeRebuild(job.name, 'test');
|
||||
if (!rebuild.ok) throw new Error(rebuild.message);
|
||||
await advance();
|
||||
const operation = (await operationFor(rebuild.deploymentId))!;
|
||||
expect(operation).toMatchObject({
|
||||
generation: 1,
|
||||
payload: {
|
||||
nextGeneration: 2,
|
||||
moderation: { generation: 2, configPath: 'configs/electric_cherry_moderation.cfg' }
|
||||
}
|
||||
});
|
||||
const newToken = (operation.payload.moderation as { token: string }).token;
|
||||
expect(newToken).not.toBe(oldToken);
|
||||
const { authenticateModerationRuntime } =
|
||||
await import('../../src/lib/server/moderation/credentials.js');
|
||||
const request = (token: string) =>
|
||||
new Request('https://public-controller.example/api/moderation/runtime', {
|
||||
headers: { Authorization: `Bearer ${token}` }
|
||||
});
|
||||
expect(authenticateModerationRuntime(request(oldToken))).toMatchObject({ generation: 1 });
|
||||
expect(authenticateModerationRuntime(request(newToken))).toBeNull();
|
||||
await acknowledge(rebuild.deploymentId);
|
||||
expect(authenticateModerationRuntime(request(oldToken))).toBeNull();
|
||||
expect(authenticateModerationRuntime(request(newToken))).toMatchObject({ generation: 2 });
|
||||
});
|
||||
it('carries confirmed admin override through serialized rebuild preparation', async () => {
|
||||
const job = await queue();
|
||||
await advance();
|
||||
|
||||
Reference in New Issue
Block a user