diff --git a/apps/api/src/application/connections/upstream-session-client.ts b/apps/api/src/application/connections/upstream-session-client.ts index 6d9bd82..396fdd1 100644 --- a/apps/api/src/application/connections/upstream-session-client.ts +++ b/apps/api/src/application/connections/upstream-session-client.ts @@ -1,6 +1,6 @@ export interface UpstreamRequest { readonly url: string; - readonly method: 'POST'; + readonly method: 'GET' | 'POST'; readonly headers: Readonly>; /** One-shot secret. Request implementations must not log or persist this field. */ readonly secret?: string; diff --git a/apps/api/src/application/resources/instance-resource-service.test.ts b/apps/api/src/application/resources/instance-resource-service.test.ts new file mode 100644 index 0000000..6c316c8 --- /dev/null +++ b/apps/api/src/application/resources/instance-resource-service.test.ts @@ -0,0 +1,48 @@ +import { describe, expect, it } from 'vitest'; + +import { parseSim, parseStats } from './instance-resource-service.js'; + +const response = (body: unknown) => ({ + status: 200, + headers: {}, + body: JSON.stringify(body), +}); + +describe('instance resource allowlist parsing', () => { + it('extracts CPU, memory and only the highest valid temperature', () => { + expect( + parseStats( + response({ + data: { + cpu_load: { load_percent: 23.4, secret: 'drop' }, + memory: { used_percent: 67.8, total_bytes: 123 }, + temperature: [ + { label: 'a', temperature: 41.2 }, + { label: 'b', temperature: 52.6 }, + { label: 'bad', temperature: 900 }, + ], + }, + }), + ), + ).toEqual({ cpuPercent: 23.4, memoryPercent: 67.8, maxTemperatureCelsius: 52.6 }); + }); + + it('extracts, validates, deduplicates and bounds phone numbers only', () => { + expect( + parseSim( + response({ + data: { + phone_numbers: ['+86 138-0000-0000', '+86 138-0000-0000', 'bad