fix(server): non-numeric route ids answer the legacy not-found, never NaN (tokens, categories, tags); mint path back to two statements; identity-map regression pinned

This commit is contained in:
jubnl
2026-09-22 21:08:06 +02:00
parent 8d0dddf385
commit 44cf31c958
13 changed files with 470 additions and 99 deletions
+10
View File
@@ -778,6 +778,16 @@ describe('MCP token management', () => {
.set('Cookie', authCookie(admin.id));
expect(res.status).toBe(404);
});
it('ADMIN-025 — DELETE /admin/mcp-tokens/abc (non-numeric id) returns the legacy 404, not a 500 (Plan 3b Task 2 review, F1)', async () => {
const { user: admin } = createAdmin(testDb);
const res = await request(app)
.delete('/api/admin/mcp-tokens/abc')
.set('Cookie', authCookie(admin.id));
expect(res.status).toBe(404);
expect(res.body).toEqual({ error: 'Token not found' });
});
});
// ─────────────────────────────────────────────────────────────────────────────
+18
View File
@@ -890,4 +890,22 @@ describe('MCP token management', () => {
const res = await request(app).get('/api/auth/mcp-tokens');
expect(res.status).toBe(401);
});
it('AUTH-040 — DELETE /auth/mcp-tokens/abc (non-numeric id) returns the legacy 404, not a 500 (Plan 3b Task 2 review, F1)', async () => {
const { user } = createUser(testDb);
const res = await request(app)
.delete('/api/auth/mcp-tokens/abc')
.set('Cookie', authCookie(user.id));
expect(res.status).toBe(404);
expect(res.body).toEqual({ error: 'Token not found' });
});
it('AUTH-041 — DELETE /auth/api-tokens/abc (non-numeric id) returns the legacy 404, not a 500 (Plan 3b Task 2 review, F1)', async () => {
const { user } = createUser(testDb);
const res = await request(app)
.delete('/api/auth/api-tokens/abc')
.set('Cookie', authCookie(user.id));
expect(res.status).toBe(404);
expect(res.body).toEqual({ error: 'Token not found' });
});
});
@@ -161,4 +161,23 @@ describe('Categories', () => {
const res = await request(app).get('/api/categories');
expect(res.status).toBe(401);
});
it('CAT-011: PUT /api/categories/abc - non-numeric id returns the legacy 404, not a 500 (Plan 3b Task 2 fix round, item 1b)', async () => {
const { user: admin } = createAdmin(testDb);
const res = await request(app)
.put('/api/categories/abc')
.set('Cookie', authCookie(admin.id))
.send({ name: 'Ghost' });
expect(res.status).toBe(404);
expect(res.body).toEqual({ error: 'Category not found' });
});
it('CAT-012: DELETE /api/categories/abc - non-numeric id returns the legacy 404, not a 500 (Plan 3b Task 2 fix round, item 1b)', async () => {
const { user: admin } = createAdmin(testDb);
const res = await request(app)
.delete('/api/categories/abc')
.set('Cookie', authCookie(admin.id));
expect(res.status).toBe(404);
expect(res.body).toEqual({ error: 'Category not found' });
});
});
+32 -33
View File
@@ -37,16 +37,16 @@ import { setPluginMcpToolSource } from '../../src/plugin-mcp-tools';
import type { McpDynamicTool } from '../../src/nest-mcp';
import { getMcpSafeUrl } from '../../src/app-config';
import { OauthService } from '../../src/nest/oauth/oauth.service';
import { DatabaseService } from '../../src/nest/database/database.service';
import { createTestAddonsService } from '../helpers/test-addons';
import { AuditService } from '../../src/nest/audit/audit.service';
import { createTestOrm, type TestOrm } from '../helpers/test-orm';
import { AuditLog } from '../../src/db/entities/AuditLog.entity';
import { Users } from '../../src/db/entities/Users.entity';
import { TokenService } from '../../src/nest/tokens/token.service';
import { OauthClients } from '../../src/db/entities/OauthClients.entity';
import { OauthTokens } from '../../src/db/entities/OauthTokens.entity';
import { OauthConsents } from '../../src/db/entities/OauthConsents.entity';
import { MikroORM } from '@mikro-orm/core';
const oauthDbs = new DatabaseService(testDb);
let oauthSvc: OauthService;
/** Mint a trekoa_ access token for the user via a fresh OAuth client. */
@@ -76,7 +76,7 @@ beforeAll(async () => {
nestApp = await buildApp();
app = nestApp.getHttpAdapter().getInstance();
t = await createTestOrm(testDb);
oauthSvc = new OauthService(oauthDbs, await createTestAddonsService(testDb, oauthDbs), new AuditService(t.repo(AuditLog), t.repo(Users)));
oauthSvc = new OauthService(t.repo(OauthClients), t.repo(OauthTokens), t.repo(OauthConsents), await createTestAddonsService(testDb), new AuditService(t.repo(AuditLog), t.repo(Users)));
});
beforeEach(() => {
@@ -769,10 +769,15 @@ describe('MCP rate limiting', () => {
* (`MikroOrmModule.forRoot`'s default `registerRequestContext`, registered
* via `NestModule.configure()`/`forRoutes(ALL)`) applies to it exactly like
* every other route, BEFORE any guard runs. Verified here rather than
* assumed: `TokenService.verifyMcpToken` (TK13 in the inventory) is not yet
* repository-backed (Task 2), so this forces a genuine repository read at
* the exact point that method will occupy once converted, through the same
* DI-provided `TokenService` singleton the real `/mcp` route calls.
* assumed: `TokenService.verifyMcpToken` (TK13 in the inventory) is now
* repository-backed (`McpTokensRepository.findUserByHashAndKind` +
* `touchLastUsedByHash`, Plan 3b Task 2) — MCP-CTX-002 drives a real `trek_`
* bearer token through the genuine DI-provided `TokenService` singleton the
* `/mcp` route calls (no mock of `verifyMcpToken` itself, per the Task 2
* review's F5: a spy on the very method under test does not exercise the
* repository path it exists to guard) and asserts the repository's write
* (`last_used_at`) actually moved, which is only possible if the read ran
* inside the forked context.
*/
describe('MCP bearer-token verification runs inside the HTTP request context (Plan 3b Task 0, D6)', () => {
it('MCP-CTX-001: outside of any request, the SAME ORM refuses a query (allowGlobalContext: false is genuinely enforced, not just permissively configured)', async () => {
@@ -780,32 +785,26 @@ describe('MCP bearer-token verification runs inside the HTTP request context (Pl
await expect(orm.em.getRepository(Users).findOne({ id: 1 })).rejects.toThrow(/context/i);
});
it('MCP-CTX-002: a repository read forced inside verifyMcpToken (the trek_ bearer-token branch) succeeds — the /mcp route already forks a request context before the auth step runs', async () => {
it('MCP-CTX-002: a repository read inside verifyMcpToken (the trek_ bearer-token branch) succeeds — the /mcp route already forks a request context before the auth step runs', async () => {
testDb.prepare("UPDATE addons SET enabled = 1 WHERE id = 'mcp'").run();
const { user } = createUser(testDb);
const orm = nestApp.get(MikroORM);
const tokenService = nestApp.get(TokenService);
let found: unknown;
let caught: unknown;
const spy = vi.spyOn(tokenService, 'verifyMcpToken').mockImplementation(async () => {
try {
found = await orm.em.getRepository(Users).findOne({ id: user.id });
} catch (e) {
caught = e;
}
return found ? { id: user.id, username: user.username, email: user.email, role: user.role } : null;
});
try {
const res = await request(app)
.post('/mcp')
.set('Authorization', 'Bearer trek_forces_a_repository_read')
.set('Accept', 'application/json, text/event-stream')
.send({ jsonrpc: '2.0', method: 'initialize', id: 1, params: { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'test', version: '1' } } });
expect(caught).toBeUndefined();
expect(found).toBeTruthy();
expect(res.status).toBe(200);
} finally {
spy.mockRestore();
}
const { rawToken, id: tokenId } = createMcpToken(testDb, user.id);
const before = (testDb.prepare('SELECT last_used_at FROM mcp_tokens WHERE id = ?').get(tokenId) as { last_used_at: string | null }).last_used_at;
expect(before).toBeNull();
const res = await request(app)
.post('/mcp')
.set('Authorization', `Bearer ${rawToken}`)
.set('Accept', 'application/json, text/event-stream')
.send({ jsonrpc: '2.0', method: 'initialize', id: 1, params: { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'test', version: '1' } } });
expect(res.status).toBe(200);
// The real `TokenService.verifyMcpToken` ran `McpTokensRepository`'s
// `findUserByHashAndKind` (TK13) then `touchLastUsedByHash` (TK14) —
// `last_used_at` moving is only possible if both reached the DB, which
// MCP-CTX-001 proves the ORM refuses outside a forked request context.
const after = (testDb.prepare('SELECT last_used_at FROM mcp_tokens WHERE id = ?').get(tokenId) as { last_used_at: string | null }).last_used_at;
expect(after).not.toBeNull();
expect(after).not.toBe(before);
});
});
+19
View File
@@ -177,4 +177,23 @@ describe('Tags', () => {
const res = await request(app).get('/api/tags');
expect(res.status).toBe(401);
});
it('TAG-011: PUT /api/tags/abc - non-numeric id returns the legacy 404, not a 500 (Plan 3b Task 2 fix round, item 1b)', async () => {
const { user } = createUser(testDb);
const res = await request(app)
.put('/api/tags/abc')
.set('Cookie', authCookie(user.id))
.send({ name: 'Ghost' });
expect(res.status).toBe(404);
expect(res.body).toEqual({ error: 'Tag not found' });
});
it('TAG-012: DELETE /api/tags/abc - non-numeric id returns the legacy 404, not a 500 (Plan 3b Task 2 fix round, item 1b)', async () => {
const { user } = createUser(testDb);
const res = await request(app)
.delete('/api/tags/abc')
.set('Cookie', authCookie(user.id));
expect(res.status).toBe(404);
expect(res.body).toEqual({ error: 'Tag not found' });
});
});
@@ -1,4 +1,4 @@
import { afterAll, beforeAll, beforeEach, describe, expect, it } from 'vitest';
import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
import { createHash } from 'crypto';
import { createSnapshotTestDb } from '../../../helpers/db-mock';
import { resetTestDb } from '../../../helpers/test-db';
@@ -66,9 +66,9 @@ describe('McpTokensRepository', () => {
});
describe('insertToken', () => {
it('MCPTOKREPO-004: inserts and returns exactly the row a legacy re-select would return', async () => {
it('MCPTOKREPO-004: inserts the row a legacy re-select would return, and returns only the generated id (Plan 3b Task 2 review, F4)', async () => {
const { user } = createUser(testDb);
const row = await tokens.insertToken({
const inserted = await tokens.insertToken({
user_id: user.id,
name: 'My Token',
token_hash: 'hash-value',
@@ -77,7 +77,12 @@ describe('McpTokensRepository', () => {
scope_mode: 'all',
api_scopes: null,
});
expect(row).toStrictEqual(rawToken(row.id));
// Only `{ id }` comes back — no full-row re-select is folded into
// insertToken itself, so it cannot leak `token_hash` (or anything
// else) to a caller that only asked to mint a row. `findBasic` (TK4)
// stays the one place a caller reads the row back.
expect(Object.keys(inserted)).toEqual(['id']);
const row = rawToken(inserted.id) as Record<string, unknown>;
expect(row.user_id).toBe(user.id);
expect(row.name).toBe('My Token');
expect(row.token_hash).toBe('hash-value');
@@ -90,7 +95,7 @@ describe('McpTokensRepository', () => {
it('MCPTOKREPO-005: api_scopes is written when narrowed', async () => {
const { user } = createUser(testDb);
const row = await tokens.insertToken({
const inserted = await tokens.insertToken({
user_id: user.id,
name: 'Narrowed',
token_hash: 'hash-2',
@@ -99,9 +104,46 @@ describe('McpTokensRepository', () => {
scope_mode: 'limited',
api_scopes: '["stats","trips"]',
});
const row = rawToken(inserted.id) as { scope_mode: string; api_scopes: string };
expect(row.scope_mode).toBe('limited');
expect(row.api_scopes).toBe('["stats","trips"]');
});
it('MCPTOKREPO-024: the mint path (insertToken + findBasic) issues exactly two statements and never selects token_hash (Plan 3b Task 2 review, F4)', async () => {
const { user } = createUser(testDb);
const statements: string[] = [];
const original = testDb.prepare.bind(testDb);
const spy = vi.spyOn(testDb, 'prepare').mockImplementation((sql: string) => {
statements.push(sql);
return original(sql);
});
let insertedId: number;
try {
const inserted = await tokens.insertToken({
user_id: user.id,
name: 'Statement Count',
token_hash: 'hash-count',
token_prefix: 'trek_countpr',
kind: 'mcp',
scope_mode: 'all',
api_scopes: null,
});
insertedId = inserted.id;
await tokens.findBasic(insertedId);
} finally {
spy.mockRestore();
}
expect(statements).toHaveLength(2);
expect(statements[0].toLowerCase()).toContain('insert into');
expect(statements[1].toLowerCase()).toContain('select');
// The INSERT necessarily names `token_hash` as a column to write; the
// point is that no SELECT on the mint path reads it back into memory —
// the discarded middle re-select an earlier version issued did.
const selects = statements.filter((sql) => sql.trim().toLowerCase().startsWith('select'));
for (const sql of selects) expect(sql.toLowerCase()).not.toContain('token_hash');
});
});
describe('findBasic', () => {
@@ -247,6 +289,35 @@ describe('McpTokensRepository', () => {
it('MCPTOKREPO-018: an unknown hash is null', async () => {
expect(await tokens.findUserByHashAndKind('nope', 'api')).toBeNull();
});
it('MCPTOKREPO-025: kind is genuinely inside the generated WHERE clause, not a post-filter on the result (Plan 3b Task 2 review, F6)', async () => {
const { user } = createUser(testDb);
createMcpToken(testDb, user.id, { kind: 'mcp', rawToken: 'trek_sql_shape' });
const hash = createHash('sha256').update('trek_sql_shape').digest('hex');
const statements: string[] = [];
const original = testDb.prepare.bind(testDb);
const spy = vi.spyOn(testDb, 'prepare').mockImplementation((sql: string) => {
statements.push(sql);
return original(sql);
});
try {
await tokens.findUserByHashAndKind(hash, 'mcp');
} finally {
spy.mockRestore();
}
expect(statements).toHaveLength(1);
const select = statements[0].toLowerCase();
const whereIndex = select.indexOf('where');
expect(whereIndex).toBeGreaterThan(-1);
// `kind` must appear on the SQL side of the WHERE keyword — a
// post-filter shape (select every column, compare `kind` in JS) would
// still pass every behavioural test in this describe block (M1 in the
// review's mutation table: 56/56 green with kind moved to a JS
// check), so the SQL text itself is the only thing that can catch it.
expect(select.slice(whereIndex)).toContain('kind');
});
});
describe('touchLastUsedByHash', () => {
@@ -300,26 +371,34 @@ describe('McpTokensRepository', () => {
// ---------------------------------------------------------------------
describe('identity-map isolation (disableIdentityMap regression)', () => {
/**
* The precise, mutation-proven form of the proof: `disableIdentityMap:
* true` means the returned entity is never merged into
* `EntityManager.getUnitOfWork()`'s tracked set at all — checked
* `disableIdentityMap: true` means the returned entity is never merged
* into `EntityManager.getUnitOfWork()`'s tracked set at all — checked
* directly via `getById`, which is the same lookup MikroORM's own
* `flush()` consults to decide what to write. This is deliberately NOT
* a black-box "does a stale value get written back" behavioural test:
* hand-mutation-testing this repository (reverting `findBasic` to
* `refresh: true` and `findOwnedByKind`/`listByUserAndKind` to no
* `disableIdentityMap`, five different projection-pairing/nativeUpdate/
* flush orderings tried by hand) never reproduced a stale write-back on
* the installed MikroORM 7.2.1 + `better-sqlite3` combination — flush()'s
* dirty-checking finds nothing to write for an entity nothing ever
* mutated via `assign()`/direct property set, which is exactly the
* shape this repository's methods have (`nativeUpdate` only, never
* `assign()+flush()`, unlike `UsersRepository.patchProfile`'s callers).
* `getById` is the one assertion that DOES fail on the un-fixed code
* (verified: reverting `findBasic` to `refresh: true` flips `tracked1`
* below from `false` to `true`) — the tracking itself is the hazard the
* ruling targets, whether or not this particular table's call shapes
* manage to turn it into an observable stale write today.
* `flush()` consults to decide what to write.
*
* CORRECTION (Plan 3b Task 2 review, F2): an earlier version of this
* docstring claimed the stale write-back this ruling guards against
* could not be reproduced as an observable black-box failure on this
* repository's own call shapes, and settled for this structural
* `getById` assertion alone. That claim was wrong — it IS reproducible.
* `MCPTOKREPO-023` below is the request-shaped reproduction: read
* projection A (`listByUserAndKind`, which selects `scope_mode`), read
* projection B (`findBasic`, which does not), then a `nativeUpdate` on
* `scope_mode` inside `uow.transactional`. On the fixed code (every read
* `disableIdentityMap: true`) the `nativeUpdate` survives the block's
* closing flush. Reverting `listByUserAndKind` to a bare `find` (no
* `disableIdentityMap`) and `findBasic` to `refresh: true` instead
* reproduces the exact hazard the ruling describes: both reads merge
* into the same managed entity, the `nativeUpdate` bypasses it, and the
* closing `flush()` writes the merged entity's stale `scope_mode: 'all'`
* back over the intended `'limited'` — `update mcp_tokens set
* scope_mode='all', api_scopes=null where id=?` observed immediately
* after `update mcp_tokens set scope_mode='limited' where id=?` in the
* query log, reverting the very write the test just made. `getById`
* (this test, `MCPTOKREPO-021`) stays as the structural companion: it is
* the assertion that fails first and pinpoints which method regressed,
* while `MCPTOKREPO-023` pins the actual end-to-end behaviour the
* ruling exists to protect.
*/
it('MCPTOKREPO-021: every entity-hydrating read leaves nothing behind in the shared identity map', async () => {
const { user } = createUser(testDb);
@@ -385,5 +464,45 @@ describe('McpTokensRepository', () => {
expect((rawToken(untouched.id) as { name: string }).name).toBe('do-not-flush-me');
expect(testDb.prepare('SELECT id FROM mcp_tokens WHERE token_hash = ?').get('insert-no-side-effect-hash')).toBeDefined();
});
/**
* The request-shaped reproduction (Plan 3b Task 2 review, F2, shape D):
* projection A (`listByUserAndKind`, which selects `scope_mode`),
* projection B (`findBasic`, which does not), then a `nativeUpdate` on
* `scope_mode` — the column only projection A touched — inside
* `uow.transactional`. On the fixed code (every read
* `disableIdentityMap: true`) neither read is ever merged into the
* shared identity map, so the transaction's closing `flush()` has
* nothing stale to write and the `nativeUpdate` survives untouched.
*
* Mutation-proven by hand (not committed as a variant, per the brief —
* see the fix report for the transcript): reverting
* `listByUserAndKind`'s `find` to drop `disableIdentityMap` and
* `findBasic`'s `findOne` from `disableIdentityMap: true` to
* `refresh: true` makes this test fail — the row comes back
* `scope_mode: 'all'`, and the captured query log shows `update
* mcp_tokens set scope_mode='all', api_scopes=null where id=?` executed
* immediately AFTER `update mcp_tokens set scope_mode='limited' where
* id=?`, i.e. the transaction's closing flush silently reverting the
* intended write.
*/
it('MCPTOKREPO-023: projection A then projection B then a nativeUpdate on an A-only column, inside uow.transactional — the nativeUpdate survives the closing flush', async () => {
const { user } = createUser(testDb);
const created = createMcpToken(testDb, user.id, { name: 'stays-original', scope_mode: 'all' });
const uow = new UnitOfWork(t.em);
await uow.transactional(async () => {
// Projection A: selects `scope_mode` among its columns.
await tokens.listByUserAndKind(user.id, 'mcp');
// Projection B: a disjoint column set that does NOT select `scope_mode`.
await tokens.findBasic(created.id);
// A native write on the column only projection A touched.
await t.em.nativeUpdate(McpTokens, { id: created.id }, { scope_mode: 'limited' });
});
const row = rawToken(created.id) as { scope_mode: string; name: string };
expect(row.scope_mode).toBe('limited');
expect(row.name).toBe('stays-original');
});
});
});
@@ -0,0 +1,49 @@
import { describe, it, expect } from 'vitest';
import { toRowId } from '../../../../src/nest/common/row-id';
describe('toRowId', () => {
it('ROWID-001: rejects a non-numeric string', () => {
expect(toRowId('abc')).toBeNull();
});
it('ROWID-002: rejects a hex-shaped string — Number() would accept it, SQLite affinity never would', () => {
expect(toRowId('0x10')).toBeNull();
});
it('ROWID-003: rejects an exponent-shaped string — Number() would accept it, SQLite affinity never would', () => {
expect(toRowId('1e3')).toBeNull();
});
it('ROWID-004: rejects a negative sign', () => {
expect(toRowId('-1')).toBeNull();
});
it('ROWID-005: rejects a leading space', () => {
expect(toRowId(' 1')).toBeNull();
});
it('ROWID-006: rejects a decimal point', () => {
expect(toRowId('1.0')).toBeNull();
});
it('ROWID-007: rejects an empty string', () => {
expect(toRowId('')).toBeNull();
});
it('ROWID-008: rejects undefined', () => {
expect(toRowId(undefined)).toBeNull();
});
it('ROWID-009: accepts a plain digit string', () => {
expect(toRowId('42')).toBe(42);
});
it('ROWID-010: accepts an already-numeric safe integer', () => {
expect(toRowId(42)).toBe(42);
});
it('ROWID-011: rejects a number one past MAX_SAFE_INTEGER (2**53)', () => {
expect(toRowId(2 ** 53)).toBeNull();
});
});
+27 -2
View File
@@ -153,6 +153,16 @@ describe('MCP token service', () => {
expect(await svc.deleteMcpToken(user.id, tokenId)).toEqual({ error: 'Token not found', status: 404 });
expect(testDb.prepare('SELECT id FROM mcp_tokens WHERE id = ?').get(tokenId)).toBeDefined();
});
it('TOKEN-017: deleteMcpToken 404s (not 500) on a non-numeric id — Plan 3b Task 2 review, F1', async () => {
const { user } = createUser(testDb);
expect(await svc.deleteMcpToken(user.id, 'abc')).toEqual({ error: 'Token not found', status: 404 });
});
it('TOKEN-018: deleteMcpToken 404s on a hex-shaped id — Number("0x10") is 16, a safe integer a bare Number() conversion would accept, but SQLite affinity never would (Plan 3b Task 2 review, F1)', async () => {
const { user } = createUser(testDb);
expect(await svc.deleteMcpToken(user.id, '0x10')).toEqual({ error: 'Token not found', status: 404 });
});
});
// ---------------------------------------------------------------------------
@@ -267,10 +277,15 @@ describe('MCP token service (admin view)', () => {
await svc.createMcpToken(user.id, 'a');
await svc.createMcpToken(other.id, 'b');
const all = await svc.listAllMcpTokens() as unknown as Record<string, unknown>[];
// `listAllMcpTokens` returns the repository's own typed
// `McpTokenWithUsernameRow[]` now (Plan 3b Task 2) — no cast needed
// (Task 2 review, F7: the earlier `as unknown as Record<string,
// unknown>[]` was a double cast kept only to compile against the old
// `unknown` return type).
const all = await svc.listAllMcpTokens();
expect(all).toHaveLength(2);
expect(all.every(t => typeof t.username === 'string')).toBe(true);
expect(all.some(t => t.token_hash !== undefined)).toBe(false);
expect(all.every(t => !('token_hash' in t))).toBe(true);
});
it('TOKEN-004: adminDeleteMcpToken removes any user token and revokes that user', async () => {
@@ -287,6 +302,16 @@ describe('MCP token service (admin view)', () => {
expect(await svc.adminDeleteMcpToken('99999')).toEqual({ error: 'Token not found', status: 404 });
expect(revokeUserSessions).not.toHaveBeenCalled();
});
it('TOKEN-019: adminDeleteMcpToken 404s (not 500) on a non-numeric id, without revoking anyone — Plan 3b Task 2 review, F1', async () => {
expect(await svc.adminDeleteMcpToken('abc')).toEqual({ error: 'Token not found', status: 404 });
expect(revokeUserSessions).not.toHaveBeenCalled();
});
it('TOKEN-020: adminDeleteMcpToken 404s on a hex-shaped id (Plan 3b Task 2 review, F1)', async () => {
expect(await svc.adminDeleteMcpToken('0x10')).toEqual({ error: 'Token not found', status: 404 });
expect(revokeUserSessions).not.toHaveBeenCalled();
});
});
// ---------------------------------------------------------------------------