Improve application responsiveness and background processing
This commit is contained in:
@@ -15,6 +15,24 @@ async function enrolled() {
|
||||
}
|
||||
|
||||
describe('native host enrollment and scoped authentication', () => {
|
||||
it('separates observation and mutation delivery and wakes long polls on newly queued work', async () => {
|
||||
const api = await enrolled();
|
||||
const inspect = api.queueHostOperation(api.host.id, 'host.inspect', {});
|
||||
const restart = api.queueHostOperation(api.host.id, 'instance.restart', {});
|
||||
const status = api.queueHostOperation(api.host.id, 'rcon.execute', { command: 'status' });
|
||||
const command = api.queueHostOperation(api.host.id, 'rcon.execute', { command: 'map_restart' });
|
||||
expect(api.pendingHostOperations(api.host.id, 'read').map(op => op.id).sort()).toEqual([inspect.id, status.id].sort());
|
||||
expect(api.pendingHostOperations(api.host.id, 'write').map(op => op.id).sort()).toEqual([restart.id, command.id].sort());
|
||||
// Let earlier enqueue notifications finish before subscribing.
|
||||
await Promise.resolve();
|
||||
const controller = new AbortController();
|
||||
const waiting = api.waitForHostWork(api.host.id, controller.signal, 20_000);
|
||||
api.queueHostOperation(api.host.id, 'host.inspect', {});
|
||||
await waiting;
|
||||
const aborted = api.waitForHostWork(api.host.id, controller.signal, 20_000);
|
||||
controller.abort();
|
||||
await aborted;
|
||||
});
|
||||
it('consumes an enrollment exactly once and stores only credential hashes', async () => {
|
||||
const api = await enrolled();
|
||||
expect(api.authenticateCredential(api.credentials.credential)?.id).toBe(api.host.id);
|
||||
|
||||
Reference in New Issue
Block a user