signing-keys.test.ts39 lines · main
1import { beforeEach, describe, expect, it, vi } from 'vitest'
2
3import { getLegacySigningKey } from './signing-keys'
4
5vi.mock('./util', () => ({
6 assertSelfHosted: vi.fn(),
7}))
8
9describe('api/self-hosted/signing-keys', () => {
10 let mockAssertSelfHosted: ReturnType<typeof vi.fn>
11
12 beforeEach(async () => {
13 vi.clearAllMocks()
14 vi.resetModules()
15
16 const util = await import('./util')
17 mockAssertSelfHosted = vi.mocked(util.assertSelfHosted)
18 })
19
20 describe('getLegacySigningKey', () => {
21 it('should call assertSelfHosted', () => {
22 getLegacySigningKey()
23
24 expect(mockAssertSelfHosted).toHaveBeenCalled()
25 })
26
27 it('should return a SigningKeyResponse-shaped legacy entry', () => {
28 const key = getLegacySigningKey()
29
30 expect(key).toEqual({
31 id: '00000000-0000-0000-0000-000000000000',
32 algorithm: 'HS256',
33 status: 'in_use',
34 created_at: '1970-01-01T00:00:00.000Z',
35 updated_at: '1970-01-01T00:00:00.000Z',
36 })
37 })
38 })
39})