test(describe): mock the ?reveal=true path on --show-values
Some checks failed
CI/CD / lint (push) Successful in 54s
CI/CD / test (push) Successful in 1m7s
CI/CD / typecheck (push) Successful in 2m19s
CI/CD / smoke (push) Failing after 5m9s
CI/CD / publish (push) Has been cancelled
CI/CD / build (push) Has been cancelled

Follow-up to faccbb5: the describe-secret test for --show-values used the
old fetchResource shape, so it broke after the route now goes through
client.get directly with ?reveal=true.
This commit is contained in:
Michal
2026-04-24 00:49:22 +01:00
parent faccbb58e7
commit b1bccee50d

View File

@@ -216,12 +216,27 @@ describe('describe command', () => {
});
it('shows secret detail with revealed values when --show-values', async () => {
const deps = makeDeps({
id: 'sec-1',
name: 'ha-creds',
data: { TOKEN: 'abc123' },
createdAt: '2025-01-01',
});
// --show-values takes the ?reveal=true path: bypasses fetchResource and
// calls deps.client.get('/api/v1/secrets/:id?reveal=true') directly so
// mcpd resolves through the backing driver. Mock that here.
const deps = makeDeps();
deps.client = {
get: vi.fn(async (path: string) => {
if (path.startsWith('/api/v1/secrets/sec-1')) {
return {
id: 'sec-1',
name: 'ha-creds',
data: { TOKEN: 'abc123' },
createdAt: '2025-01-01',
};
}
// resolveNameOrId path — return the matching list
if (path === '/api/v1/secrets') {
return [{ id: 'sec-1', name: 'sec-1' }];
}
return [];
}),
} as unknown as typeof deps.client;
const cmd = createDescribeCommand(deps);
await cmd.parseAsync(['node', 'test', 'secret', 'sec-1', '--show-values']);