signing-keys.test.ts 1008 B

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