Coves frontend - a photon fork
1import { describe, it, expect, vi } from 'vitest'
2
3// Mock import.meta.env before importing the module
4vi.stubGlobal('import', {
5 meta: {
6 env: {
7 PROD: true,
8 },
9 },
10})
11
12describe('cookies configuration', () => {
13 describe('PENDING_AUTH_COOKIE_OPTIONS', () => {
14 it('should have httpOnly enabled for security', async () => {
15 const { PENDING_AUTH_COOKIE_OPTIONS } = await import('./cookies')
16 expect(PENDING_AUTH_COOKIE_OPTIONS.httpOnly).toBe(true)
17 })
18
19 it('should use lax sameSite for OAuth redirect compatibility', async () => {
20 const { PENDING_AUTH_COOKIE_OPTIONS } = await import('./cookies')
21 expect(PENDING_AUTH_COOKIE_OPTIONS.sameSite).toBe('lax')
22 })
23
24 it('should set path to root', async () => {
25 const { PENDING_AUTH_COOKIE_OPTIONS } = await import('./cookies')
26 expect(PENDING_AUTH_COOKIE_OPTIONS.path).toBe('/')
27 })
28
29 it('should have a 10-minute maxAge for short-lived OAuth state', async () => {
30 const { PENDING_AUTH_COOKIE_OPTIONS } = await import('./cookies')
31 const tenMinutesInSeconds = 60 * 10
32 expect(PENDING_AUTH_COOKIE_OPTIONS.maxAge).toBe(tenMinutesInSeconds)
33 })
34 })
35})