sh-mcp/packages/reminders/test/dev-client.test.ts
Adam Moussa a60a5a5794 Add security-weighted test suite + coverage gate; wire tooling
Add tests for the highest-risk surface (build-plan §5, design.md §7.3):
tool-hiding, server-side scope enforcement (incl. forced hidden calls),
audience binding, input-schema validation, finance redaction on egress, audit
emission with hashed args, prompt-injection regression (tool output is data),
rate limiting, MCP conformance (in-memory transport round-trip), OpenAPI 3.1
validity, and local-auth safety. Add HTTP integration tests (supertest) for both
servers and per-package dev-client tests. 405 tests pass.

Wire the coverage gate into vitest.config.ts: 80% overall, with per-file
thresholds on the auth + dispatch crown jewels; exclude deferred real client
stubs, entrypoints, cdk apps, and aws-only config from the gate (documented).
Extend eslint flat config + add .prettierignore to cover servers/. Commit the
updated package-lock.json.
2026-06-26 12:48:26 -04:00

32 lines
1.3 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { InMemorySchedulerClient } from '../src/dev-client.js';
const baseInput = {
scheduleName: 'reminder-abc',
scheduleAt: '2026-07-01T16:00:00Z',
targetArn: 'arn:aws:lambda:us-east-1:000000000000:function:reminder-deliver',
payload: { message: 'Follow up with vendor' },
roleArn: 'arn:aws:iam::000000000000:role/scheduler-role',
};
describe('InMemorySchedulerClient', () => {
describe('createSchedule', () => {
it('returns a deterministic ARN derived from the schedule name', async () => {
const client = new InMemorySchedulerClient();
const out = await client.createSchedule(baseInput);
expect(out.scheduleArn).toBe(
'arn:aws:scheduler:us-east-1:000000000000:schedule/dev/reminder-abc',
);
});
it('pushes each input to the public created array in call order', async () => {
const client = new InMemorySchedulerClient();
expect(client.created).toEqual([]);
await client.createSchedule(baseInput);
await client.createSchedule({ ...baseInput, scheduleName: 'reminder-xyz' });
expect(client.created).toHaveLength(2);
expect(client.created[0]).toBe(baseInput);
expect(client.created[1].scheduleName).toBe('reminder-xyz');
});
});
});