import { describe, expect, test } from 'bun:test'; import { handleTokenList, handleTokenObtain, handleTokenRevoke } from './token'; // These cover the argument-validation paths that short-circuit BEFORE the idp // capability is loaded — no DB or authentik needed. The idp-side behavior // (mint / list / revoke) is covered in modules/authentik/scripts/idp-functions.test.ts. describe('celilo token — argument validation', () => { test('obtain requires a username', async () => { const result = await handleTokenObtain([], {}); expect(result.success).toBe(false); if (!result.success) expect(result.error).toMatch(/Username required/); }); test('list requires a username', async () => { const result = await handleTokenList([], {}); expect(result.success).toBe(false); if (!result.success) expect(result.error).toMatch(/Username required/); }); test('revoke requires an identifier', async () => { const result = await handleTokenRevoke([], {}); expect(result.success).toBe(false); if (!result.success) expect(result.error).toMatch(/Identifier required/); }); });