test(describe): mock the ?reveal=true path on --show-values
Some checks failed
Some checks failed
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:
@@ -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']);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user