maestro/src/bridge/a2a/oidc-keys.test.ts
oss-sync b1292e34b2
Some checks failed
CI / build-and-test (push) Has been cancelled
sync: update from private repo (edc775f2)
2026-07-06 01:04:12 +00:00

20 lines
802 B
TypeScript

import { describe, it, expect } from 'vitest';
import { mkdtempSync, existsSync, rmSync } from 'fs';
import { tmpdir } from 'os';
import { join } from 'path';
import { loadOrCreateJwks } from './oidc-keys.js';
describe('loadOrCreateJwks', () => {
it('creates a persistent RSA JWKS and reloads the same key', () => {
const dir = mkdtempSync(join(tmpdir(), 'a2a-jwks-'));
const first = loadOrCreateJwks(dir);
expect(first.keys).toHaveLength(1);
expect(first.keys[0]).toMatchObject({ kty: 'RSA' });
expect(first.keys[0]).toHaveProperty('d');
expect(existsSync(join(dir, 'a2a-jwks.json'))).toBe(true);
const second = loadOrCreateJwks(dir);
expect((second.keys[0] as any).kid).toBe((first.keys[0] as any).kid);
rmSync(dir, { recursive: true, force: true });
});
});